-
Notifications
You must be signed in to change notification settings - Fork 0
/
pandaplayer.py
52 lines (45 loc) · 1.51 KB
/
pandaplayer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import xbmc
from threading import Timer
class PandaPlayer( xbmc.Player ):
def __init__( self, core=None, panda=None ):
xbmc.Player.__init__( self, xbmc.PLAYER_CORE_MPLAYER )
self.panda = panda
self.timer = None
def playSong( self, item ):
print "PANDORA: Item 0 %s" % item[0]
print "PANDORA: Item 1 %s" % item[1]
self.play( item[0], item[1] )
def play( self, url, item ):
xbmc.Player(xbmc.PLAYER_CORE_MPLAYER).play( url, item )
def onPlayBackStarted( self ):
print "PANDORA: onPlayBackStarted: %s" %self.getPlayingFile()
if self.panda.playing:
if not "pandora.com" in self.getPlayingFile():
if not "p-cdn.com" in self.getPlayingFile():
self.panda.playing = False
self.panda.quit()
else:
#Show Visualization (disappears after each song...)
xbmc.executebuiltin( "ActivateWindow( 12006 )" )
def onPlayBackEnded( self ):
print "PANDORA: onPlayBackEnded"
self.stop()
print "PANDORA: playing = %s" %self.panda.playing
if self.timer and self.timer.isAlive():
self.timer.cancel()
if self.panda.skip:
self.panda.skip = False
if self.panda.playing:
self.timer = Timer( 0.5, self.panda.playNextSong )
self.timer.start()
def onPlayBackStopped( self ):
print "PANDORA: onPlayBackStopped"
self.stop()
print "PANDORA: playing = %s" %self.panda.playing
if self.timer and self.timer.isAlive():
self.timer.cancel()
if self.panda.playing:
if self.panda.skip:
self.panda.skip = False
self.timer = Timer( 0.5, self.panda.playNextSong )
self.timer.start()