#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    3
    Rep Power
    0

    I am Stuck, help requested.


    I have written a script that goes out to a directory of playlists, then makes a list of them you can choose from, after a choice is made it will load the playlist, shuffle the songs and then play it. What I NEED it to do is run exactly like it is but if no selection is made within 10 seconds, I want it to load shuffle and play the default playlist. I simply cant figure out how to do this. Any help would be appreciated.

    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 __init__(self):
    if Emulating: xbmcgui.Window.__init__(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
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Please read the sticky thread at the top of this forum regarding how to as a Question. Since Python uses indentation to define code blocks this is particularly important when posting code .

    http://forums.devshed.com/t131489/s.html

    Anyway, normally if you wanted to wait 10 seconds before performing an action you would use the time modules sleep() function. See the link below for more information on this:

    http://www.python.org/doc/2.4/lib/module-time.html

    Take care,

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    3
    Rep Power
    0
    Mark,
    I dont want to wait 10 seconds before I do something even I can figure out the sleep(10). What I want is for my script to run, if you make a choice, great, it does its thing. If you dont make a choice, it choses the default selection and does its thing.

    I thank you for taking the time to reply, is there anyway I can send you a copy of this code so you could look at it. I have posted similar requests EVERYWHERE I can think of, either this cant be done (which I HIGHLY doubt) or I am just an unlucky sap who isnt gonna get any help.

    Rodney




    Originally Posted by netytan
    Please read the sticky thread at the top of this forum regarding how to as a Question. Since Python uses indentation to define code blocks this is particularly important when posting code .

    http://forums.devshed.com/t131489/s.html

    Anyway, normally if you wanted to wait 10 seconds before performing an action you would use the time modules sleep() function. See the link below for more information on this:

    http://www.python.org/doc/2.4/lib/module-time.html

    Take care,

    Mark.
    Attached Files
  6. #4
  7. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Less haste more speed.

    I scanned what docs I could find on Python and xbmc(gui) and none of them show you how to handle events which would be the best way (with a timer event).

    I looked at your code (not easy at all without indentations!), the xbmcgui doc
    http://members.cox.net/alexpoet/downloads/Docs/xbmcgui.html
    and I find it looks similar to wxWindows.
    This (untested) code might work:
    Code:
    mydisplay = MyClass()
    mydisplay.show()
    for x in range(10):
        sleep(1)
        try:
             mydisplay.getHeight() #to see if the dialog is still there
        except:
             break
    else:
        mydisplay.close()
        #any other default action code
    No guarantees (I don't have an Xbox)

    My guess is that some combination of show/close is what you want. Failing that write to the authors of the GUI and ask them how to set up a timer

    grimey.
    Last edited by Grim Archon; January 28th, 2005 at 04:05 AM.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    3
    Rep Power
    0

    Thank You for the Reply


    I have asked for help in no less than 6 different places, your the first person to send back any code at all, Thank You. If you want to take a look at the script in its proper format email me at butlerrodney@hotmail.com and I will send it over to you. I am going to try and figure out who did the xbmcgui for python and get ahold of them next, thanks to your input.

    Rodney

IMN logo majestic logo threadwatch logo seochat tools logo