2005-01-14, 17:28
i've just been getting into python scripting for xbmc, and have written a good script to automatically load a playlist, shuffle it, and then start playing.
i load this script at start-up, so xbox starts playing music from a playlist at start-up.
i'm not sure where to publish these scripts, so if anyone can tell me, that would be great, but for now, i'll just put the code below:
import xbmc, xbmcgui
# playliststart
# start playing a playlist
# by scomal
# version 1.0
#set up the following parameters:
#################################
#playlist to load:
file = '[your filename here]'
#suffle playlist on load?:
shuffle = true
#display loading notice?:
dispload = true
#################################
pls = xbmc.playlist(0)
class myclass(xbmcgui.window):
def (self, id):
# begin setting up the gui
self.info = xbmcgui.controllabel(50,50,200,20,"loading playlist...","font13","0xffffffff")
self.addcontrol(self.info)
def clear(self):
self.info.setlabel("")
self.removecontrol(self.info)
#program starts here:
if dispload:
winid = xbmcgui.getcurrentwindowid()
win = myclass(winid)
win.show()
try:
pls.load(file)
if shuffle:
pls.shuffle()
xbmc.player().play()
except:
pass
if dispload:
currwin = xbmcgui.getcurrentwindowid()
while currwin <> winid:
sleep(1)
currwin = xbmcgui.getcurrentwindowid()
win.clear()
win.close()
i load this script at start-up, so xbox starts playing music from a playlist at start-up.
i'm not sure where to publish these scripts, so if anyone can tell me, that would be great, but for now, i'll just put the code below:
import xbmc, xbmcgui
# playliststart
# start playing a playlist
# by scomal
# version 1.0
#set up the following parameters:
#################################
#playlist to load:
file = '[your filename here]'
#suffle playlist on load?:
shuffle = true
#display loading notice?:
dispload = true
#################################
pls = xbmc.playlist(0)
class myclass(xbmcgui.window):
def (self, id):
# begin setting up the gui
self.info = xbmcgui.controllabel(50,50,200,20,"loading playlist...","font13","0xffffffff")
self.addcontrol(self.info)
def clear(self):
self.info.setlabel("")
self.removecontrol(self.info)
#program starts here:
if dispload:
winid = xbmcgui.getcurrentwindowid()
win = myclass(winid)
win.show()
try:
pls.load(file)
if shuffle:
pls.shuffle()
xbmc.player().play()
except:
pass
if dispload:
currwin = xbmcgui.getcurrentwindowid()
while currwin <> winid:
sleep(1)
currwin = xbmcgui.getcurrentwindowid()
win.clear()
win.close()