X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/e0d2999e8b856bb5b6c984447bf0c213a49a1e31..dc2c27a337f958696295d818281805f6c17a4631:/lib/python/Plugins/Extensions/MediaPlayer/plugin.py?ds=inline diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index 3783ddd4..63e2b302 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -33,10 +33,11 @@ class MyPlayList(PlayList): class MediaPixmap(Pixmap): def applySkin(self, desktop): self.default_pixmap = None - for (attrib, value) in self.skinAttributes: - if attrib == "pixmap": - self.default_pixmap = value - break + if self.skinAttributes is not None: + for (attrib, value) in self.skinAttributes: + if attrib == "pixmap": + self.default_pixmap = value + break if self.default_pixmap is None: self.default_pixmap = resolveFilename(SCOPE_SKIN_IMAGE, "no_coverArt.png") return Pixmap.applySkin(self, desktop) @@ -106,7 +107,7 @@ class MediaPlayer(Screen, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSup self["MediaPlayerActions"] = HelpableActionMap(self, "MediaPlayerActions", { - "play": (self.playEntry, _("play entry")), + "play": (self.xplayEntry, _("play entry")), "pause": (self.pauseEntry, _("pause")), "stop": (self.stopEntry, _("stop entry")), "previous": (self.previousEntry, _("play previous playlist entry")), @@ -164,10 +165,6 @@ class MediaPlayer(Screen, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSup self.leftKeyTimer = eTimer() self.leftKeyTimer.timeout.get().append(self.leftTimerFire) - self.infoTimer = eTimer() - self.infoTimer.timeout.get().append(self.infoTimerFire) - self.infoTimer.start(500) - self.currList = "filelist" self.coverArtFileName = "" @@ -208,9 +205,8 @@ class MediaPlayer(Screen, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSup def delMPTimer(self): del self.rightKeyTimer del self.leftKeyTimer - del self.infoTimer - def infoTimerFire(self): + def readTitleInformation(self): currPlay = self.session.nav.getCurrentService() if currPlay is not None: stitle = currPlay.info().getInfoString(iServiceInformation.sTitle) @@ -222,10 +218,8 @@ class MediaPlayer(Screen, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSup album = currPlay.info().getInfoString(iServiceInformation.sAlbum), genre = currPlay.info().getInfoString(iServiceInformation.sGenre), clear = True) - self.updateCoverArtPixmap( currPlay.info().getName() ) else: self.updateMusicInformation() - self.updateCoverArtPixmap( "" ) def updateMusicInformation(self, artist = "", title = "", album = "", year = "", genre = "", clear = False): self.updateSingleMusicInformation("artist", artist, clear) @@ -239,14 +233,11 @@ class MediaPlayer(Screen, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSup if self[name].getText() != info: self[name].setText(info) - def updateCoverArtPixmap(self, currentServiceName): - filename = currentServiceName - # The "getName" usually adds something like "MP3 File:" infront of filename - # Get rid of this...by finding the first "/" - # FIXME: this should be fixed in the servicemp3.cpp handler - filename = filename[filename.find("/"):] - path = os_path.dirname(filename) - pngname = path + "/" + "folder.png" + def updateCoverArtPixmap(self, path): + while not path.endswith("/"): + path = path[:-1] + pngname = path + "folder.png" + if not os_path.exists(pngname): pngname = self["coverArt"].default_pixmap if self.coverArtFileName != pngname: @@ -600,9 +591,27 @@ class MediaPlayer(Screen, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSup if serviceRefList[count] == serviceref: self.changeEntry(count) break - + + def xplayEntry(self): + if self.currList == "playlist": + self.playEntry() + else: + self.stopEntry() + self.playlist.clear() + sel = self.filelist.getSelection() + if sel: + if sel[1]: # can descent + # add directory to playlist + self.copyDirectory(sel[0]) + else: + # add files to playlist + self.copyDirectory(os_path.dirname(sel[0].getPath()) + "/", recursive = False) + if len(self.playlist) > 0: + self.changeEntry(0) + def playEntry(self): if len(self.playlist.getServiceRefList()): + needsInfoUpdate = False currref = self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()] if self.session.nav.getCurrentlyPlayingServiceReference() is None or currref != self.session.nav.getCurrentlyPlayingServiceReference(): self.session.nav.playService(self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()]) @@ -620,6 +629,8 @@ class MediaPlayer(Screen, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSup # FIXME: the information if the service contains video (and we should hide our window) should com from the service instead if ext not in ["mp3", "wav", "ogg"]: self.hide() + else: + needsInfoUpdate = True self.summaries.setText(text,1) # get the next two entries @@ -647,7 +658,17 @@ class MediaPlayer(Screen, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSup ext = text[-3:].lower() if ext not in ["mp3", "wav", "ogg"]: self.hide() + else: + needsInfoUpdate = True + self.unPauseService() + if needsInfoUpdate == True: + self.updateCoverArtPixmap(currref.getPath()) + else: + pngname = self["coverArt"].default_pixmap + self.coverArtFileName = pngname + self["coverArt"].instance.setPixmapFromFile(self.coverArtFileName) + self.readTitleInformation() def updatedSeekState(self): if self.seekstate == self.SEEK_STATE_PAUSE: