Quantcast
Channel: Kodi Community Forum - All Forums
Viewing all articles
Browse latest Browse all 84004

Frodo B2 broke/changed custom players?

$
0
0
Hi folks, I'm creating a custom player to keep track of watched percentage and etc in one of my addons. The code worked fine in Eden and Frodo b1, but broke in b2 so I'm assuming it's a bug and didn't see anything on Trac

I'm using this to start playback and keep the script alive:
Code:
player = playback.Player()
player.play(stream_url, listitem)
while player._playbackLock.isSet():
    xbmc.sleep(250)

Then here's the (simplified) custom player code:
Code:
class Player(xbmc.Player):

    def __init__(self):
        xbmc.Player.__init__(self, xbmc.PLAYER_CORE_AUTO)
        self._playbackLock = threading.Event()
        self._playbackLock.set()
        self._totalTime = 999999
        self._lastPos = 0

    def onPlayBackStarted(self):
        addon.log('Beginning Playback')
        self._totalTime = self.getTotalTime()
        self._tracker = threading.Thread(target=self._trackPosition)
        self._tracker.start()

    def onPlayBackStopped(self):
        addon.log('onPlayBackStopped')
        self._playbackLock.clear()

        playedTime = int(self._lastPos)
        min_watched_percent = 0.7
        if playedTime == 0 and self._totalTime == 999999:
            raise PlaybackFailed('XBMC silently failed to start playback')
        elif (playedTime/self._totalTime) > min_watched_percent:
            self.ChangeWatched(params)

    def onPlayBackEnded(self):
        self.onPlayBackStopped()
        addon.log('onPlayBackEnded')

    def _trackPosition(self):
        while self._playbackLock.isSet():
            try:
                self._lastPos = self.getTime()
            except:
                addon.log_debug('Error while trying to set playback time')
            addon.log_debug('Inside Player. Tracker time = %s' % self._lastPos)
            xbmc.sleep(SLEEP_MILLIS)
        addon.log('Position tracker ending with lastPos = %s' % self._lastPos)

    def ChangeWatched(self, params):
        # logic to record the video has been watched
        pass

class PlaybackFailed(Exception):
    '''Raised to indicate that xbmc silently failed to play the stream'''

None of the stuff in onPlayBackStopped() or onPlayBackEnded() is being called (nothing being logged). The net effect is that _playbackLock is never being cleared, so we drop into an infinite loop popping errors that xbmc is not playing anything and therefore, self.getTime() is throwing the expected error.

Viewing all articles
Browse latest Browse all 84004

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>