X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/09f2e2935df89c375633517884682151de3d9741..dc2c27a337f958696295d818281805f6c17a4631:/lib/python/Plugins/Extensions/MediaPlayer/plugin.py diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index 7efd33e2..63e2b302 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -30,6 +30,18 @@ class MyPlayList(PlayList): self.currPlaying = -1 self.oldCurrPlaying = -1 +class MediaPixmap(Pixmap): + def applySkin(self, desktop): + self.default_pixmap = None + 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) + class MediaPlayer(Screen, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSupport, InfoBarNotifications, HelpableScreen): ALLOW_SUSPEND = True ENABLE_RESUME_SUPPORT = True @@ -73,7 +85,7 @@ class MediaPlayer(Screen, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSup self["year"] = Label("") self["genretext"] = Label(_("Genre:")) self["genre"] = Label("") - self["coverArt"] = Pixmap() + self["coverArt"] = MediaPixmap() self.seek_target = None @@ -95,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")), @@ -153,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 = "" @@ -197,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) @@ -211,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) @@ -228,16 +233,13 @@ 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 = resolveFilename(SCOPE_SKIN_IMAGE, "no_coverArt.png") + pngname = self["coverArt"].default_pixmap if self.coverArtFileName != pngname: self.coverArtFileName = pngname self["coverArt"].instance.setPixmapFromFile(self.coverArtFileName) @@ -589,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()]) @@ -609,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 @@ -636,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: @@ -707,7 +739,7 @@ def main(session, **kwargs): def menu(menuid, **kwargs): if menuid == "mainmenu": - return [(_("Media player"), main, "media_player")] + return [(_("Media player"), main, "media_player", 45)] return [] def filescan_open(list, session, **kwargs):