How to receive the 'Play on XBMC' event on my addon?
#1
Hi all,

I may be doing the wrong queries but I didn't find anything on this topic.
I want my python video plugin to receive the 'Play on XBMC' event, when you send something to XBMC with your device.
Just like the Youtube plugin does it. You can share to xbmc a youtube video and the plugin will make its stuff to play it on XBMC.

Can someone show me how to do it, or point me to the right direction, please.
Reply
#2
I am not sure what "Play on XBMC" you are referring to, as there are many possibilities: through UPnP discovery, chrome/firefox add-ons using JSONRPC, or mobile devices apps and widgets using JSONRPC.

I am not familiar with UPnP protocol, but it mainly streaming a direct link from the source device to the destination. Many of the add-ons/apps using JSONRPC are handling the URL detection themselves and then pass it to the right plugin (YouTube, Vimeo...) by RPCing the appropriate plugin with the URL. So they are parsing the URL, finding the right plugin, find that plugin URL, and execute it through JSONRPC from within the add-on/app.
http://mirrors.xbmc.org/docs/python-docs/13.0-gotham/
http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v6

I am not sure what you are trying to achieve. You can subclass xbmc.Player, and then monitor the start/stop/queueditem..etc events, and act upon each event if you wish. Or maybe you could use the xbmc.setResolvedUrl in your add-on, and develop/modify an external app that pass everything to it, and your add-on resolves it. I would say take a look at the source of the add-on/app you are referring to (if there is a source) and modify it.
Reply
#3
Thanks for the reply tria.

By looking into the xbmc.log file, and using the Yatse remote app to send a video to my XBMC I realized the app is in deed parsing the youtube URL itself, calling the Youtube plugin with the correct URL through a Player.Open JSONRPC request just like you said.

For my application, what I would like to do is. Make my video plugin intercept any JSONRPC Player.Open request, check if the URL is from a website I want extract the video from, then change the URL and let XBMC play the correct video URL. I searched for ways to "intercept" a JSONRPC request. What I got is, to extend the xbmc.Monitor class and override the onNotification method to get the JSONRPC. But then came my doubts.

I just need to create a class in my video plugin that extends xbmc.Monitor, leave the code there, and xbmc will always call it upon receiving a JSONRPC request? Just by letting my video plugin Active?
Or maybe I need to create a python script, keep it alive with a 'while' loop so it can intercept the JSONRPC request.

And another one. Is it possible to change the URL in the request and let XBMC do it's thing to play the video, or I'll have to get the JSONRPC, stop XBMC from processing it and calling xbmc.Player().play myself to finally play the video?
Reply
#4
I think you can only intercept, but you cannot prevent an event from occurring. Even when you intercept, you still need to parse the URLs (and the possible Script/Plugin URLs).

Extending xbmc.Monitor is a good start. Extending xbmc.Player, will give you the direct resolved link regardless of which plugin handled it (you can get the same information from xbmc.Monitor but with less details).

You shouldn't create a video plugin, but rather a script/service addon. Of course, you can have another video add-on to go with it, but generally the Monitor part should be in a service looping forever until it receives xbmc.abortRequested.

You cannot change or prevent any request as far as I know. As you suggested, you can intercept, parse/modify, and replay (stop-play).
Good Luck.
Reply

Logout Mark Read Team Forum Stats Members Help
How to receive the 'Play on XBMC' event on my addon?0