onPlayBackEnded problems
#1
I am trying to write a script that will play music from a custom server on my PC. My server maintains the active playlist, and sends the next song in response to an HTTP request. I am trying to use onPlayBackEnded() to cue up the next song, but it is not getting called.

Any help would be greatly appreciated. Here's the script:

Code:
import xbmc, urllib, time

class MyPlayer(xbmc.Player):
    def __init__ ( self ):
            xbmc.Player.__init__( self )

    def startPlaying(self):
        self.source = 'http://192.168.1.207:80/song.mp3'
        self.dest = 'Q:\\UserData\\Music\song.mp3'

        self.loc = urllib.URLopener()

        self.loc.retrieve(self.source, self.dest)

        self.play(self.dest)

    def onPlayBackEnded(self):
        xbmc.log("My Function Called")
        self.startPlaying()

p = MyPlayer()
p.startPlaying()

while(1):
    time.sleep(500)
Reply
#2
Is there a gui? If so press a key on the controller. this should fire the event.

What I've found is if you spin off a timer thread, then the events fire imediately.

I used:

Code:
# dummy() and self.Timer are currently used for the Player() subclass so when an onPlayback* event occurs,
#it calls myPlayerChanged() immediately.
def dummy( self ):
    self.Timer = threading.Timer( 60*60*60, self.dummy,() )
    self.Timer.start()

You can adjust if you're not using a gui class.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#3
Thanks for the reply.

That works, kinda...

The problem is that it kicks back to the script directory view when a song ends, which is annoying if you have the song info / visualization view up.

I also haven't figured out how to handle skipping to the next song.

Maybe I should just manage a playlist instead, and insert the next song every time playback starts.
Reply
#4
Is that your whole script? You could use activatewindow() to activate the viz. It would still switch though.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply

Logout Mark Read Team Forum Stats Members Help
onPlayBackEnded problems0