1 from HTMLComponent import *
2 from GUIComponent import *
4 from MenuList import MenuList
6 from Tools.Directories import *
27 PlayIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_play.png"))
28 PauseIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_pause.png"))
29 StopIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_stop.png"))
30 RewindIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_rewind.png"))
31 ForwardIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_forward.png"))
33 def PlaylistEntryComponent(serviceref, state):
35 res.append((eListboxPythonMultiContent.TYPE_TEXT,25, 0, 470, 32, 0, RT_VALIGN_CENTER, os.path.split(serviceref.getPath().split('/')[-1])[1]))
37 if state == STATE_PLAY:
39 elif state == STATE_PAUSE:
41 elif state == STATE_STOP:
43 elif state == STATE_REWIND:
45 elif state == STATE_FORWARD:
49 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 0, 16, 16, png))
53 class PlayList(MenuList, HTMLComponent, GUIComponent):
55 GUIComponent.__init__(self)
56 self.l = eListboxPythonMultiContent()
58 self.l.setList(self.list)
59 self.l.setFont(0, gFont("Regular", 18))
61 self.oldCurrPlaying = -1
65 self.l.setList(self.list)
67 self.oldCurrPlaying = -1
71 def postWidgetCreate(self, instance):
72 instance.setContent(self.l)
73 instance.setItemHeight(22)
75 def getSelection(self):
76 return self.l.getCurrentSelection()[0]
78 def getSelectionIndex(self):
79 return self.l.getCurrentSelectionIndex()
81 def addFile(self, serviceref):
82 self.list.append(PlaylistEntryComponent(serviceref, STATE_NONE))
84 def deleteFile(self, index):
85 if self.currPlaying >= index:
89 def setCurrentPlaying(self, index):
90 self.oldCurrPlaying = self.currPlaying
91 self.currPlaying = index
93 def updateState(self, state):
94 if len(self.list) > self.oldCurrPlaying and self.oldCurrPlaying != -1:
95 self.list[self.oldCurrPlaying] = PlaylistEntryComponent(self.list[self.oldCurrPlaying][0], STATE_NONE)
96 if self.currPlaying != -1 and self.currPlaying < len(self.list):
97 self.list[self.currPlaying] = PlaylistEntryComponent(self.list[self.currPlaying][0], state)
101 self.updateState(STATE_PLAY)
104 self.updateState(STATE_PAUSE)
107 self.updateState(STATE_STOP)
109 def rewindFile(self):
110 self.updateState(STATE_REWIND)
112 def forwardFile(self):
113 self.updateState(STATE_FORWARD)
115 def updateList(self):
116 self.l.setList(self.list)
118 def getCurrentIndex(self):
119 return self.currPlaying
121 def getServiceRefList(self):
128 return len(self.list)