2005-01-26, 22:35
i have managed to put together a script that will goto my playlist directory, get a list of all the playlists, then allow me to choose one, it then load, shuffles and plays. here is what i need it to do now. if there is no user input for say 10 seconds i want it to select the default playlist, load, shuffle and play it. could someone suggest how to accomplish this.
below is the script just as i have it running on my xbox currently. i know there is alot of excess code in this, it will be cleaned up soon.
import os, xbmc, xbmcgui
try: emulating = xbmcgui.emulating
except: emulating = false
#get actioncodes from keymap.xml
action_previous_menu = 10
class myclass(xbmcgui.window):
def (self):
if emulating: xbmcgui.window.(self)
self.addcontrol(xbmcgui.controlimage(0,0,720,480, "q:\\scripts\\background.gif"))
self.stractioninfo = xbmcgui.controllabel(100, 200, 200, 200, "", "font13", "0xffff00ff")
self.addcontrol(self.stractioninfo)
self.stractioninfo.setlabel("push back to quit, or select an item from the list and push a")
# make the list
self.list = xbmcgui.controllist(300, 250, 200, 200)
self.addcontrol(self.list)
#define playlist directory here
path = 'q:\\albums\\playlists\\'
list = os.listdir(path)
intcount = len(list)
for a in list :
self.list.additem(a)
self.setfocus(self.list)
#select playlist
#playlist = getrandomplaylist(path)
def onaction(self, action):
if action == action_previous_menu:
self.close()
def oncontrol(self, control):
if control == self.list:
item = self.list.getselecteditem()
#self.message("you selected : " + item.getlabel())
path1 = 'q:\\albums\\playlists\\'
xbmc.playlist(0).load(path1+item.getlabel())
xbmc.playlist(0).shuffle()
xbmc.player().play()
self.close()
def message(self, message):
dialog = xbmcgui.dialog()
dialog.ok(" my message title", message)
mydisplay = myclass()
mydisplay.domodal()
del mydisplay
below is the script just as i have it running on my xbox currently. i know there is alot of excess code in this, it will be cleaned up soon.
import os, xbmc, xbmcgui
try: emulating = xbmcgui.emulating
except: emulating = false
#get actioncodes from keymap.xml
action_previous_menu = 10
class myclass(xbmcgui.window):
def (self):
if emulating: xbmcgui.window.(self)
self.addcontrol(xbmcgui.controlimage(0,0,720,480, "q:\\scripts\\background.gif"))
self.stractioninfo = xbmcgui.controllabel(100, 200, 200, 200, "", "font13", "0xffff00ff")
self.addcontrol(self.stractioninfo)
self.stractioninfo.setlabel("push back to quit, or select an item from the list and push a")
# make the list
self.list = xbmcgui.controllist(300, 250, 200, 200)
self.addcontrol(self.list)
#define playlist directory here
path = 'q:\\albums\\playlists\\'
list = os.listdir(path)
intcount = len(list)
for a in list :
self.list.additem(a)
self.setfocus(self.list)
#select playlist
#playlist = getrandomplaylist(path)
def onaction(self, action):
if action == action_previous_menu:
self.close()
def oncontrol(self, control):
if control == self.list:
item = self.list.getselecteditem()
#self.message("you selected : " + item.getlabel())
path1 = 'q:\\albums\\playlists\\'
xbmc.playlist(0).load(path1+item.getlabel())
xbmc.playlist(0).shuffle()
xbmc.player().play()
self.close()
def message(self, message):
dialog = xbmcgui.dialog()
dialog.ok(" my message title", message)
mydisplay = myclass()
mydisplay.domodal()
del mydisplay