1 from MenuList import MenuList
3 from Tools.Directories import SCOPE_SKIN_IMAGE, resolveFilename
6 from enigma import eListboxPythonMultiContent, eListbox, RT_VALIGN_CENTER, gFont, eServiceCenter
8 from Tools.LoadPixmap import LoadPixmap
17 PlayIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/ico_mp_play.png"))
18 PauseIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/ico_mp_pause.png"))
19 StopIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/ico_mp_stop.png"))
20 RewindIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/ico_mp_rewind.png"))
21 ForwardIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/ico_mp_forward.png"))
23 def PlaylistEntryComponent(serviceref, state):
25 res.append((eListboxPythonMultiContent.TYPE_TEXT,25, 0, 470, 32, 0, RT_VALIGN_CENTER, path.split(serviceref.getPath().split('/')[-1])[1]))
27 if state == STATE_PLAY:
29 elif state == STATE_PAUSE:
31 elif state == STATE_STOP:
33 elif state == STATE_REWIND:
35 elif state == STATE_FORWARD:
39 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 0, 16, 16, png))
43 class PlayList(MenuList):
44 def __init__(self, enableWrapAround = False):
45 MenuList.__init__(self, [], enableWrapAround, eListboxPythonMultiContent)
46 self.l.setFont(0, gFont("Regular", 18))
47 self.l.setItemHeight(22)
49 self.oldCurrPlaying = -1
50 self.serviceHandler = eServiceCenter.getInstance()
54 self.l.setList(self.list)
56 self.oldCurrPlaying = -1
58 def getSelection(self):
59 return self.l.getCurrentSelection()[0]
61 def addFile(self, serviceref):
62 self.list.append(PlaylistEntryComponent(serviceref, STATE_NONE))
64 def deleteFile(self, index):
65 if self.currPlaying >= index:
69 def setCurrentPlaying(self, index):
70 self.oldCurrPlaying = self.currPlaying
71 self.currPlaying = index
73 def updateState(self, state):
74 if len(self.list) > self.oldCurrPlaying and self.oldCurrPlaying != -1:
75 self.list[self.oldCurrPlaying] = PlaylistEntryComponent(self.list[self.oldCurrPlaying][0], STATE_NONE)
76 if self.currPlaying != -1 and self.currPlaying < len(self.list):
77 self.list[self.currPlaying] = PlaylistEntryComponent(self.list[self.currPlaying][0], state)
81 self.updateState(STATE_PLAY)
84 self.updateState(STATE_PAUSE)
87 self.updateState(STATE_STOP)
90 self.updateState(STATE_REWIND)
92 def forwardFile(self):
93 self.updateState(STATE_FORWARD)
96 self.l.setList(self.list)
98 def getCurrentIndex(self):
99 return self.currPlaying
101 def getCurrentEvent(self):
102 l = self.l.getCurrentSelection()
103 return l and self.serviceHandler.info(l[0]).getEvent(l[0])
105 def getCurrent(self):
106 l = self.l.getCurrentSelection()
109 def getServiceRefList(self):
110 return [ x[0] for x in self.list ]
113 return len(self.list)