X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/08fca93e7f2a37a452399d08c5c84b969b7e52af..0ccffb6b503d7a285f3d5f7d7e44999d6eb60784:/lib/python/Components/MediaPlayer.py diff --git a/lib/python/Components/MediaPlayer.py b/lib/python/Components/MediaPlayer.py index b6b2e432..44937fa3 100644 --- a/lib/python/Components/MediaPlayer.py +++ b/lib/python/Components/MediaPlayer.py @@ -3,19 +3,10 @@ from GUIComponent import * from MenuList import MenuList -from Tools.Directories import * -import os +from Tools.Directories import SCOPE_SKIN_IMAGE, resolveFilename +from os import path -from enigma import * - -RT_HALIGN_LEFT = 0 -RT_HALIGN_RIGHT = 1 -RT_HALIGN_CENTER = 2 -RT_HALIGN_BLOCK = 4 - -RT_VALIGN_TOP = 0 -RT_VALIGN_CENTER = 8 -RT_VALIGN_BOTTOM = 16 +from enigma import eListboxPythonMultiContent, eListbox, RT_VALIGN_CENTER, loadPNG, gFont STATE_PLAY = 0 STATE_PAUSE = 1 @@ -24,15 +15,15 @@ STATE_REWIND = 3 STATE_FORWARD = 4 STATE_NONE = 5 -PlayIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "play-small-fs8.png")) -PauseIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "pause-small-fs8.png")) -StopIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "stop-small-fs8.png")) -RewindIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "rewind-small-fs8.png")) -ForwardIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "forward-small-fs8.png")) +PlayIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_play.png")) +PauseIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_pause.png")) +StopIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_stop.png")) +RewindIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_rewind.png")) +ForwardIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_mp_forward.png")) def PlaylistEntryComponent(serviceref, state): res = [ serviceref ] - res.append((eListboxPythonMultiContent.TYPE_TEXT, 35, 0, 250, 32, 0, RT_VALIGN_CENTER, os.path.split(serviceref.getPath().split('/')[-1])[1])) + res.append((eListboxPythonMultiContent.TYPE_TEXT,25, 0, 470, 32, 0, RT_VALIGN_CENTER, path.split(serviceref.getPath().split('/')[-1])[1])) png = None if state == STATE_PLAY: png = PlayIcon @@ -46,29 +37,32 @@ def PlaylistEntryComponent(serviceref, state): png = ForwardIcon if png is not None: - res.append((eListboxPythonMultiContent.TYPE_PIXMAP, 0, 0, 33, 32, png)) + res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 0, 16, 16, png)) return res -class PlayList(HTMLComponent, GUIComponent, MenuList): +class PlayList(MenuList, HTMLComponent, GUIComponent): def __init__(self): GUIComponent.__init__(self) self.l = eListboxPythonMultiContent() self.list = [] self.l.setList(self.list) self.l.setFont(0, gFont("Regular", 18)) - self.currPlaying = 0 + self.currPlaying = -1 self.oldCurrPlaying = -1 def clear(self): - self.list = [] + del self.list[:] self.l.setList(self.list) - - def GUIcreate(self, parent): - self.instance = eListbox(parent) - self.instance.setContent(self.l) - self.instance.setItemHeight(32) - + self.currPlaying = -1 + self.oldCurrPlaying = -1 + + GUI_WIDGET = eListbox + + def postWidgetCreate(self, instance): + instance.setContent(self.l) + instance.setItemHeight(22) + def getSelection(self): return self.l.getCurrentSelection()[0] @@ -79,10 +73,10 @@ class PlayList(HTMLComponent, GUIComponent, MenuList): self.list.append(PlaylistEntryComponent(serviceref, STATE_NONE)) def deleteFile(self, index): - if self.currPlaying > index: + if self.currPlaying >= index: self.currPlaying -= 1 - self.list = self.list[:index] + self.list[index + 1:] - + del self.list[index] + def setCurrentPlaying(self, index): self.oldCurrPlaying = self.currPlaying self.currPlaying = index @@ -90,7 +84,8 @@ class PlayList(HTMLComponent, GUIComponent, MenuList): def updateState(self, state): if len(self.list) > self.oldCurrPlaying and self.oldCurrPlaying != -1: self.list[self.oldCurrPlaying] = PlaylistEntryComponent(self.list[self.oldCurrPlaying][0], STATE_NONE) - self.list[self.currPlaying] = PlaylistEntryComponent(self.list[self.currPlaying][0], state) + if self.currPlaying != -1 and self.currPlaying < len(self.list): + self.list[self.currPlaying] = PlaylistEntryComponent(self.list[self.currPlaying][0], state) self.updateList() def playFile(self): @@ -121,4 +116,4 @@ class PlayList(HTMLComponent, GUIComponent, MenuList): return list def __len__(self): - return len(self.list) \ No newline at end of file + return len(self.list)