2012-07-02, 16:53
I want to get XBMC's current selection from a Python script so I can do various interesting things with the media file it points to. I've tried the following:
But this prints to the log:
and the getLabel() call then generates an exception because obviously the type None has no getLabel() function. Why does the ControlList.getSelectedItem call return None? An item was selected when I ran the script.
Is there a different/better way for a script to get the currently selected item from the Video or Music navigation lists?
Code:
import xbmcgui
win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
curctl = win.getFocus()
print "Type of curctl is " + type(curctl).__name__
cursel = curctl.getSelectedItem()
print "Type of cursel is " + type(cursel).__name__
label = cursel.getLabel()
But this prints to the log:
Code:
NOTICE: Type of curctl is ControlList
NOTICE: Type of cursel is NoneType
and the getLabel() call then generates an exception because obviously the type None has no getLabel() function. Why does the ControlList.getSelectedItem call return None? An item was selected when I ran the script.
Is there a different/better way for a script to get the currently selected item from the Video or Music navigation lists?