prefetching content for plugins?
#1
Hello all,

I have a plugin, which currently is synchronous: the user chooses a menu item, then the plugin does an http api request to the content provider, waits for the request to complete and the result is shown to the user.

I would like to change this so that the requests are prefetched while the menu is shown to the user, asynchronously. Or in other words, this could described as "background loading".

My current idea is to create a separate service addon for the plugin, so that on plugin startup the service is signaled to start prefetching, and then at each menu item selected by the user, the service would start prefetching the next items and return the prefetched item to the plugin. If prefetching is not done yet, then the request from the plugin to the service would block until the prefetch request is ready. In the best case, the service addon could be a generic http prefetcher for any plugin.

Thoughts?

Before I start exploring this further (I don´t have much experience with service addons), does anyone know if this is possible with a service addon, and obviously in such a way that it´s okay to be included in the official addon repo?
Reply
#2
http://forum.xbmc.org/showthread.php?tid=176864

...might help?
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#3
(2014-04-14, 02:52)bossanova808 Wrote: http://forum.xbmc.org/showthread.php?tid=176864

...might help?

That thread deals with a skin feature so it does not help at all.

...

However, I got another, simpler idea on how I can do the prefetching pretty easily: The plugin can call itself "recursively", with

Code:
import xbmc
xbmc.executebuiltin('XBMC.RunScript("plugin.id","first","second","third etc...")')

The RunScript "builtin" is asyncronous, it returns immediately so I can use that to fire up the prefetch http requests and store the results locally in a cache. Then elsewhere in the plugin, instead of doing http requests normally, I can first check the cache if it's there already, or if that very request is being prefetched currently (minding race conditions while doing all that).

Note: parameter "first" with plugins is the "handle", and the "second" parameter is the url-encoded "parameter list". So usually with plugins which use the "mode" url-encoded parameter, you'd call XBMC.RunScript("plugin.name","","mode=whatever"...etc)
Reply

Logout Mark Read Team Forum Stats Members Help
prefetching content for plugins?0