allow burning DVDs with multiple titles where playback automatically jumps to the...
[enigma2.git] / lib / python / Plugins / Extensions / DVDPlayer / plugin.py
index 1db873761d5f8794b6c792c02be83f9cefd25fc2..f9f45cbcff5c7c0c780f4606610f67767419e961 100644 (file)
@@ -56,17 +56,24 @@ class FileBrowser(Screen):
                        global lastpath
                        filename = self["filelist"].getFilename()
                        if filename is not None:
-                               lastpath = filename[0:filename.rfind("/")]
                                if filename.upper().endswith("VIDEO_TS/"):
                                        print "dvd structure found, trying to open..."
-                                       self.close(filename[0:-9])
+                                       dvdpath = filename[0:-9]
+                                       lastpath = (dvdpath.rstrip("/").rsplit("/",1))[0]
+                                       print "lastpath video_ts/=", lastpath
+                                       self.close(dvdpath)
+                                       return
                        if self["filelist"].canDescent(): # isDir
                                self["filelist"].descent()
                                pathname = self["filelist"].getCurrentDirectory() or ""
                                if fileExists(pathname+"VIDEO_TS.IFO"):
                                        print "dvd structure found, trying to open..."
+                                       lastpath = (pathname.rstrip("/").rsplit("/",1))[0]
+                                       print "lastpath video_ts.ifo=", lastpath
                                        self.close(pathname)
                        else:
+                               lastpath = filename[0:filename.rfind("/")]
+                               print "lastpath directory=", lastpath
                                self.close(filename)
 
        def exit(self):
@@ -246,6 +253,8 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP
                self["audioLabel"] = Label("n/a")
                self["subtitleLabel"] = Label("")
                self["chapterLabel"] = Label("")
+               self.last_audioTuple = None
+               self.last_subtitleTuple = None
                self.totalChapters = 0
                self.currentChapter = 0
                self.totalTitles = 0
@@ -424,8 +433,9 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP
                print "AudioInfoAvail ", repr(audioTuple)
                audioString = "%d: %s (%s)" % (audioTuple[0],audioTuple[1],audioTuple[2])
                self["audioLabel"].setText(audioString)
-               if not self.in_menu:
+               if audioTuple != self.last_audioTuple and not self.in_menu:
                        self.doShow()
+               self.last_audioTuple = audioTuple
 
        def __osdSubtitleInfoAvail(self):
                subtitleTuple = self.service.info().getInfoObject(iServiceInformation.sUser+7)
@@ -434,8 +444,9 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP
                if subtitleTuple[0] is not 0:
                        subtitleString = "%d: %s" % (subtitleTuple[0],subtitleTuple[1])
                self["subtitleLabel"].setText(subtitleString)
-               if not self.in_menu:
+               if subtitleTuple != self.last_subtitleTuple and not self.in_menu:
                        self.doShow()
+               self.last_subtitleTuple = subtitleTuple
 
        def __chapterUpdated(self):
                self.currentChapter = self.service.info().getInfo(iServiceInformation.sCurrentChapter)
@@ -452,10 +463,10 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP
                        self.doShow()
                
        def askLeavePlayer(self):
-               if self.physicalDVD:
-                       self.session.openWithCallback(self.exitCB, ChoiceBox, title=_("Leave DVD Player?"), list=[(_("Continue playing"), "play"), (_("Exit"), "exit")])
-               else:
-                       self.session.openWithCallback(self.exitCB, ChoiceBox, title=_("Leave DVD Player?"), list=[(_("Continue playing"), "play"), (_("Return to file browser"), "browser"), (_("Exit"), "exit")])
+               choices = [(_("Continue playing"), "play"), (_("Exit"), "exit")]
+               if not self.physicalDVD:
+                       choices.insert(1,(_("Return to file browser"), "browser"))                      
+               self.session.openWithCallback(self.exitCB, ChoiceBox, title=_("Leave DVD Player?"), list = choices)
 
        def nextAudioTrack(self):
                if self.service:
@@ -542,6 +553,7 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP
                        self.FileBrowserClosed(self.dvd_device)
                else:
                        self.session.openWithCallback(self.FileBrowserClosed, FileBrowser)
+                       self.physicalDVD = False
 
        def FileBrowserClosed(self, val):
                curref = self.session.nav.getCurrentlyPlayingServiceReference()
@@ -585,7 +597,10 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP
                print "playLastCB", answer, self.resume_point
                if self.service:
                        seek = self.service.seek()
-                       seek.seekTo(self.resume_point)
+                       if answer == True:
+                               seek.seekTo(self.resume_point)
+                       pause = self.service.pause()
+                       pause.unpause()
                self.hideAfterResume()
 
        def showAfterCuesheetOperation(self):