This file looks large and may slow your browser down if we attempt
to syntax highlight it, so we are showing it without any
pretty colors.
Highlight
it anyway.
| 1 |
import xbmc |
| 2 |
from threading import Timer |
| 3 |
|
| 4 |
class PandaPlayer( xbmc.Player ): |
| 5 |
|
| 6 |
def __init__( self, core=None, panda=None ): |
| 7 |
xbmc.Player.__init__( self, xbmc.PLAYER_CORE_MPLAYER ) |
| 8 |
self.panda = panda |
| 9 |
self.timer = None |
| 10 |
|
| 11 |
def playSong( self, item ): |
| 12 |
self.play( item[0], item[1] ) |
| 13 |
|
| 14 |
def play( self, url, item ): |
| 15 |
xbmc.Player(xbmc.PLAYER_CORE_MPLAYER).play( url, item ) |
| 16 |
|
| 17 |
def onPlayBackStarted( self ): |
| 18 |
print "PANDORA: onPlayBackStarted: %s" %self.getPlayingFile() |
| 19 |
if self.panda.playing: |
| 20 |
if not "pandora.com" in self.getPlayingFile(): |
| 21 |
self.panda.playing = False |
| 22 |
self.panda.quit() |
| 23 |
|
| 24 |
def onPlayBackEnded( self ): |
| 25 |
print "PANDORA: onPlayBackEnded" |
| 26 |
print "PANDORA: playing = %s" %self.panda.playing |
| 27 |
if self.timer and self.timer.isAlive(): |
| 28 |
self.timer.cancel() |
| 29 |
if self.panda.skip: |
| 30 |
self.panda.skip = False |
| 31 |
if self.panda.playing: |
| 32 |
self.timer = Timer( 0.5, self.panda.playNextSong ) |
| 33 |
self.timer.start() |
| 34 |
|
| 35 |
def onPlayBackStopped( self ): |
| 36 |
print "PANDORA: onPlayBackStopped" |
| 37 |
print "PANDORA: playing = %s" %self.panda.playing |
| 38 |
if self.timer and self.timer.isAlive(): |
| 39 |
self.timer.cancel() |
| 40 |
if self.panda.playing: |
| 41 |
if self.panda.skip: |
| 42 |
self.panda.skip = False |
| 43 |
self.timer = Timer( 0.5, self.panda.playNextSong ) |
| 44 |
self.timer.start() |