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
18 PlayIcon = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_play.png"))
19 PauseIcon = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_pause.png"))
20 StopIcon = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_stop.png"))
21 RewindIcon = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_rewind.png"))
22 ForwardIcon = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/ico_mp_forward.png"))
24 def PlaylistEntryComponent(serviceref, state):
26 text = serviceref.getName()
28 text = path.split(serviceref.getPath().split('/')[-1])[1]
29 x, y, w, h = skin.parameters.get("PlayListName",(25, 1, 470, 22))
30 res.append((eListboxPythonMultiContent.TYPE_TEXT,x, y, w, h, 0, RT_VALIGN_CENTER, text))
32 if state == STATE_PLAY:
34 elif state == STATE_PAUSE:
36 elif state == STATE_STOP:
38 elif state == STATE_REWIND:
40 elif state == STATE_FORWARD:
44 x, y, w, h = skin.parameters.get("PlayListIcon",(5, 3, 16, 16))
45 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, x, y, w, h, png))
49 class PlayList(MenuList):
50 def __init__(self, enableWrapAround = False):
51 MenuList.__init__(self, [], enableWrapAround, eListboxPythonMultiContent)
52 font = skin.fonts.get("PlayList", ("Regular", 18, 23))
53 self.l.setFont(0, gFont(font[0], font[1]))
54 self.l.setItemHeight(font[2])
56 self.oldCurrPlaying = -1
57 self.serviceHandler = eServiceCenter.getInstance()
61 self.l.setList(self.list)
63 self.oldCurrPlaying = -1
65 def getSelection(self):
66 return self.l.getCurrentSelection()[0]
68 def addFile(self, serviceref):
69 self.list.append(PlaylistEntryComponent(serviceref, STATE_NONE))
71 def updateFile(self, index, newserviceref):
72 if index < len(self.list):
73 self.list[index] = PlaylistEntryComponent(newserviceref, 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
83 self.moveToIndex(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)