Trigger when playback moves to next video in playlist
#1
Hello,
I'm trying to figure out how to trigger a script to run every time XBMC moves from one video to the next when playing a playlist.

I'd also like to pass the script the title of the video that's about to play.

Any help or pointers in the right direction (ie which event should I be looking for) would be greatly appreciated.

Thanks in advance for any and all help!

- Matt
Reply
#2
Well, just in case anyone else hits on this topic I was able to answer my own question using the service.xbmc.callbacks addon here:

http://forum.xbmc.org/showthread.php?tid=151011
Reply
#3
The way I did it was to extend the 'onplay' method built in to the playlist class.
Reply
#4
I JUST finished trying something like that.

My code is below. I am using onPlayBackStopped but there is also onQueueNextItem which might better suit your needs.

My addon plays a playlist, so I only wanted the loop to continue while THAT playlist was playing. I wanted the script to end when the playlist ends or when the player is stopped. I hit a problem in that onPlayBackEnded would be triggered in the change between videos, so I have a sleep to cover the changeover time.

There may be a more efficent or robust method for doing this, but it is working for me right now.

Code:
play_monitor = MyPlayer()

while not xbmc.abortRequested and play_monitor.player_active:
            xbmc.sleep(100)

class MyPlayer( xbmc.Player ):
    def __init__( self, *args, **kwargs ):
        xbmc.Player.__init__( self )
        self.player_active = True
        self.send_notification()

    def onPlayBackEnded(self):
        xbmc.sleep(100)
        self.now_name = xbmc.getInfoLabel('VideoPlayer.TVShowTitle')
        if self.now_name == '':
            self.player_active = False

    def onPlayBackStopped(self):
        xbmc.executebuiltin('ActivateWindow(10028)')
        self.player_active = False

    def onPlayBackStarted(self):
        self.send_notification()

    def send_notification(self):
        xbmc.sleep(100)
        self.now_name = xbmc.getInfoLabel('VideoPlayer.TVShowTitle')
        if self.now_name == '':
            self.player_active = False
        else:    
            if settings['notify'] == 'true':
                pass #my code went here
Reply

Logout Mark Read Team Forum Stats Members Help
Trigger when playback moves to next video in playlist0