fix media player behaviour when adding a single file:
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Fri, 6 Oct 2006 12:51:40 +0000 (12:51 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Fri, 6 Oct 2006 12:51:40 +0000 (12:51 +0000)
adds the whole directory to the playlist now and plays the selected file
(advantage: the next file is automatically played after the selected file finished playing)

lib/python/Screens/MediaPlayer.py

index 4c142332a5c572b7da8b7c4aacc3050ea14c6912..446621dfbace1f32a329751e62d2777b74ea6217 100644 (file)
@@ -283,7 +283,10 @@ class MediaPlayer(Screen, InfoBarSeek):
                                self.filelist.descent()
                                self.updateCurrentInfo()
                        else:
-                               self.copyFile()
+                               self.playlist.clear()
+                               self.copyDirectory(os.path.dirname(self.filelist.getSelection()[0].getPath()) + "/", recursive = False)
+                               self.playServiceRefEntry(self.filelist.getServiceRef())
+                               
                if self.currList == "playlist":
                        selection = self["playlist"].getSelection()
                        self.changeEntry(self.playlist.getSelectionIndex())
@@ -364,12 +367,14 @@ class MediaPlayer(Screen, InfoBarSeek):
                elif choice[1] == "hide":
                        self.hide()
 
-       def copyDirectory(self, directory):
+       def copyDirectory(self, directory, recursive = True):
+               print "copyDirectory", directory
                filelist = FileList(directory, useServiceRef = True, isTop = True)
 
                for x in filelist.getFileList():
                        if x[0][1] == True: #isDir
-                               self.copyDirectory(x[0][0])
+                               if recursive:
+                                       self.copyDirectory(x[0][0])
                        else:
                                self.playlist.addFile(x[0][0])
                self.playlist.updateList()
@@ -428,6 +433,13 @@ class MediaPlayer(Screen, InfoBarSeek):
                self.playlist.setCurrentPlaying(index)
                self.playEntry()
 
+       def playServiceRefEntry(self, serviceref):
+               serviceRefList = self.playlist.getServiceRefList()
+               for count in range(len(serviceRefList)):
+                       if serviceRefList[count] == serviceref:
+                               self.changeEntry(count)
+                               break
+
        def playEntry(self):
                if len(self.playlist.getServiceRefList()):
                        currref = self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()]