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
self["year"] = Label("")
self["genretext"] = Label(_("Genre:"))
self["genre"] = Label("")
- self["coverArt"] = Pixmap()
+ self["coverArt"] = MediaPixmap()
self.seek_target = None
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")),
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 = ""
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)
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)
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)
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()])
# 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
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:
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):
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)
]