2011-12-29, 18:20
Many plugins (for instance Google Listen) provides XBMC with a fully functioning URL to play.
This is the obvious implementation, but also extremely slow. XBMC will try to get MIME data for all the links. Thus if you have a list of 50 mp3's, the user will have to wait for XBMC to connect to all 50 urls, and check that it is an mp3.
For a faster implementation you can make a "start playback" function in your plugin, and give XBMC an URL to your playback url.
In the YouTube plugin a video is always given the following url:
And then a playback function like this.
Unless the plugin is using some kind of cache to remember the playable URL, they source will have to be fetched again. But this will still be a lot faster than having XBMC check MIME type of every item.
It is, of course, also possible to use an URL like this.
Instead of using a cache or doing a second lookup.
And added bonus of doing this is that the servers we are requesting from will be hammered less. So the webmasters should be happier with us.
This is the obvious implementation, but also extremely slow. XBMC will try to get MIME data for all the links. Thus if you have a list of 50 mp3's, the user will have to wait for XBMC to connect to all 50 urls, and check that it is an mp3.
For a faster implementation you can make a "start playback" function in your plugin, and give XBMC an URL to your playback url.
In the YouTube plugin a video is always given the following url:
PHP Code:
plugin://plugin.video.youtube/?path=root/video&action=play_video&videoid=ID
And then a playback function like this.
PHP Code:
def playVideo(self, params={}):
get = params.get
video = self.getVideoObject(params)
listitem = xbmcgui.ListItem(label=video['Title'], iconImage=video['thumbnail'], thumbnailImage=video['thumbnail'], path=video['video_url'])
xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=listitem)
Unless the plugin is using some kind of cache to remember the playable URL, they source will have to be fetched again. But this will still be a lot faster than having XBMC check MIME type of every item.
It is, of course, also possible to use an URL like this.
PHP Code:
plugin://plugin.some.plugin/?path=root&action=play&url=urllib.quote(my_url)
And added bonus of doing this is that the servers we are requesting from will be hammered less. So the webmasters should be happier with us.