JSON RPC PlayMedia (was Starter for 10)
#1
Hi people. I'm new to XBMC development. I've had a play with a few plugins, but not touched XBMC proper, until now Smile

Working on the iPlayer plugin, I found a problem that using the JSON API I can't play ASX files. I tracked this down to the fact that the JSON API uses g_ApplicationMessenger to play files. This function takes a list of file items, creates a playlist and starts playing using g_Application.PlayFile.

The problem with this is that some playable types (last fm streams, smart playlists) can't be handled in a playlist, and thus are called by the function g_Application.PlayMedia (which handles these special cases and then falls through to PlayFile). Currently he only way to access the PlayMedia function is by using ExecuteBuiltin('PlayMedia'). However it seems we want to move away from the ExecuteBuiltin function for common tasks.

In regards to this I've modified the g_ApplicationMessenger function to see if it has been asked to play a single file (that isn't a playlist). If so then it passes that to PlayMedia instead of PlayFile. This allows these special types to be handled. Secondly I have allowed PlayMedia to resolve Plugin types and call itself again. This allows plugins to resolve to last fm streams, smarts playlists, internet playlists etc using setResolvedURL.

As this is my first hacking of XBMC, I'm not sure what the procedure is to have other people look at this. My changes are in a branch on my forked repo https://github.com/AWilco/xbmc/commits/wilcodev
commits https://github.com/AWilco/xbmc/commit/9f...5b168a6f85
and https://github.com/AWilco/xbmc/commit/6d...77226220cd
are the 2 changes.

Unfortunately this branch has some changes to keyboard.xml that I use with my setup. Do you need a completely clean branch or can you cherry-pick the commits with github?
Reply
#2
While I am not a dev, your suggestions look reasonable. But the subject is not likely to draw any attention. I took the liberty to change it.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#3
I haven't tested it but it sounds and looks promising.

Best way for it to get into xbmc master is to do the following:
  1. Create a new clean branch of current xbmc master (so your patch is up-to-date)
  2. Apply the two commits onto the new branch, resolve any conflicts and squash them into a single commit (as the second commit is simply a fixup of the first one)
  3. Clean up some stuff in your code (see comments in your commit on github)
  4. Create a pull request on github

If you need help with any of these steps let me know.
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
#4
Hey @AWilco, thats crazy, but I was just about to fork XBMC and make these changes myself. I need to be able to play lastfm streams through the API.
Thanks heaps for your work, I'm going to apply those commits and recompile xbmc today.
Reply
#5
It works beautifully, cheers! Big Grin
Reply
#6
I've generated a pull request for this at 64 (PR)
Reply
#7
Okay, for those that would like to test this, I have a setup with a modified XBMC iplayer plugin.

Firstly you need to install my modified xbmc iPlayer plugin available at https://github.com/AWilco/iplayerv2 . This contains code modifications to allow JSON RPC calls to iPlayer URLs.

With this installed, the easiest way to test the specific mods I've made to XBMC is to install my firefox plugin at http://www.awilco.net/doku/xbmciplayer

This plugin allows you to browse the iPlayer web site in firefox, and then shows a command to play it on your XBMC media player. Select a radio feed and then click "Play in XBMC".

This will test both if the JSON RPC now calls PlayMedia instead of PlayFile (as Radio streams are smart playlists that only work while using PlayMedia) and also that PlayMedia can resolve plugin URLS (as JSON RPC is sent a plugin://plugin.video.iplayer/.... link that resolves to the internet playlist).

Note if you install the firefox plugin you will need to set up the plugin options to point to your XBMC server.

If you don't want to install the plugin then a carefully crafted JSON RPC call with the following POST data should work

{"jsonrpc":"2.0","method":"XBMC.Play","params":"plugin://plugin.video.iplayer/?resolveURL=True&pid=b00zlfkp","id":1}

I hope somebody can test this so it can get pushed to master!
Reply
#8
Great patches!
Reply
#9
If you've tested this patch could you just comment to say that it worked, and what OS you're running? testing it enough to get it included is the next challenge.
Reply

Logout Mark Read Team Forum Stats Members Help
JSON RPC PlayMedia (was Starter for 10)0