API call to playback file or stream

Hi everybody,

I’m working on an extension to play a local file (or radio stream) depending on the information on a NFC card (using NXP Explore & Raspberry). Almost like the “cassette player”.

So right now I’m graceful for any code snippet that shows me how to start the playback for an URI. Like playback.play(‘file:/music/country/foo.mp3’) or playback.play(‘http://my-radio-station’).

I have 15 years experience in software development but I’m pretty stuck with python :wink:


you don’t need to use Mopidy for that.

To play a URL or file you can simply pass the location to Gastreamer like
"gst-play-1.0 http://mp3stream7.apasf.apa.at:8000"


P.S.: I’m really interested in your NFC project. Do you have some docu about it somewhere?

Hi Michael,

thanks for your hint. Besides streaming radio stations I would like to play m3u/Spotify playlists. So Mopidy is the best solution for that.

I the meantime I found a snippet how playback is done in Mopidy:

Using NFC & Raspberry is quite easy (in theorie ;-)).
Hardware: http://www.element14.com/community/community/designcenter/explorenfc

This is Python wrapper to access the hardware: https://github.com/svvitale/nxppy
Check out the polling example.


Use mpc if you just want to fire a few commands at mopidy in response to
some event. If you find this isn’t enough then, yes, write an extension.
There are numerous extensions out there to provide examples and there is
documentation for everything at docs.mopidy.com.