From ce8e939502fb096515b84a16087bdcb2c498bfdc Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 2 Nov 2008 11:14:33 +0100 Subject: add .mp2 as supported filetype --- lib/python/Plugins/Extensions/MediaPlayer/plugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to '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 a144f2cd..841ad614 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -66,7 +66,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.addPlaylistParser(PlaylistIOInternal, "e2pls") # 'None' is magic to start at the list of mountpoints - self.filelist = FileList(None, matchingPattern = "(?i)^.*\.(mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|mkv|mp4|dat|flac)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls") + self.filelist = FileList(None, matchingPattern = "(?i)^.*\.(mp2|mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|mkv|mp4|dat|flac)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls") self["filelist"] = self.filelist self.playlist = MyPlayList() @@ -727,7 +727,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB ext = text[-4:].lower() # 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", "flac"] and not self.isAudioCD: + if ext not in [".mp2", ".mp3", ".wav", ".ogg", "flac"] and not self.isAudioCD: self.hide() else: needsInfoUpdate = True @@ -754,7 +754,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB currref = self.playlist.getServiceRefList()[idx] text = currref.getPath() ext = text[-4:].lower() - if ext not in [".mp3", ".wav", ".ogg", "flac"] and not self.isAudioCD: + if ext not in [".mp2", ".mp3", ".wav", ".ogg", "flac"] and not self.isAudioCD: self.hide() else: needsInfoUpdate = True -- cgit v1.2.3 From 58fe3de03d974c022df060acdf5d0e3dbc5bac90 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 3 Nov 2008 09:01:50 +0100 Subject: user correct playlist parser from dict --- lib/python/Plugins/Extensions/MediaPlayer/plugin.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to '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 841ad614..ed1a8874 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -592,12 +592,13 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB def PlaylistSelected(self,path): if path is not None: self.clear_playlist() - self.playlistIOInternal = PlaylistIOInternal() - list = self.playlistIOInternal.open(path[1]) - if list: + extension = path[0].rsplit('.',1)[-1] + if self.playlistparsers.has_key(extension): + playlist = self.playlistparsers[extension]() + list = playlist.open(path[1]) for x in list: self.playlist.addFile(x.ref) - self.playlist.updateList() + self.playlist.updateList() def delete_saved_playlist(self): listpath = [] -- cgit v1.2.3 From cef8f42aa76d0ebf17b5b7ddf9883d6d6128c280 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Fri, 7 Nov 2008 09:21:24 +0100 Subject: refresh playlist when adding playlist via filelist. when copying directory to playlist, only add media files and no playlist files --- lib/python/Plugins/Extensions/MediaPlayer/plugin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to '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 ed1a8874..2233998c 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -632,7 +632,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB if x[0][1] == True: #isDir if recursive: self.copyDirectory(x[0][0]) - else: + elif filelist.getServiceRef().type != 4098: self.playlist.addFile(x[0][0]) self.playlist.updateList() @@ -646,6 +646,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB list = playlist.open(ServiceRef.getPath()) for x in list: self.playlist.addFile(x.ref) + self.playlist.updateList() else: self.playlist.addFile(self.filelist.getServiceRef()) self.playlist.updateList() -- cgit v1.2.3 From f5dc0e14397ef85ad77df165de061264dd2166fd Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Fri, 7 Nov 2008 11:14:18 +0100 Subject: fix coverart displaying, allow using cover art with all different image formats, remove some debug prints --- .../Plugins/Extensions/MediaPlayer/plugin.py | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to '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 2233998c..963247d6 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -1,6 +1,6 @@ from os import path as os_path, remove as os_remove, listdir as os_listdir from time import strftime -from enigma import iPlayableService, eTimer, eServiceCenter, iServiceInformation +from enigma import iPlayableService, eTimer, eServiceCenter, iServiceInformation, loadPic from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Screens.InputBox import InputBox @@ -14,6 +14,7 @@ from Tools.Directories import resolveFilename, SCOPE_CONFIG, SCOPE_PLAYLIST, SCO from Components.ServicePosition import ServicePositionGauge from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase from Components.Playlist import PlaylistIOInternal, PlaylistIOM3U, PlaylistIOPLS +from Components.AVSwitch import AVSwitch from Screens.InfoBarGenerics import InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSupport, InfoBarNotifications, InfoBarSubtitleSupport from ServiceReference import ServiceReference from Screens.ChoiceBox import ChoiceBox @@ -42,6 +43,7 @@ class MediaPixmap(Pixmap): break if self.default_pixmap is None: self.default_pixmap = resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/no_coverArt.png") + self.coverFileNames = ["folder.png", "folder.jpg"] return Pixmap.applySkin(self, desktop, screen) class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSupport, InfoBarNotifications, InfoBarSubtitleSupport, HelpableScreen): @@ -283,13 +285,15 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB def updateCoverArtPixmap(self, path): while not path.endswith("/"): path = path[:-1] - pngname = path + "folder.png" - - if not fileExists(pngname): - pngname = self["coverArt"].default_pixmap - if self.coverArtFileName != pngname: - self.coverArtFileName = pngname - self["coverArt"].instance.setPixmapFromFile(self.coverArtFileName) + new_coverArtFileName = self["coverArt"].default_pixmap + for filename in self["coverArt"].coverFileNames: + if fileExists(path + filename): + new_coverArtFileName = path + filename + if self.coverArtFileName != new_coverArtFileName: + self.coverArtFileName = new_coverArtFileName + pixmap = loadPic(self.coverArtFileName, 116, 116, AVSwitch().getAspectRatioSetting()/2,1,0,0) + if pixmap is not None: + self["coverArt"].instance.setPixmap(pixmap.__deref__()) def leftDown(self): self.lefttimer = True @@ -632,7 +636,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB if x[0][1] == True: #isDir if recursive: self.copyDirectory(x[0][0]) - elif filelist.getServiceRef().type != 4098: + elif filelist.getServiceRef() and filelist.getServiceRef().type == 4097: self.playlist.addFile(x[0][0]) self.playlist.updateList() @@ -640,7 +644,6 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB if self.filelist.getServiceRef().type == 4098: # playlist ServiceRef = self.filelist.getServiceRef() extension = ServiceRef.getPath()[ServiceRef.getPath().rfind('.') + 1:] - print "extension:", extension if self.playlistparsers.has_key(extension): playlist = self.playlistparsers[extension]() list = playlist.open(ServiceRef.getPath()) @@ -763,7 +766,8 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.unPauseService() if needsInfoUpdate == True: - self.updateCoverArtPixmap(currref.getPath()) + path = self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()].getPath() + self.updateCoverArtPixmap(path) else: pngname = self["coverArt"].default_pixmap self.coverArtFileName = pngname @@ -815,7 +819,6 @@ class MediaPlayerLCDScreen(Screen): self["text4"] = Label("") def setText(self, text, line): - print "lcd set text:", text, line if len(text) > 10: if text[-4:] == ".mp3": text = text[:-4] -- cgit v1.2.3 From 7cd404df03f85b78738c2650b45479e74e093d0b Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Fri, 14 Nov 2008 16:26:07 +0100 Subject: MediaPlayer: fix imports, introduce config and settings screen for repeat playlist, save playlist on exit and default start directory, implement file delete. this update comprises enhancements by courtesy of ralfk. fixes #46 --- .../Plugins/Extensions/MediaPlayer/Makefile.am | 3 +- .../Plugins/Extensions/MediaPlayer/plugin.py | 139 +++++++++++++++------ .../Plugins/Extensions/MediaPlayer/settings.py | 136 ++++++++++++++++++++ 3 files changed, 239 insertions(+), 39 deletions(-) create mode 100644 lib/python/Plugins/Extensions/MediaPlayer/settings.py (limited to 'lib/python/Plugins/Extensions/MediaPlayer/plugin.py') diff --git a/lib/python/Plugins/Extensions/MediaPlayer/Makefile.am b/lib/python/Plugins/Extensions/MediaPlayer/Makefile.am index e4ec5748..123df22d 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/Makefile.am +++ b/lib/python/Plugins/Extensions/MediaPlayer/Makefile.am @@ -1,5 +1,4 @@ installdir = $(LIBDIR)/enigma2/python/Plugins/Extensions/MediaPlayer install_PYTHON = \ - __init__.py \ - plugin.py + __init__.py plugin.py settings.py diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index 963247d6..b12e03e5 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -1,26 +1,26 @@ from os import path as os_path, remove as os_remove, listdir as os_listdir from time import strftime from enigma import iPlayableService, eTimer, eServiceCenter, iServiceInformation, loadPic +from ServiceReference import ServiceReference from Screens.Screen import Screen +from Screens.HelpMenu import HelpableScreen from Screens.MessageBox import MessageBox from Screens.InputBox import InputBox +from Screens.ChoiceBox import ChoiceBox +from Screens.InfoBarGenerics import InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSupport, InfoBarNotifications, InfoBarSubtitleSupport from Components.ActionMap import NumberActionMap, HelpableActionMap from Components.Label import Label from Components.Pixmap import Pixmap,MultiPixmap -from Components.Label import Label from Components.FileList import FileList from Components.MediaPlayer import PlayList -from Tools.Directories import resolveFilename, SCOPE_CONFIG, SCOPE_PLAYLIST, SCOPE_SKIN_IMAGE from Components.ServicePosition import ServicePositionGauge from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase from Components.Playlist import PlaylistIOInternal, PlaylistIOM3U, PlaylistIOPLS from Components.AVSwitch import AVSwitch -from Screens.InfoBarGenerics import InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSupport, InfoBarNotifications, InfoBarSubtitleSupport -from ServiceReference import ServiceReference -from Screens.ChoiceBox import ChoiceBox -from Screens.HelpMenu import HelpableScreen from Components.Harddisk import harddiskmanager -from Tools.Directories import fileExists, pathExists +from Components.config import config +from Tools.Directories import fileExists, pathExists, resolveFilename, SCOPE_CONFIG, SCOPE_PLAYLIST, SCOPE_SKIN_IMAGE +from settings import MediaPlayerSettings import random class MyPlayList(PlayList): @@ -68,7 +68,8 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.addPlaylistParser(PlaylistIOInternal, "e2pls") # 'None' is magic to start at the list of mountpoints - self.filelist = FileList(None, matchingPattern = "(?i)^.*\.(mp2|mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|mkv|mp4|dat|flac)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls") + defaultDir = config.mediaplayer.defaultDir.getValue() + self.filelist = FileList(defaultDir, matchingPattern = "(?i)^.*\.(mp2|mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|mkv|mp4|dat|flac)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls") self["filelist"] = self.filelist self.playlist = MyPlayList() @@ -94,7 +95,6 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self["coverArt"] = MediaPixmap() self["repeat"] = MultiPixmap() - self.repeat = False self.seek_target = None class MoviePlayerActionMap(NumberActionMap): @@ -171,7 +171,8 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.coverArtFileName = "" self.isAudioCD = False self.AudioCD_albuminfo = {} - self.savePlaylistOnExit = True + + self.applySettings() self.playlistIOInternal = PlaylistIOInternal() list = self.playlistIOInternal.open(resolveFilename(SCOPE_CONFIG, "playlist.e2pls")) @@ -194,16 +195,15 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB return MediaPlayerLCDScreen def exit(self): - self.session.openWithCallback(self.exitCB, MessageBox, _("Do you really want to exit?"), timeout=5) - - def exitCB(self, answer): - if answer == True: - self.playlistIOInternal.clear() - for x in self.playlist.list: - self.playlistIOInternal.addService(ServiceReference(x[0])) - if self.savePlaylistOnExit: - self.playlistIOInternal.save(resolveFilename(SCOPE_CONFIG, "playlist.e2pls")) - self.close() + self.playlistIOInternal.clear() + for x in self.playlist.list: + self.playlistIOInternal.addService(ServiceReference(x[0])) + if self.savePlaylistOnExit: + self.playlistIOInternal.save(resolveFilename(SCOPE_CONFIG, "playlist.e2pls")) + if config.mediaplayer.saveDirOnExit.getValue(): + config.mediaplayer.defaultDir.setValue(self.filelist.getCurrentDirectory()) + config.mediaplayer.defaultDir.save() + self.close() def checkSkipShowHideLock(self): self.updatedSeekState() @@ -451,18 +451,17 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB else: menu.append((_("add files to playlist"), "copyfiles")) menu.append((_("switch to playlist"), "playlist")) + menu.append((_("delete file"), "deletefile")) else: menu.append((_("switch to filelist"), "filelist")) - menu.append((_("shuffle playlist"), "shuffle")) - - menu.append((_("delete"), "delete")) + menu.append((_("Delete entry"), "deleteentry")) menu.append((_("clear playlist"), "clear")) menu.append((_("hide player"), "hide")); menu.append((_("save playlist"), "saveplaylist")); menu.append((_("load playlist"), "loadplaylist")); menu.append((_("delete saved playlist"), "deleteplaylist")); - menu.append((_("repeat playlist"), "repeat")); + menu.append((_("Edit settings"), "settings")) drivepath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()) if pathExists(drivepath): menu.insert(0,(_("Play Audio-CD..."), "audiocd")) @@ -477,20 +476,19 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB elif choice[1] == "copyfiles": self.stopEntry() self.playlist.clear() + self.isAudioCD = False self.copyDirectory(os_path.dirname(self.filelist.getSelection()[0].getPath()) + "/", recursive = False) self.playServiceRefEntry(self.filelist.getServiceRef()) elif choice[1] == "playlist": self.switchToPlayList() elif choice[1] == "filelist": self.switchToFileList() - elif choice[1] == "delete": + elif choice[1] == "deleteentry": if self.playlist.getSelectionIndex() == self.playlist.getCurrentIndex(): self.stopEntry() self.deleteEntry() elif choice[1] == "clear": - self.stopEntry() - self.playlist.clear() - self.switchToFileList() + self.clear_playlist() elif choice[1] == "hide": self.hide() elif choice[1] == "saveplaylist": @@ -501,13 +499,10 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.delete_saved_playlist() elif choice[1] == "shuffle": self.playlist.PlayListShuffle() - elif choice[1] == "repeat": - if self.repeat == True: - self.repeat = False - self["repeat"].setPixmapNum(0) - else: - self.repeat = True - self["repeat"].setPixmapNum(1) + elif choice[1] == "deletefile": + self.deleteFile() + elif choice[1] == "settings": + self.session.openWithCallback(self.applySettings, MediaPlayerSettings, self) elif choice[1] == "audiocd": from Components.Scanner import scanDevice drivepath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()) @@ -537,6 +532,13 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.changeEntry(0) self.switchToPlayList() + def applySettings(self): + self.savePlaylistOnExit = config.mediaplayer.savePlaylistOnExit.getValue() + if config.mediaplayer.repeat.getValue() == True: + self["repeat"].setPixmapNum(1) + else: + self["repeat"].setPixmapNum(0) + def showEventInformation(self): from Screens.EventView import EventViewSimple from ServiceReference import ServiceReference @@ -621,9 +623,13 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB def deleteConfirmed(self, confirmed): if confirmed: - os_remove(self.delname) + try: + os_remove(self.delname) + except OSError,e: + self.session.open(MessageBox, _("Delete failed!, %s") %e, MessageBox.TYPE_ERROR) def clear_playlist(self): + self.isAudioCD = False self.stopEntry() self.playlist.clear() self.switchToFileList() @@ -640,6 +646,64 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.playlist.addFile(x[0][0]) self.playlist.updateList() + def deleteFile(self): + if self.currList == "filelist": + self.service = self.filelist.getServiceRef() + else: + self.service = self.playlist.getSelection() + if self.service is None: + return + if self.service.type != 4098 and self.session.nav.getCurrentlyPlayingServiceReference() is not None: + if self.service == self.session.nav.getCurrentlyPlayingServiceReference(): + self.stopEntry() + + serviceHandler = eServiceCenter.getInstance() + offline = serviceHandler.offlineOperations(self.service) + info = serviceHandler.info(self.service) + name = info and info.getName(self.service) + result = False + if offline is not None: + # simulate first + if not offline.deleteFromDisk(1): + result = True + if result == True: + self.session.openWithCallback(self.deleteConfirmed_offline, MessageBox, _("Do you really want to delete %s?") % (name)) + else: + self.session.openWithCallback(self.close, MessageBox, _("You cannot delete this!"), MessageBox.TYPE_ERROR) + + def deleteConfirmed_offline(self, confirmed): + if confirmed: + serviceHandler = eServiceCenter.getInstance() + offline = serviceHandler.offlineOperations(self.service) + result = False + if offline is not None: + # really delete! + if not offline.deleteFromDisk(0): + result = True + if result == False: + self.session.open(MessageBox, _("Delete failed!"), MessageBox.TYPE_ERROR) + else: + self.removeListEntry() + + def removeListEntry(self): + currdir = self.filelist.getCurrentDirectory() + self.filelist.changeDir(currdir) + deleteend = False + while not deleteend: + index = 0 + deleteend = True + if len(self.playlist) > 0: + for x in self.playlist.list: + if self.service == x[0]: + self.playlist.deleteFile(index) + deleteend = False + break + index += 1 + self.playlist.updateList() + if self.currList == "playlist": + if len(self.playlist) == 0: + self.switchToFileList() + def copyFile(self): if self.filelist.getServiceRef().type == 4098: # playlist ServiceRef = self.filelist.getServiceRef() @@ -663,7 +727,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB next = self.playlist.getCurrentIndex() + 1 if next < len(self.playlist): self.changeEntry(next) - elif ( len(self.playlist) > 0 ) and ( self.repeat == True ): + elif ( len(self.playlist) > 0 ) and ( config.mediaplayer.repeat.getValue() == True ): self.stopEntry() self.changeEntry(0) @@ -704,6 +768,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB else: self.stopEntry() self.playlist.clear() + self.isAudioCD = False sel = self.filelist.getSelection() if sel: if sel[1]: # can descent diff --git a/lib/python/Plugins/Extensions/MediaPlayer/settings.py b/lib/python/Plugins/Extensions/MediaPlayer/settings.py new file mode 100644 index 00000000..594b4534 --- /dev/null +++ b/lib/python/Plugins/Extensions/MediaPlayer/settings.py @@ -0,0 +1,136 @@ +from Screens.Screen import Screen +from Screens.HelpMenu import HelpableScreen +from Components.Label import Label +from Components.FileList import FileList +from Components.MediaPlayer import PlayList +from Components.config import config, getConfigListEntry, ConfigSubsection, configfile, ConfigText, ConfigYesNo +from Components.ConfigList import ConfigListScreen +from Components.ActionMap import ActionMap + +class ConfigDirectory(ConfigText): + def __init__(self, default="", visible_width=60): + ConfigText.__init__(self, default, fixed_size = True, visible_width = visible_width) + def handleKey(self, key): + pass + def getValue(self): + if self.text == "": + return None + else: + return ConfigText.getValue(self) + def setValue(self, val): + if val == None: + val = "" + ConfigText.setValue(self, val) + def getMulti(self, selected): + if self.text == "": + return ("mtext"[1-selected:], _("List of Storage Devices"), range(0)) + else: + return ConfigText.getMulti(self, selected) + +config.mediaplayer = ConfigSubsection() +config.mediaplayer.repeat = ConfigYesNo(default=False) +config.mediaplayer.savePlaylistOnExit = ConfigYesNo(default=True) +config.mediaplayer.saveDirOnExit = ConfigYesNo(default=False) +config.mediaplayer.defaultDir = ConfigDirectory() + +class DirectoryBrowser(Screen, HelpableScreen): + skin = """ + + + + + + """ + def __init__(self, session, currDir): + from Components.Sources.StaticText import StaticText + Screen.__init__(self, session) + HelpableScreen.__init__(self) + + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Apply")) + + self.filelist = FileList(currDir, matchingPattern="") + self["filelist"] = self.filelist + + self["FilelistActions"] = ActionMap(["SetupActions", "ColorActions"], + { + "green": self.apply, + "red": self.exit, + "ok": self.ok, + "cancel": self.exit + }) + + def ok(self): + if self.filelist.canDescent(): + self.filelist.descent() + + def apply(self): + if self.filelist.canDescent() and len(self["filelist"].getFilename()) > len(self["filelist"].getCurrentDirectory()): + self.filelist.descent() + self.close(self["filelist"].getCurrentDirectory()) + + def exit(self): + self.close(False) + +class MediaPlayerSettings(Screen,ConfigListScreen): + skin = """ + + + + + + + """ + + def __init__(self, session, parent): + from Components.Sources.StaticText import StaticText + Screen.__init__(self, session) + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Save")) + + ConfigListScreen.__init__(self, []) + self.parent = parent + self.initConfigList() + config.mediaplayer.saveDirOnExit.addNotifier(self.initConfigList) + + self["setupActions"] = ActionMap(["SetupActions", "ColorActions"], + { + "green": self.save, + "red": self.cancel, + "cancel": self.cancel, + "ok": self.ok, + }, -2) + + def initConfigList(self, element=None): + print "[initConfigList]", element + try: + self.list = [] + self.list.append(getConfigListEntry(_("repeat playlist"), config.mediaplayer.repeat)) + self.list.append(getConfigListEntry(_("save playlist on exit"), config.mediaplayer.savePlaylistOnExit)) + self.list.append(getConfigListEntry(_("save last directory on exit"), config.mediaplayer.saveDirOnExit)) + if not config.mediaplayer.saveDirOnExit.getValue(): + self.list.append(getConfigListEntry(_("start directory"), config.mediaplayer.defaultDir)) + self["config"].setList(self.list) + except KeyError: + print "keyError" + + def changedConfigList(self): + self.initConfigList() + + def ok(self): + if self["config"].getCurrent()[1] == config.mediaplayer.defaultDir: + self.session.openWithCallback(self.DirectoryBrowserClosed, DirectoryBrowser, self.parent.filelist.getCurrentDirectory()) + + def DirectoryBrowserClosed(self, path): + print "PathBrowserClosed:" + str(path) + if path != False: + config.mediaplayer.defaultDir.setValue(path) + + def save(self): + for x in self["config"].list: + x[1].save() + self.close() + + def cancel(self): + self.close() + -- cgit v1.2.3 From 103f4bf674f20b4431233ac066089e6de16ea480 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Fri, 14 Nov 2008 22:31:31 +0100 Subject: callbacks that are added upon hotplug events can be added to a hotplugNotifier list now. use this to speed up Audio CD recognition in MediaPlayer --- .../Plugins/Extensions/MediaPlayer/plugin.py | 35 ++++++++++++---------- lib/python/Plugins/SystemPlugins/Hotplug/plugin.py | 8 +++++ 2 files changed, 28 insertions(+), 15 deletions(-) (limited to '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 b12e03e5..876e2a48 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -21,6 +21,7 @@ from Components.Harddisk import harddiskmanager from Components.config import config from Tools.Directories import fileExists, pathExists, resolveFilename, SCOPE_CONFIG, SCOPE_PLAYLIST, SCOPE_SKIN_IMAGE from settings import MediaPlayerSettings +from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier import random class MyPlayList(PlayList): @@ -96,6 +97,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self["repeat"] = MultiPixmap() self.seek_target = None + hotplugNotifier.append(self.hotplugCB) class MoviePlayerActionMap(NumberActionMap): def __init__(self, player, contexts = [ ], actions = { }, prio=0): @@ -171,7 +173,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.coverArtFileName = "" self.isAudioCD = False self.AudioCD_albuminfo = {} - + self.cdAudioTrackFiles = [] self.applySettings() self.playlistIOInternal = PlaylistIOInternal() @@ -203,6 +205,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB if config.mediaplayer.saveDirOnExit.getValue(): config.mediaplayer.defaultDir.setValue(self.filelist.getCurrentDirectory()) config.mediaplayer.defaultDir.save() + hotplugNotifier.remove(self.hotplugCB) self.close() def checkSkipShowHideLock(self): @@ -445,6 +448,8 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB def showMenu(self): menu = [] + if len(self.cdAudioTrackFiles): + menu.insert(0,(_("Play Audio-CD..."), "audiocd")) if self.currList == "filelist": if self.filelist.canDescent(): menu.append((_("add directory to playlist"), "copydir")) @@ -462,9 +467,6 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB menu.append((_("load playlist"), "loadplaylist")); menu.append((_("delete saved playlist"), "deleteplaylist")); menu.append((_("Edit settings"), "settings")) - drivepath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()) - if pathExists(drivepath): - menu.insert(0,(_("Play Audio-CD..."), "audiocd")) self.session.openWithCallback(self.menuCallback, ChoiceBox, title="", list=menu) def menuCallback(self, choice): @@ -504,16 +506,6 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB elif choice[1] == "settings": self.session.openWithCallback(self.applySettings, MediaPlayerSettings, self) elif choice[1] == "audiocd": - from Components.Scanner import scanDevice - drivepath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()) - self.cdAudioTrackFiles = [] - res = scanDevice(drivepath) - list = [ (r.description, r, res[r], self.session) for r in res ] - if list: - (desc, scanner, files, session) = list[0] - for file in files: - if file.mimetype == "audio/x-cda": - self.cdAudioTrackFiles.append(file.path) self.playAudioCD() def playAudioCD(self): @@ -867,7 +859,20 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB def subtitleSelection(self): from Screens.Subtitles import Subtitles - self.session.open(Subtitles) + self.session.open(Subtitles) + + def hotplugCB(self, dev, media_state): + if dev == harddiskmanager.getCD(): + from Components.Scanner import scanDevice + devpath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()) + self.cdAudioTrackFiles = [] + res = scanDevice(devpath) + list = [ (r.description, r, res[r], self.session) for r in res ] + if list: + (desc, scanner, files, session) = list[0] + for file in files: + if file.mimetype == "audio/x-cda": + self.cdAudioTrackFiles.append(file.path) class MediaPlayerLCDScreen(Screen): skin = """ diff --git a/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py b/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py index 469b1dd0..97ddf4a1 100644 --- a/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py +++ b/lib/python/Plugins/SystemPlugins/Hotplug/plugin.py @@ -8,6 +8,8 @@ DEVICEDB = \ "/devices/pci0000:00/0000:00:14.2/usb1/1-1/1-1:1.0/host0/target1:0:0/0:0:0:0": "SD Slot" } +hotplugNotifier = [ ] + class Hotplug(Protocol): def getUserfriendlyDeviceName(self, phys): return DEVICEDB.get(phys, "USB Storage") @@ -48,6 +50,12 @@ class Hotplug(Protocol): harddiskmanager.addHotplugPartition(dev, self.getUserfriendlyDeviceName(physdevpath)) elif media_state == '0': harddiskmanager.removeHotplugPartition(dev) + + for callback in hotplugNotifier: + try: + callback(dev, media_state) + except AttributeError: + hotplugNotifier.remove(callback) def autostart(reason, **kwargs): if reason == 0: -- cgit v1.2.3 From 369086956b791ab97d2e60e2c820f7045650c236 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Sat, 15 Nov 2008 00:12:52 +0100 Subject: MediaPlayer german locale update --- .../Plugins/Extensions/MediaPlayer/plugin.py | 3 +- .../Plugins/Extensions/MediaPlayer/settings.py | 23 +++++++------- po/de.po | 37 +++++++++++++++------- 3 files changed, 40 insertions(+), 23 deletions(-) (limited to '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 876e2a48..0d5305d7 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -618,7 +618,8 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB try: os_remove(self.delname) except OSError,e: - self.session.open(MessageBox, _("Delete failed!, %s") %e, MessageBox.TYPE_ERROR) + print "delete failed:", e + self.session.open(MessageBox, _("Delete failed!"), MessageBox.TYPE_ERROR) def clear_playlist(self): self.isAudioCD = False diff --git a/lib/python/Plugins/Extensions/MediaPlayer/settings.py b/lib/python/Plugins/Extensions/MediaPlayer/settings.py index 594b4534..c6d274bd 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/settings.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/settings.py @@ -35,11 +35,12 @@ config.mediaplayer.defaultDir = ConfigDirectory() class DirectoryBrowser(Screen, HelpableScreen): skin = """ - + - - - + + + + """ def __init__(self, session, currDir): from Components.Sources.StaticText import StaticText @@ -47,14 +48,14 @@ class DirectoryBrowser(Screen, HelpableScreen): HelpableScreen.__init__(self) self["key_red"] = StaticText(_("Cancel")) - self["key_green"] = StaticText(_("Apply")) + self["key_green"] = StaticText(_("Use")) self.filelist = FileList(currDir, matchingPattern="") self["filelist"] = self.filelist self["FilelistActions"] = ActionMap(["SetupActions", "ColorActions"], { - "green": self.apply, + "green": self.use, "red": self.exit, "ok": self.ok, "cancel": self.exit @@ -64,7 +65,7 @@ class DirectoryBrowser(Screen, HelpableScreen): if self.filelist.canDescent(): self.filelist.descent() - def apply(self): + def use(self): if self.filelist.canDescent() and len(self["filelist"].getFilename()) > len(self["filelist"].getCurrentDirectory()): self.filelist.descent() self.close(self["filelist"].getCurrentDirectory()) @@ -74,12 +75,12 @@ class DirectoryBrowser(Screen, HelpableScreen): class MediaPlayerSettings(Screen,ConfigListScreen): skin = """ - + - + - - + + """ def __init__(self, session, parent): diff --git a/po/de.po b/po/de.po index a0198dd5..75186438 100755 --- a/po/de.po +++ b/po/de.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: tuxbox-enigma 0.0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-11-14 07:24+0100\n" -"PO-Revision-Date: 2008-11-13 14:12+0100\n" +"POT-Creation-Date: 2008-11-14 23:57+0100\n" +"PO-Revision-Date: 2008-11-14 23:41+0100\n" "Last-Translator: Andreas Frisch \n" "Language-Team: none\n" "MIME-Version: 1.0\n" @@ -89,7 +89,7 @@ msgid "(empty)" msgstr "(leer)" msgid "(show optional DVD audio menu)" -msgstr "" +msgstr "(DVD-Audiomenü zeigen falls vorh.)" msgid "* Only available if more than one interface is active." msgstr "* Nur verfügbar wenn mehr als ein Netzwerkadapter aktiv ist." @@ -948,9 +948,6 @@ msgid "" "the plugin \"%s\"?" msgstr "" -msgid "Do you really want to exit?" -msgstr "Wollen Sie wirklich beenden?" - msgid "" "Do you really want to initialize the harddisk?\n" "All data on the disk will be lost!" @@ -1606,7 +1603,7 @@ msgid "Load" msgstr "Laden" msgid "Load Length of Movies in Movielist" -msgstr "" +msgstr "Anzeigen der Spielzeit in der Filmliste" msgid "Local Network" msgstr "Int. Netzwerk" @@ -2020,7 +2017,7 @@ msgid "Pan&Scan" msgstr "" msgid "Parent Directory" -msgstr "" +msgstr "übergeordnetes Verzeichnis" msgid "Parental control" msgstr "Jugendschutz" @@ -3397,6 +3394,9 @@ msgstr "Upgrade" msgid "Upgrading Dreambox... Please wait" msgstr "Dreambox wird aktualisiert... Bitte warten" +msgid "Use" +msgstr "Benutzen" + msgid "Use DHCP" msgstr "Adresse automatisch beziehen (DHCP)" @@ -3978,12 +3978,12 @@ msgstr "täglich" msgid "day" msgstr "Tag" -msgid "delete" -msgstr "Löschen" - msgid "delete cut" msgstr "Schnitt löschen" +msgid "delete file" +msgstr "Datei löschen" + msgid "delete playlist entry" msgstr "Wiedergabelisteneintrag löschen" @@ -4397,9 +4397,15 @@ msgstr "Zum vorherigen Kapitel zurück" msgid "right" msgstr "rechts" +msgid "save last directory on exit" +msgstr "Anfangsverzeichnis beim Beenden merken" + msgid "save playlist" msgstr "Wiedergabeliste speichern" +msgid "save playlist on exit" +msgstr "Wiedergabeliste beim Beenden speicher" + msgid "scan done!" msgstr "Suche beendet!" @@ -4518,6 +4524,9 @@ msgstr "Standby" msgid "start cut here" msgstr "Schnitt hier starten" +msgid "start directory" +msgstr "Anfangsverzeichnis" + msgid "start timeshift" msgstr "Timeshift starten" @@ -4679,6 +4688,9 @@ msgstr "umgeschaltet" #~ "Wollen Sie das Plugin mit\n" #~ "dem Namen \" wirklich herunterladen?" +#~ msgid "Do you really want to exit?" +#~ msgstr "Wollen Sie wirklich beenden?" + #~ msgid "Enable WLAN Support" #~ msgstr "Aktiviere WLAN Unterstützung" @@ -4783,6 +4795,9 @@ msgstr "umgeschaltet" #~ msgid "You have to wait for" #~ msgstr "Sie müssen warten" +#~ msgid "delete" +#~ msgstr "Löschen" + #~ msgid "equal to Socket A" #~ msgstr "Wie Tuner A" -- cgit v1.2.3