1 from HTMLComponent import *
2 from GUIComponent import *
4 from MenuList import MenuList
6 from Tools.Directories import SCOPE_SKIN_IMAGE, resolveFilename
9 from enigma import eListboxPythonMultiContent, eListbox, RT_VALIGN_CENTER, loadPNG, gFont
18 PlayIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_play.png"))
19 PauseIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_pause.png"))
20 StopIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_stop.png"))
21 RewindIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_rewind.png"))
22 ForwardIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_forward.png"))
24 def PlaylistEntryComponent(serviceref, state):
26 res.append((eListboxPythonMultiContent.TYPE_TEXT,25, 0, 470, 32, 0, RT_VALIGN_CENTER, path.split(serviceref.getPath().split('/')[-1])[1]))
28 if state == STATE_PLAY:
30 elif state == STATE_PAUSE:
32 elif state == STATE_STOP:
34 elif state == STATE_REWIND:
36 elif state == STATE_FORWARD:
40 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 0, 16, 16, png))
44 class PlayList(MenuList, HTMLComponent, GUIComponent):
46 GUIComponent.__init__(self)
47 self.l = eListboxPythonMultiContent()
49 self.l.setList(self.list)
50 self.l.setFont(0, gFont("Regular", 18))
51 self.l.setItemHeight(22)
53 self.oldCurrPlaying = -1
57 self.l.setList(self.list)
59 self.oldCurrPlaying = -1
63 def postWidgetCreate(self, instance):
64 instance.setContent(self.l)
66 def getSelection(self):
67 return self.l.getCurrentSelection()[0]
69 def getSelectionIndex(self):
70 return self.l.getCurrentSelectionIndex()
72 def addFile(self, serviceref):
73 self.list.append(PlaylistEntryComponent(serviceref, STATE_NONE))
75 def deleteFile(self, index):
76 if self.currPlaying >= index:
80 def setCurrentPlaying(self, index):
81 self.oldCurrPlaying = self.currPlaying
82 self.currPlaying = index
84 def updateState(self, state):
85 if len(self.list) > self.oldCurrPlaying and self.oldCurrPlaying != -1:
86 self.list[self.oldCurrPlaying] = PlaylistEntryComponent(self.list[self.oldCurrPlaying][0], STATE_NONE)
87 if self.currPlaying != -1 and self.currPlaying < len(self.list):
88 self.list[self.currPlaying] = PlaylistEntryComponent(self.list[self.currPlaying][0], state)
92 self.updateState(STATE_PLAY)
95 self.updateState(STATE_PAUSE)
98 self.updateState(STATE_STOP)
100 def rewindFile(self):
101 self.updateState(STATE_REWIND)
103 def forwardFile(self):
104 self.updateState(STATE_FORWARD)
106 def updateList(self):
107 self.l.setList(self.list)
109 def getCurrentIndex(self):
110 return self.currPlaying
112 def getServiceRefList(self):
113 return [ x[0] for x in self.list ]
116 return len(self.list)