X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FPlugins%2FExtensions%2FMediaPlayer%2Fplugin.py;h=2c9097fb7dc830e312c7bf88b16607352775e464;hp=0de820c84189591246b7ea1cf2ef7fe2337cb222;hb=be98c731e6b92060760fb0c5e8567dcf747235e5;hpb=fdb15fdd11d88b73900badf092cf2db0e8d3aabf diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index 0de820c..2c9097f 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -30,6 +30,17 @@ class MyPlayList(PlayList): self.currPlaying = -1 self.oldCurrPlaying = -1 +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.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 +84,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 @@ -153,10 +164,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 +204,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 +217,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 +232,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) @@ -592,6 +593,7 @@ class MediaPlayer(Screen, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSup 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 +611,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 +640,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 +721,7 @@ def main(session, **kwargs): def menu(menuid, **kwargs): if menuid == "mainmenu": - return [(_("Media player"), main)] + return [(_("Media player"), main, "media_player", 45)] return [] def filescan_open(list, session, **kwargs): @@ -750,6 +764,6 @@ def filescan(**kwargs): from Plugins.Plugin import PluginDescriptor def Plugins(**kwargs): return [ - PluginDescriptor(name = "MediaPlayer", description = "Play back media files", where = PluginDescriptor.WHERE_SETUP, fnc = menu), + PluginDescriptor(name = "MediaPlayer", description = "Play back media files", where = PluginDescriptor.WHERE_MENU, fnc = menu), PluginDescriptor(name = "MediaPlayer", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan) ]