How do i end a script if there is no user input - Printable Version
+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (/forumdisplay.php?fid=32)
+--- Forum: Add-ons (/forumdisplay.php?fid=26)
+--- Thread: How do i end a script if there is no user input (/showthread.php?tid=9457)
- Zeosstud - 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
if emulating: xbmcgui.window.(self)
self.stractioninfo = xbmcgui.controllabel(100, 200, 200, 200, "", "font13", "0xffff00ff")
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)
#define playlist directory here
path = 'q:\\albums\\playlists\\'
list = os.listdir(path)
intcount = len(list)
for a in list :
#playlist = getrandomplaylist(path)
def onaction(self, action):
if action == action_previous_menu:
def oncontrol(self, control):
if control == self.list:
item = self.list.getselecteditem()
#self.message("you selected : " + item.getlabel())
path1 = 'q:\\albums\\playlists\\'
def message(self, message):
dialog = xbmcgui.dialog()
dialog.ok(" my message title", message)
mydisplay = myclass()
- solexalex - 2005-01-27 00:26
you have to create a thread class
Quote:from threading import threadthis is not complete... you'll have to set tome things in the run def to make it working the way you want
thne, you'll have to create the thread class
Quote:th = thread(10) #1 is the time out you want in secs, so you'll have to count in the run def in the thread
then you'll have to make something to reset your counter each time a control event is detected (oncontrol) or action (onaction)
hope these can help
- Zeosstud - 2005-01-27 00:39
thanks for the reply, trying to figure out how to implement your solutions now. if anyone has any code examples they want to share, please let me know. struggleing to perfect this little script.
- solexalex - 2005-01-27 01:35
you can check my wakeup script
it is an alarm to wake you up if you can keep your xbox on
it wakes you up with the sound of your choice, stream, radio, tv, video...
check for the correct thread in this board