Playlist script with choices
#1
thought this might be pretty easy for someone with alittle python skill.

was hoping someone could write a script that would look out on the albums\playlists directory and get a list of .m3u files then offer me the chance to pick which one i want to listen to. after its selected, the list would be shuffled and played. it would be super if a default playlist would automatically run in case a key was not pressed, say within 5 seconds.

i have gotten scripts to run for me when xbmc starts up using an autoexec.py file that looks like this:

import xbmc
xbmc.executescript('q:\\scripts\\autoplay.py')

then i have a autoplay.py that looks like this

file = 'q:\\albums\\playlists\\playlist.m3u'
pls = xbmc.playlist(0)
pls.load(file)
pls.shuffle()
xbmc.player().play(pls)

this is working perfectly on the 1-15-05 cvs build. i guess i am just trying to get alittle fancy now. the xbox that this will run on is in my car so making changes to my existing playlist is just alittle inconvient. if a window would pop up with my list of playlists and let me choose one if i wanted to or just play whichever one is highlighted if i dont make a selection it would be awesome.
Reply
#2
bump. i have everything working except for the part where if there is no input the default choice is made automatically. here is what it looks like. someone, please, help me finish this baby off.

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, "c:\\scripts\\background.jpg"))

# make the list
self.list = xbmcgui.controllist(290, 300, 150, 150)
self.addcontrol(self.list)

#define playlist directory here
path = 'c:\\albums\\playlists\\'
list = os.listdir(path)
intcount = len(list)
for a in list :
self.list.additem(a)
self.setfocus(self.list)

def onaction(self, action):
if action == action_previous_menu:
self.close()

def oncontrol(self, control):
if control == self.list:
item = self.list.getselecteditem()
path1 = 'c:\\albums\\playlists\\'
xbmc.playlist(0).load (path1+item.getlabel())
xbmc.playlist(0).shuffle()
xbmc.player().play()
self.close()

mydisplay = myclass()
mydisplay.domodal()
del mydisplay
Reply

Logout Mark Read Team Forum Stats Members Help
Playlist script with choices0