[MediaPlayer] fix bug in "add directory to playlist".
[vuplus_dvbapp] / lib / python / Plugins / Extensions / MediaPlayer / plugin.py
index d61dbc7..fab96d9 100755 (executable)
@@ -110,7 +110,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
 
                # 'None' is magic to start at the list of mountpoints
                defaultDir = config.mediaplayer.defaultDir.getValue()
-               self.filelist = FileList(defaultDir, matchingPattern = "(?i)^.*\.(mp2|mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|divx|m4v|mkv|mp4|m4a|dat|flac|mov|m2ts)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls")
+               self.filelist = FileList(defaultDir, matchingPattern = "(?i)^.*\.(mp2|mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|divx|m4v|mkv|mp4|m4a|dat|flac|mov|m2ts|flv|dts|3gp|3g2|mts|wmv|asf|wma)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls")
                self["filelist"] = self.filelist
 
                self.playlist = MyPlayList()
@@ -137,8 +137,8 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
 
                self.seek_target = None
 
-               from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier
-               hotplugNotifier.append(self.hotplugCB)
+#              from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier
+#              hotplugNotifier.append(self.hotplugCB)
 
                class MoviePlayerActionMap(NumberActionMap):
                        def __init__(self, player, contexts = [ ], actions = { }, prio=0):
@@ -168,8 +168,10 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
                                "prevBouquet": (self.switchToPlayList, _("switch to playlist")),
                                "nextBouquet": (self.switchToFileList, _("switch to filelist")),
                                "delete": (self.deletePlaylistEntry, _("delete playlist entry")),
-                               "shift_stop": (self.clear_playlist, _("clear playlist")),
-                               "shift_record": (self.playlist.PlayListShuffle, _("shuffle playlist")),
+#                              "shift_stop": (self.clear_playlist, _("clear playlist")),
+#                              "shift_record": (self.playlist.PlayListShuffle, _("shuffle playlist")),
+                               "shift_stop": self.clear_playlist,
+                               "shift_record": self.playlist.PlayListShuffle,
                                "subtitles": (self.subtitleSelection, _("Subtitle selection")),
                        }, -2)
 
@@ -248,8 +250,8 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
                if config.mediaplayer.saveDirOnExit.getValue():
                        config.mediaplayer.defaultDir.setValue(self.filelist.getCurrentDirectory())
                        config.mediaplayer.defaultDir.save()
-               from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier
-               hotplugNotifier.remove(self.hotplugCB)
+#      from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier
+#      hotplugNotifier.remove(self.hotplugCB)
                del self["coverArt"].picload
                self.close()
 
@@ -277,13 +279,13 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
                currPlay = self.session.nav.getCurrentService()
                sTagAudioCodec = currPlay.info().getInfoString(iServiceInformation.sTagAudioCodec)
                print "[__evAudioDecodeError] audio-codec %s can't be decoded by hardware" % (sTagAudioCodec)
-               self.session.open(MessageBox, _("This Dreambox can't decode %s streams!") % sTagAudioCodec, type = MessageBox.TYPE_INFO,timeout = 20 )
+               self.session.open(MessageBox, _("This STB can't decode %s streams!") % sTagAudioCodec, type = MessageBox.TYPE_INFO,timeout = 20 )
 
        def __evVideoDecodeError(self):
                currPlay = self.session.nav.getCurrentService()
                sTagVideoCodec = currPlay.info().getInfoString(iServiceInformation.sTagVideoCodec)
                print "[__evVideoDecodeError] video-codec %s can't be decoded by hardware" % (sTagVideoCodec)
-               self.session.open(MessageBox, _("This Dreambox can't decode %s streams!") % sTagVideoCodec, type = MessageBox.TYPE_INFO,timeout = 20 )
+               self.session.open(MessageBox, _("This STB can't decode %s streams!") % sTagVideoCodec, type = MessageBox.TYPE_INFO,timeout = 20 )
 
        def __evPluginError(self):
                currPlay = self.session.nav.getCurrentService()
@@ -676,12 +678,14 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
                filelist = FileList(directory, useServiceRef = True, showMountpoints = False, isTop = True)
 
                for x in filelist.getFileList():
-                       if x[0][1] == True: #isDir
+                       isDir = x[0][1]
+                       data = x[0][0]
+                       if isDir == True:
                                if recursive:
-                                       if x[0][0] != directory:
+                                       if data != directory:
                                                self.copyDirectory(x[0][0])
-                       elif filelist.getServiceRef() and filelist.getServiceRef().type == 4097:
-                               self.playlist.addFile(x[0][0])
+                       elif data and data.type in (2, 3, 4097):
+                               self.playlist.addFile(data)
                self.playlist.updateList()
 
        def deleteFile(self):
@@ -820,7 +824,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
        
        def playEntry(self):
                if len(self.playlist.getServiceRefList()):
-                       audio_extensions = (".mp2", ".mp3", ".wav", ".ogg", "flac", "m4a")
+                       audio_extensions = (".mp2", ".mp3", ".wav", ".ogg", ".flac", ".m4a", ".dts")
                        needsInfoUpdate = False
                        currref = self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()]
                        if self.session.nav.getCurrentlyPlayingServiceReference() is None or currref != self.session.nav.getCurrentlyPlayingServiceReference():
@@ -833,7 +837,11 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
                                currref = self.playlist.getServiceRefList()[idx]
                                text = self.getIdentifier(currref)
                                text = ">"+text
-                               ext = text[-4:].lower()
+                               try:
+                                       import os
+                                       nameext = os.path.splitext(text)
+                                       ext = nameext[1]
+                               except: 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 audio_extensions and not self.isAudioCD:
@@ -1041,6 +1049,6 @@ def filescan(**kwargs):
 from Plugins.Plugin import PluginDescriptor
 def Plugins(**kwargs):
        return [
-               PluginDescriptor(name = "MediaPlayer", description = "Play back media files", where = PluginDescriptor.WHERE_MENU, fnc = menu),
-               PluginDescriptor(name = "MediaPlayer", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)
+               PluginDescriptor(name = "MediaPlayer", description = "Play back media files", where = PluginDescriptor.WHERE_MENU, needsRestart = False, fnc = menu),
+               PluginDescriptor(name = "MediaPlayer", where = PluginDescriptor.WHERE_FILESCAN, needsRestart = False, fnc = filescan)
        ]