What am I doing wrong? The new Backend-M3U doesn't work for me

Moving discussion from Issues · mopidy/mopidy · GitHub

Hi.

I created an m3u file which contains only this one line:

/home/pi/01_track.mp3
When I started mopidy I get this message(s):

Loaded 1 M3U playlists from /home/pi/.local/share/mopidy/m3u
So mopidy recognize my m3u playlist but when I would like to play this track I post this json:

{“method”:“core.tracklist.add”,“jsonrpc”:“2.0”,“id”:111,“params”:{“uri”:“file:///home/pi/01_track.mp3”}}
I get the track uri from playlist object, and the response is:

{“id”:111,“jsonrpc”:“2.0”,“result”:}
What am I doing wrong? Should I do something more to use the m3u playlist? Any guess?

Another way how I tested my m3u playlist:
I tested with a webclient, I able to add the track to the tracklist via this webclient but when I would like to play this song the server log said:

WARNING Track is not playable: file:///home/pi/01_track.mp3

I tried reproducing this issue, but it seems to work for me:

$ ls -l /home/jodal/blank.mp3
-rw-rw-r-- 1 jodal jodal 9360 Apr  1 19:50 blank.mp3
$ cat /home/jodal/.local/share/mopidy/m3u/foo.m3u
/home/jodal/blank.mp3

When starting Mopidy:

INFO     Loaded 1 M3U playlists from /home/jodal/.local/share/mopidy/m3u

Then I load and play the playlist with the mpc client:

$ mpc clear                                                   
volume:100%   repeat: off   random: off   single: off   consume: off
$ mpc load foo                                                
loading: foo
$ mpc playlist                                                
file:///home/jodal/blank.mp3
$ mpc play; sleep 1; mpc status; sleep 5; mpc status          
file:///home/jodal/blank.mp3
[playing] #1/1   0:04/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
# sleep 1 goes here
file:///home/jodal/blank.mp3
[playing] #1/1   0:01/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: off
# sleep 5 goes here
volume:100%   repeat: off   random: off   single: off   consume: off
$

Note that the local backend only plays local:... URIs. To play file:// URIs, you must leave the stream backend enabled.

OK. Sorry but I didnt know that I have to enabled the stream backend. So now it works from a web client.
But my main problem is that I cant add the track to the playlist with HTTP-JSON message.

{"method":"core.tracklist.add","jsonrpc":"2.0","id":111,"params":{"uri":"file:///home/pi/01_track.mp3"}}

What else should I post in the uri field? This is not worked for me: file:///home/pi/01_track.mp3

Can you make it work from the command line with curl?

$ curl -H "Content-Type: application/json" -X POST -d '{"jsonrpc": "2.0", "id": 1, "method": "core.tracklist.add", "params": {"uri": "file:///home/jodal/blank.mp3"}}' http://localhost:6680/mopidy/rpc

Output when I run it, showing that the track is successfully added to the tracklist:

{"jsonrpc": "2.0", "id": 1, "result": [{"track": {"album": {"__model__": "Album", "num_tracks": 2, "name": "album"}, "__model__": "Track", "name": "title", "uri": "file:///home/jodal/blank.mp3", "length": 4680, "track_no": 1, "artists": [{"__model__": "Artist", "name": "artist"}], "date": "2010-01-01", "bitrate": 14030}, "__model__": "TlTrack", "tlid": 3}]}%            

Thanks. It works via curl, I think my third party library (what I use) has some problem with the backslash. Thanks again.