Help : using JSON RPC to play URL
#1
Hello,

I would like to play video from a remote server and using the JSON RPC.
The video could be a :
- IP live channel (RTP stream) (ex : rtp://@232.0.1.13:8200)
- a HTTP file (youtube, dailymotion...) (ex : http://a1408.g.akamai.net/5/1408/1388/20..._mpeg4.mp4)

1) I did not find any JSON RPC Method that allows me to achieve that.
Could anyone confirm me that no method exist ?

2) I tried using playlists.
I wrote 2 .m3u playlists that I copied in the .xbmc/userdata/playlists/video directory.
From the XBMC GUI, I can see them and I can launch the playing of remote video and IPTV streams.

The following JSON RPC requests are strange to me :

request =
{"jsonrpc": "2.0", "method": "Playlist.GetPlaylists", "id": 1}
answer =
{"id":1,"jsonrpc":"2.0","result":[{"playlistid":0,"type":"audio"},{"playlistid":1,"type":"video"},{"playlistid":2,"type":"picture"}]}

=> where are my 2 video playlists ?

request =
{"jsonrpc": "2.0", "method": "Playlist.GetItems", "params": { "properties": [ "file" ], "playlistid": 1}, "id": 1}
answer =
{"id":1,"jsonrpc":"2.0","result":{"limits":{"end":0,"start":0,"total":0}}}

=> Obviously, something is wrong somewhere

request =
{"jsonrpc": "2.0", "method": "Player.Open", "params": [{ "playlistid": 1 }], "id": 1}
answer =
{"id":1,"jsonrpc":"2.0","result":"OK"}

=> XBMC do not launch the playing

=> Is it possible to use .m3u playlists with JSON RPC in order to
- get the list of existing video playlist
- select one of them (getting info to identify the one to modify)
- modify the selected playlist (add or remove an item)
- launch the playing

Thank you
Reply
#2
First of all if you want to start any video (stream) you can simply use Player.Open and pass the path or URL in the "file" property of the "item" parameter.

Secondly you misunderstand how the Playlist namespace works. Playlist.GetPlaylists returns all playlists loaded in XBMC and doesn't list any m3u or smartplaylists stored on a disc. Right now there are always 3 playlists: music (playlistid = 0), video (1) and pictures (2) and you can modify them using Playlist.Add/Insert/Remove/Clear. Therefore Playlist.GetItems returns an empty list if you haven't manually added any items to the playlist and Player.Open for that playlist doesn't work either because it's empty.

I'd recommend either passing the streaming URL OR the m3u path to Player.Open's "file" property in the "item" parameter instead of messing with the playlist.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#3
Thank you for your quick answer !
using Player.Open as you recommended I managed to do what I wanted, thanks.
Reply
#4
Hi,

I am trying to use Player.open as follows:

http://192.168.1.114/jsonrpc?request={"jsonrpc":"2.0", "id":1, "method": "Player.Open", "params":{"item":{"file":"http:/xxx.xxx.xxx.xx/movies_test/movie_high/1321.mp4?st=sxfndA6iJpRZN4LN72RvKg&e=1366135717"}}}

and I am getting a ParseError:

{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}

Not sure what I am doing wrong. Other commands like the following works:

http://192.168.1.114/jsonrpc?request={"jsonrpc":"2.0", "id": 1, "method": "Playlist.GetPlaylists"}

I get a response {"id":1,"jsonrpc":"2.0","result":[{"playlistid":0,"type":"audio"},{"playlistid":1,"type":"video"},{"playlistid":2,"type":"picture"}]}

So, the link is working fine. Also, if I directly open the link in my browser, it starts playing the video. Can someone help here?
Reply
#5
Figured out why it was not working. It was the & in the url which was breaking things. I changed to %26 which is the ascii value for & and all is fine.
Reply
#6
When using HTTP GET requests for JSON-RPC you need to URL encode the whole request. Your browser does that for you automatically which is why it works there.
Reply
#7
Trying to play a playlist from within webcore using JSON-RPC. This works perfectly from my browser and starts playing the playlist :

http://192.168.0.51:8081/jsonrpc?request={"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item":{"file":"special://profile/playlists/music/Christian.xsp"}}}

When I URL encode within webcore I use this :

http://192.168.0.51:8081/jsonrpc?request...its.xsp%22}}}

This does not work. Do I have to use my external IP since this request is technically coming from SmartThings? I have port forwarded 8081 but using my external IP does not work either.
Reply
#8
"http://192.168.0.51:8081/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22id%22:%221%22,%22method%22:%22Player.Open%22,%22params%22:{%22item%22:{%22file%22:%22special://profile/playlists/music/80%27s%20hits.xsp%22}}}"
Reply

Logout Mark Read Team Forum Stats Members Help
Help : using JSON RPC to play URL0