Sub-Classing xbmc.Player Issue
#1
Now resolved, but will leave for future reference

I am having an issue when I subclass the xbmc.Player class.

In its simplest form I have this in a file called player.py

Code:
import xbmc

class MyPlayer(xbmc.Player):
    def __init__( self, *args, **kwargs ):
        xbmc.Player.__init__( self )

    def PlayStream(self, url):  
        self.play(url)            
        while self.isPlaying: #<== The should be    while self.isPlaying():
            xbmc.sleep(1000)

    def onPlayBackStarted(self):        
        print "PLAYBACK STARTED"
    
    def onPlayBackEnded(self):
        print "PLAYBACK ENDED"

    def onPlayBackStopped(self):        
        print "PLAYBACK STOPPED"

And I use this from another file like this:

Code:
from player import MyPlayer
MyPlayer().PlayStream('http://sohamcomputerservices.co.uk/TVC-House-V1.flv')

This seems to work okay, and I get the expected entries in the XBMC log depending on whether I stop the stream or let it end (it's only 15 seconds long).

However, and this is my problem, when I use the class again I get 2 "PLAYBACK STARTED" entries in the log, and 2 entries indicating how the stream end, use it again and I get 3, etc etc.

The only way to reset this is to atually quit XBMC (which then has to be done via Task Manager as it doesn't shutdown properly either once I've used the MyPlayer class).

I can only assume it isn't being cleaned up correctly, but I can't work out what needs to be done.

Any help would be most appreciated.
Reply
#2
Jeez, my bad, theres a few hours of my life I'll never get back!!

Simple mistake in the end;

Code:
while self.isPlaying:
    xbmc.sleep(1000)

should be a function call, i.e.

Code:
while self.isPlaying():
    xbmc.sleep(1000)



Reply
#3
Man, i was trying to make my own xbmc.Player subclass without any sucess.

Your code has been my salvation, thank you for posting it and the solution to your problem Smile
Reply

Logout Mark Read Team Forum Stats Members Help
Sub-Classing xbmc.Player Issue0