1 from HTMLComponent import HTMLComponent
2 from GUIComponent import GUIComponent
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, eServiceCenter
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
54 self.serviceHandler = eServiceCenter.getInstance()
58 self.l.setList(self.list)
60 self.oldCurrPlaying = -1
64 def postWidgetCreate(self, instance):
65 instance.setContent(self.l)
67 def getSelection(self):
68 return self.l.getCurrentSelection()[0]
70 def getSelectionIndex(self):
71 return self.l.getCurrentSelectionIndex()
73 def addFile(self, serviceref):
74 self.list.append(PlaylistEntryComponent(serviceref, STATE_NONE))
76 def deleteFile(self, index):
77 if self.currPlaying >= index:
81 def setCurrentPlaying(self, index):
82 self.oldCurrPlaying = self.currPlaying
83 self.currPlaying = index
85 def updateState(self, state):
86 if len(self.list) > self.oldCurrPlaying and self.oldCurrPlaying != -1:
87 self.list[self.oldCurrPlaying] = PlaylistEntryComponent(self.list[self.oldCurrPlaying][0], STATE_NONE)
88 if self.currPlaying != -1 and self.currPlaying < len(self.list):
89 self.list[self.currPlaying] = PlaylistEntryComponent(self.list[self.currPlaying][0], state)
93 self.updateState(STATE_PLAY)
96 self.updateState(STATE_PAUSE)
99 self.updateState(STATE_STOP)
101 def rewindFile(self):
102 self.updateState(STATE_REWIND)
104 def forwardFile(self):
105 self.updateState(STATE_FORWARD)
107 def updateList(self):
108 self.l.setList(self.list)
110 def getCurrentIndex(self):
111 return self.currPlaying
113 def getCurrentEvent(self):
114 l = self.l.getCurrentSelection()
115 return l and self.serviceHandler.info(l[0]).getEvent(l[0])
117 def getCurrent(self):
118 l = self.l.getCurrentSelection()
121 def getServiceRefList(self):
122 return [ x[0] for x in self.list ]
125 return len(self.list)