1 from MenuList import MenuList
3 from Tools.Directories import SCOPE_CURRENT_SKIN, resolveFilename
6 from enigma import eListboxPythonMultiContent, RT_VALIGN_CENTER, gFont, eServiceCenter
8 from Tools.LoadPixmap import LoadPixmap
17 PlayIcon = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_play.png"))
18 PauseIcon = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_pause.png"))
19 StopIcon = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_stop.png"))
20 RewindIcon = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_rewind.png"))
21 ForwardIcon = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_forward.png"))
23 def PlaylistEntryComponent(serviceref, state):
25 text = serviceref.getName()
27 text = path.split(serviceref.getPath().split('/')[-1])[1]
28 res.append((eListboxPythonMultiContent.TYPE_TEXT,25, 1, 470, 22, 0, RT_VALIGN_CENTER, text))
30 if state == STATE_PLAY:
32 elif state == STATE_PAUSE:
34 elif state == STATE_STOP:
36 elif state == STATE_REWIND:
38 elif state == STATE_FORWARD:
42 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 3, 16, 16, png))
46 class PlayList(MenuList):
47 def __init__(self, enableWrapAround = False):
48 MenuList.__init__(self, [], enableWrapAround, eListboxPythonMultiContent)
49 self.l.setFont(0, gFont("Regular", 18))
50 self.l.setItemHeight(23)
52 self.oldCurrPlaying = -1
53 self.serviceHandler = eServiceCenter.getInstance()
57 self.l.setList(self.list)
59 self.oldCurrPlaying = -1
61 def getSelection(self):
62 return self.l.getCurrentSelection()[0]
64 def addFile(self, serviceref):
65 self.list.append(PlaylistEntryComponent(serviceref, STATE_NONE))
67 def updateFile(self, index, newserviceref):
68 if index < len(self.list):
69 self.list[index] = PlaylistEntryComponent(newserviceref, STATE_NONE)
71 def deleteFile(self, index):
72 if self.currPlaying >= index:
76 def setCurrentPlaying(self, index):
77 self.oldCurrPlaying = self.currPlaying
78 self.currPlaying = index
79 self.moveToIndex(index)
81 def updateState(self, state):
82 if len(self.list) > self.oldCurrPlaying and self.oldCurrPlaying != -1:
83 self.list[self.oldCurrPlaying] = PlaylistEntryComponent(self.list[self.oldCurrPlaying][0], STATE_NONE)
84 if self.currPlaying != -1 and self.currPlaying < len(self.list):
85 self.list[self.currPlaying] = PlaylistEntryComponent(self.list[self.currPlaying][0], state)
89 self.updateState(STATE_PLAY)
92 self.updateState(STATE_PAUSE)
95 self.updateState(STATE_STOP)
98 self.updateState(STATE_REWIND)
100 def forwardFile(self):
101 self.updateState(STATE_FORWARD)
103 def updateList(self):
104 self.l.setList(self.list)
106 def getCurrentIndex(self):
107 return self.currPlaying
109 def getCurrentEvent(self):
110 l = self.l.getCurrentSelection()
111 return l and self.serviceHandler.info(l[0]).getEvent(l[0])
113 def getCurrent(self):
114 l = self.l.getCurrentSelection()
117 def getServiceRefList(self):
118 return [ x[0] for x in self.list ]
121 return len(self.list)