Creating web clients that are backend-aware

Is it possible / a good idea to create web clients that are backend aware?

One example of why this may be useful is for web streaming services that contain additional features beyond just regular playback (e.g. the ability to rate songs in Pandora). If the web client knows which backend is being used, it could adapt the UI to accommodate the additional functionality by rendering additional buttons on screen.

Are there any examples of how this has been done, and is it something that the current API supports / encourages? I’m thinking that on a conceptual level this will involve interrogating the Mopidy registry for the list of installed backend extensions, adding the public methods to the extension’s PlaybackProvider, and then somehow exposing the new API in JavaScript to be used by the web client?

This should be possible, if it’s a good idea I’m a bit unsure about. Similar things have come up before, having a love/favorite, ban and rate n-m type support.

Some relevant issues:

Of these #263 is the one that best covers our currently vapor ware “metadata api” idea. Our thinking for this has been to have certain fixed metadata more or less corresponding what we have in the models today. And then supplement that with extension provided metadata. This could be data from things like lastfm or things like ratings/favorite/banned. But things haven’t taken enough form to get any where quite yet :frowning:

If we we’re to add support for this type of case I’m assuming supporting ratings from n to m, love and ban “actions” would be enough. We just need to see how to integrate it cleanly given our multitude of backends.

For an example of a client implementing beyond what mopidy currently
supports you can take a look at mopidy-mopify. It uses Spotify Web API
calls to provide more functionality. It does this entirely outside of
Mopidy and has to jump through a hoops in order to do so (with regard to
authorisation and sharing state between clients) but works well. So even
without support within Mopidy you can still do a lot.

Will the service framework being proposed at: not also make this easier?

Either that, or a standard way of expanding the JSON RPC API for mopidy extensions.

Looks like the implementation that you are referring to is based on this:

It uses Angular which I am not familiar with and not currently being used in the Pi Musicbox web client. Are you aware of any simple examples of how to make JSON RPC calls in Mopidy for anything not included in ‘core’?