add ability to stop currently running repeated timer when disabling it
[enigma2.git] / lib / python / Screens / MediaPlayer.py
index 4c142332a5c572b7da8b7c4aacc3050ea14c6912..4e299b27b75bf21f2316e7ce632b3c2fbcbb547b 100644 (file)
@@ -4,7 +4,6 @@ from Screens.MessageBox import MessageBox
 from Components.ActionMap import NumberActionMap
 from Components.Label import Label
 from Components.Input import Input
-from Components.GUIComponent import *
 from Components.Pixmap import Pixmap
 from Components.Label import Label
 from Components.FileList import FileEntryComponent, FileList
@@ -34,7 +33,8 @@ class MediaPlayer(Screen, InfoBarSeek):
                self.addPlaylistParser(PlaylistIOPLS, "pls")
                self.addPlaylistParser(PlaylistIOInternal, "e2pls")
 
-               self.filelist = FileList(resolveFilename(SCOPE_MEDIA), matchingPattern = "(?i)^.*\.(mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob)", useServiceRef = True)
+               # '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)", useServiceRef = True)
                self["filelist"] = self.filelist
 
                self.playlist = PlayList()
@@ -271,9 +271,15 @@ class MediaPlayer(Screen, InfoBarSeek):
                text = ""
                if self.currList == "filelist":
                        if not self.filelist.canDescent():
-                               text = self.filelist.getServiceRef().getPath()
+                               r = self.filelist.getServiceRef()
+                               if r is None:
+                                       return
+                               text = r.getPath()
                if self.currList == "playlist":
-                       text = self.playlist.getSelection().getPath()
+                       t = self.playlist.getSelection()
+                       if t is None:
+                               return
+                       text = t.getPath()
 
                self["currenttext"].setText(os.path.basename(text))
 
@@ -283,7 +289,11 @@ class MediaPlayer(Screen, InfoBarSeek):
                                self.filelist.descent()
                                self.updateCurrentInfo()
                        else:
-                               self.copyFile()
+                               self.stopEntry()
+                               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 +374,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 +440,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()]