1 from MenuList import MenuList
3 from Tools.Directories import SCOPE_SKIN_IMAGE, resolveFilename
6 from enigma import eListboxPythonMultiContent, 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 text = serviceref.getName()
27 text = path.split(serviceref.getPath().split('/')[-1])[1]
28 res.append((eListboxPythonMultiContent.TYPE_TEXT,25, 0, 470, 32, 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, 0, 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(22)
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
80 def updateState(self, state):
81 if len(self.list) > self.oldCurrPlaying and self.oldCurrPlaying != -1:
82 self.list[self.oldCurrPlaying] = PlaylistEntryComponent(self.list[self.oldCurrPlaying][0], STATE_NONE)
83 if self.currPlaying != -1 and self.currPlaying < len(self.list):
84 self.list[self.currPlaying] = PlaylistEntryComponent(self.list[self.currPlaying][0], state)
88 self.updateState(STATE_PLAY)
91 self.updateState(STATE_PAUSE)
94 self.updateState(STATE_STOP)
97 self.updateState(STATE_REWIND)
99 def forwardFile(self):
100 self.updateState(STATE_FORWARD)
102 def updateList(self):
103 self.l.setList(self.list)
105 def getCurrentIndex(self):
106 return self.currPlaying
108 def getCurrentEvent(self):
109 l = self.l.getCurrentSelection()
110 return l and self.serviceHandler.info(l[0]).getEvent(l[0])
112 def getCurrent(self):
113 l = self.l.getCurrentSelection()
116 def getServiceRefList(self):
117 return [ x[0] for x in self.list ]
120 return len(self.list)