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, gFont, eServiceCenter
11 from Tools.LoadPixmap import LoadPixmap
21 PlayIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_play.png"))
22 PauseIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_pause.png"))
23 StopIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_stop.png"))
24 RewindIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_rewind.png"))
25 ForwardIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_forward.png"))
27 def PlaylistEntryComponent(serviceref, state):
29 res.append((eListboxPythonMultiContent.TYPE_TEXT,25, 0, 470, 32, 0, RT_VALIGN_CENTER, path.split(serviceref.getPath().split('/')[-1])[1]))
31 if state == STATE_PLAY:
33 elif state == STATE_PAUSE:
35 elif state == STATE_STOP:
37 elif state == STATE_REWIND:
39 elif state == STATE_FORWARD:
43 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 0, 16, 16, png))
47 class PlayList(MenuList, HTMLComponent, GUIComponent):
49 GUIComponent.__init__(self)
50 self.l = eListboxPythonMultiContent()
52 self.l.setList(self.list)
53 self.l.setFont(0, gFont("Regular", 18))
54 self.l.setItemHeight(22)
56 self.oldCurrPlaying = -1
57 self.serviceHandler = eServiceCenter.getInstance()
61 self.l.setList(self.list)
63 self.oldCurrPlaying = -1
67 def postWidgetCreate(self, instance):
68 instance.setContent(self.l)
70 def getSelection(self):
71 return self.l.getCurrentSelection()[0]
73 def getSelectionIndex(self):
74 return self.l.getCurrentSelectionIndex()
76 def addFile(self, serviceref):
77 self.list.append(PlaylistEntryComponent(serviceref, STATE_NONE))
79 def deleteFile(self, index):
80 if self.currPlaying >= index:
84 def setCurrentPlaying(self, index):
85 self.oldCurrPlaying = self.currPlaying
86 self.currPlaying = index
88 def updateState(self, state):
89 if len(self.list) > self.oldCurrPlaying and self.oldCurrPlaying != -1:
90 self.list[self.oldCurrPlaying] = PlaylistEntryComponent(self.list[self.oldCurrPlaying][0], STATE_NONE)
91 if self.currPlaying != -1 and self.currPlaying < len(self.list):
92 self.list[self.currPlaying] = PlaylistEntryComponent(self.list[self.currPlaying][0], state)
96 self.updateState(STATE_PLAY)
99 self.updateState(STATE_PAUSE)
102 self.updateState(STATE_STOP)
104 def rewindFile(self):
105 self.updateState(STATE_REWIND)
107 def forwardFile(self):
108 self.updateState(STATE_FORWARD)
110 def updateList(self):
111 self.l.setList(self.list)
113 def getCurrentIndex(self):
114 return self.currPlaying
116 def getCurrentEvent(self):
117 l = self.l.getCurrentSelection()
118 return l and self.serviceHandler.info(l[0]).getEvent(l[0])
120 def getCurrent(self):
121 l = self.l.getCurrentSelection()
124 def getServiceRefList(self):
125 return [ x[0] for x in self.list ]
128 return len(self.list)