Get current plugin context
#1
My plugin is able to operate under both Video and Music sections. I want it to display different information depending on which section (context) it is working. Having scoured the API refs, I can find nothing that will let me determine whether I am in audio or video. Can anyone tell me how this is done please?

TIA
System info: Asrock ION330HT-BD (Intel Atom 330 4 core i686) connected to Sony KDL-Z5800 TV using hdmi via Onkyo TX-SR507 AV Amp. [Old Config Ubuntu 12.04. (Linux 3.2.0-32-generic-pae ) XBMCBuntu (Eden 11.0 Git:unknown Compiled Mar 24 2012). OpenGL 3.3.0 NVIDIA 280.13] New Config unknown - no working XBMC at moment!
Reply
#2
Hmm, good question. One way would be to request which window is active (xbmcgui module), though that feels like a bit of a hack to me (you'd have to check against the 2 separate library/files windows).

Anyone else with any ideas?
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.


Image
Reply
#3
My feel is that the plugin and addon libs need rolling in together. Actually as most addons need xbmc plugin and addon, why are they separated. I suspect it's organic growth but with release of dharma it may not be a bad opportunity to deprecate some of it.

I apologize for opening a can of worms in my endeavour to write the documentation but hopefully I'm throwing up some inconsistencies in what is being intended by one side of the dev effort and what is actually supported in the published API

So in this instance either the addons.XML spec requires changing to only allow one media type (boo hiss) or the python api needs additional functionalty to support it, (yeah)

Cheers
Ashley
System info: Asrock ION330HT-BD (Intel Atom 330 4 core i686) connected to Sony KDL-Z5800 TV using hdmi via Onkyo TX-SR507 AV Amp. [Old Config Ubuntu 12.04. (Linux 3.2.0-32-generic-pae ) XBMCBuntu (Eden 11.0 Git:unknown Compiled Mar 24 2012). OpenGL 3.3.0 NVIDIA 280.13] New Config unknown - no working XBMC at moment!
Reply
#4
No need to apologize at all, and I agree that a function to supply that information would be useful. I wonder whether it is reasonable, however, to allow the function to actually specify that XBMC wants music and video (think a search interface) in addition to it specifying it's just looking for music or video.

The reason there is xbmcplugin and xbmcaddon is that scripts are available as well, so we wanted xbmcaddon to be a central point to get all addon stuff (localisation, settings), and the other modules to provide the specifics.

Cheers,
Jonathan
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.


Image
Reply
#5
I maybe being simple minded here but if an addon specifies it can 'play' in multiple contexts it is up to the addon to decide whether it cares what context it is in. In the case I am querying it does matter. When in audio context list only audio etc. Your particular comment addresses a rather different requirement I think.
"
The reason there is xbmcplugin and xbmcaddon is that scripts are available as well,"

From my reading of the new way of doing things under dharma, an addon is an addon is an addon. The only thing that differentiates one from another is it's context. So a script is an addon that appears under the program menu. A skin has no visibility in the main menu but acts under the covers but having reviewed a few skin scripts they still need access to much the same thing in order to strut their stuff. Actually when I think about it, to follow your logic would require a 'skin' specific api.

Now I'm way off topic here. I just need to know how to pick up the current context for an addon. :-)
System info: Asrock ION330HT-BD (Intel Atom 330 4 core i686) connected to Sony KDL-Z5800 TV using hdmi via Onkyo TX-SR507 AV Amp. [Old Config Ubuntu 12.04. (Linux 3.2.0-32-generic-pae ) XBMCBuntu (Eden 11.0 Git:unknown Compiled Mar 24 2012). OpenGL 3.3.0 NVIDIA 280.13] New Config unknown - no working XBMC at moment!
Reply
#6
Sure - the point I was making is that (sometime in the future) XBMC may provide a context where the user expects both music and video to be listed. In that case, we'd want to be able to tell the plugin that the current context is "anything goes" - that may in fact be enough (i.e. return "audio" if in an audio listing, "video" if in a video listing and "all" if anything and everything is fair game). Just trying to make sure any added functionality (after Dharma) will be what we need for the future Wink

No, scripts are addons that appear in the same way as plugins do (e.g. the full apple movie trailers script appears in the video addons section). The difference is that a plugin is effectively a directory listing service. A script, however, can do anything under the sun, from scripts that provide data to the skin, through to scripts that essentially provide their own, complex UI (apple movie trailers script), through to games and so on.

EDIT: And to get back on topic, I believe the only way currently is to grab the id of the current window and check it against a list of known "music" windows.

Cheers,
Jonathan
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.


Image
Reply
#7
EDIT: And to get back on topic, I believe the only way currently is to grab the id of the current window and check it against a list of known "music" windows.

Ok so we just need to know how to do that then. Any takers?

I'm gonna have a think about the rest of what you say JM. Not sure I quite understand it after a couple of vinos this evening. Much appreciate your time in letting me understand what is going on.

Cheers
Ashley

Ps. Amet is also currently going through stuff so I'm very encouraged that the end product will be right.
System info: Asrock ION330HT-BD (Intel Atom 330 4 core i686) connected to Sony KDL-Z5800 TV using hdmi via Onkyo TX-SR507 AV Amp. [Old Config Ubuntu 12.04. (Linux 3.2.0-32-generic-pae ) XBMCBuntu (Eden 11.0 Git:unknown Compiled Mar 24 2012). OpenGL 3.3.0 NVIDIA 280.13] New Config unknown - no working XBMC at moment!
Reply
#8
chippyash Wrote:Ok so we just need to know how to do that then. Any takers?

sure Smile



Code:
import xbmcgui
    music_windows = (10500, 10501, 10502 ) #maybe more? look here  http://wiki.xbmc.org/index.php?title=Window_IDs
    if ( xbmcgui.getCurrentWindowId() in music_windows):
       print " I am running from Music window :) "
Reply
#9
@amet - thanks
Heres my implementation that works a treat in the addon

Code:
import xbmcgui

class context:
    """
    Hack to get current context that addon is running in

    @usage      context = context().getContext()
    @author chippyash
    @thanks amet - xbmc.org
    @link http://wiki.xbmc.org/index.php?title=Window_IDs
    """
    # Set up window Ids for the various contexts
    _ctxt_audio = (10005,10500,10501,10502)
    _ctxt_video = (10006,10024,10025,10028)
    _ctxt_image = (10002)
    _ctxt_executable = (10001,10020)
    # current  window id
    _currId = 0;

    def __init__(self):
        self._currId = xbmcgui.getCurrentWindowId();

    def getContext(self):
        """
        Returns the current system context
        @return string ('audio','video','image','executable','unknown')
        """
        if self._currId in self._ctxt_audio:
            return 'audio'
        elif self._currId in self._ctxt_video:
            return 'video'
        elif self._currId in self._ctxt_image:
            return 'image'
        elif self._currId in self._ctxt_executable:
            return 'executable'
        else:
            return 'unknown'

this now neatly ties up with the <extension><provides> tag in addons.xml schema
System info: Asrock ION330HT-BD (Intel Atom 330 4 core i686) connected to Sony KDL-Z5800 TV using hdmi via Onkyo TX-SR507 AV Amp. [Old Config Ubuntu 12.04. (Linux 3.2.0-32-generic-pae ) XBMCBuntu (Eden 11.0 Git:unknown Compiled Mar 24 2012). OpenGL 3.3.0 NVIDIA 280.13] New Config unknown - no working XBMC at moment!
Reply

Logout Mark Read Team Forum Stats Members Help
Get current plugin context0