2006-06-10, 22:04
i have the following two scripts. player1.py works good, but needs a while loop. player2.py works, but the call to setit() in myplayer class, does not get called until some onaction event happens.
to test play some media then run the script. press stop on the remote and the label should change to stopped. in player1.py it happens immediately. in player2.py it doesn't happen until i press a direction button for instance.
i don't know if this is a bug in xbmc or a feature request. maybe i'm missing something.
download here.
thanks
player1.py
player2.py
to test play some media then run the script. press stop on the remote and the label should change to stopped. in player1.py it happens immediately. in player2.py it doesn't happen until i press a direction button for instance.
i don't know if this is a bug in xbmc or a feature request. maybe i'm missing something.
download here.
thanks
player1.py
Quote:import xbmcgui, xbmc, time
import thread, threading
playing_file = true
class myplayer( xbmc.player ) :
def --init--( self ):
xbmc.player.--init--( self )
def onplaybackstopped(self):
global playing_file
playing_file = false
class mydisplay(xbmcgui.windowdialog):
def --init--(self):
self.b = xbmcgui.controllabel(100,100,100,100,"test")
self.addcontrol(self.b)
thread.start_new_thread(self.loop, ())
def setit(self):
self.b.setlabel("stopped")
def loop(self):
self.b.setlabel("loop")
if xbmc.player().isplaying():
self.p = myplayer()
while playing_file:
time.sleep(.2)
self.setit()
w = mydisplay()
w.domodal()
del w
player2.py
Quote:import xbmcgui, xbmc, time
import thread, threading
class myplayer( xbmc.player ) :
def --init--( self ):
xbmc.player.--init--( self )
def onplaybackstopped(self):
global w
w.setit()
class mydisplay(xbmcgui.windowdialog):
def --init--(self):
self.b = xbmcgui.controllabel(100,100,100,100,"test")
self.addcontrol(self.b)
self.loop()
def setit(self):
self.b.setlabel("stopped")
def loop(self):
self.b.setlabel("loop")
if xbmc.player().isplaying():
self.p = myplayer()
w = mydisplay()
w.domodal()
del w