some dvd player changes (resume isnt working yet)
[enigma2.git] / lib / python / Plugins / Extensions / DVDPlayer / plugin.py
index 856c7d18d40674c4f88d22155a9a156a92be8d3f..a44d042bf9b973a12d53d6d388503575ee41424b 100644 (file)
@@ -10,7 +10,7 @@ from Screens.InfoBarGenerics import InfoBarSeek, InfoBarPVRState, InfoBarCueShee
 from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap
 from Components.Label import Label
 from Components.FileList import FileList
-from Components.ServiceEventTracker import ServiceEventTracker
+from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase
 from Components.config import config
 from Components.ProgressBar import ProgressBar
 from ServiceReference import ServiceReference
@@ -19,6 +19,8 @@ from Tools.Directories import pathExists, fileExists
 import random
 import servicedvd # load c++ part of dvd player plugin
 
+lastpath = ""
+
 class FileBrowser(Screen):
        skin = """
        <screen name="FileBrowser" position="100,100" size="520,376" title="DVD File Browser" >
@@ -26,7 +28,11 @@ class FileBrowser(Screen):
        </screen>"""
        def __init__(self, session):
                Screen.__init__(self, session)
-               currDir = "/media/dvd/"
+               global lastpath
+               if lastpath is not None:
+                       currDir = lastpath + "/"
+               else:
+                       currDir = "/media/dvd/"
                if not pathExists(currDir):
                        currDir = "/"
                #else:
@@ -41,16 +47,18 @@ class FileBrowser(Screen):
                        })
 
        def ok(self):
-               if self["filelist"].getFilename().upper().endswith("VIDEO_TS/"):
-                       print "dvd structure found, trying to open..."
-                       self.close(self["filelist"].getFilename()[0:-9])
-               
-               elif self["filelist"].canDescent(): # isDir
+               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])
+               if self["filelist"].canDescent(): # isDir
                        self["filelist"].descent()
-                       
                else:
-                       self.close(self["filelist"].getFilename())
-                       
+                       self.close(filename)
+
        def exit(self):
                self.close(None)
                
@@ -139,7 +147,7 @@ class ChapterZap(Screen):
                self.Timer.callback.append(self.keyOK)
                self.Timer.start(3000, True)
 
-class DVDPlayer(Screen, InfoBarNotifications, InfoBarSeek, InfoBarCueSheetSupport, InfoBarPVRState, InfoBarShowHide, HelpableScreen):
+class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarCueSheetSupport, InfoBarPVRState, InfoBarShowHide, HelpableScreen):
        ALLOW_SUSPEND = True
        ENABLE_RESUME_SUPPORT = True
        
@@ -212,6 +220,7 @@ class DVDPlayer(Screen, InfoBarNotifications, InfoBarSeek, InfoBarCueSheetSuppor
 
        def __init__(self, session, args = None):
                Screen.__init__(self, session)
+               InfoBarBase.__init__(self)
                InfoBarNotifications.__init__(self)
                InfoBarCueSheetSupport.__init__(self, actionmap = "MediaPlayerCueSheetActions")
                InfoBarShowHide.__init__(self)
@@ -330,10 +339,12 @@ class DVDPlayer(Screen, InfoBarNotifications, InfoBarSeek, InfoBarCueSheetSuppor
        def __menuOpened(self):
                self.hide()
                self.in_menu = True
+               self["NumberActions"].setEnabled(False)
 
        def __menuClosed(self):
                self.show()
                self.in_menu = False
+               self["NumberActions"].setEnabled(True)
 
        def setChapterLabel(self):
                chapterLCD = "Menu"
@@ -380,13 +391,15 @@ class DVDPlayer(Screen, InfoBarNotifications, InfoBarSeek, InfoBarCueSheetSuppor
                audioString = self.service.info().getInfoString(iPlayableService.evUser+6)
                print "AudioInfoAvail "+audioString
                self["audioLabel"].setText(audioString)
-               self.doShow()
+               if not self.in_menu:
+                       self.doShow()
 
        def __osdSubtitleInfoAvail(self):
                subtitleString = self.service.info().getInfoString(iPlayableService.evUser+7)
                print "SubtitleInfoAvail "+subtitleString
                self["subtitleLabel"].setText(subtitleString)
-               self.doShow()
+               if not self.in_menu:
+                       self.doShow()
 
        def __chapterUpdated(self):
                self.currentChapter = self.service.info().getInfo(iPlayableService.evUser+8)
@@ -399,7 +412,8 @@ class DVDPlayer(Screen, InfoBarNotifications, InfoBarSeek, InfoBarCueSheetSuppor
                self.totalTitles = self.service.info().getInfo(iPlayableService.evUser+90)
                self.setChapterLabel()
                print "__titleUpdated: %d/%d" % (self.currentTitle, self.totalTitles)
-               self.doShow()
+               if not self.in_menu:
+                       self.doShow()
                
        #def __initializeDVDinfo(self):
                #self.__osdAudioInfoAvail()
@@ -472,6 +486,8 @@ class DVDPlayer(Screen, InfoBarNotifications, InfoBarSeek, InfoBarCueSheetSuppor
 
        def keyOk(self):
                if self.service:
+                       if not self.in_menu:
+                               self.toggleInfo()
                        self.service.keys().keyPressed(iServiceKeys.keyOk)
 
        def keyCancel(self):
@@ -515,13 +531,27 @@ class DVDPlayer(Screen, InfoBarNotifications, InfoBarSeek, InfoBarCueSheetSuppor
                self.restore_infobar_seek_config()
                self.session.nav.playService(self.oldService)
 
+       def playLastCB(self, answer): # overwrite infobar cuesheet function
+               print "playLastCB", answer, self.resume_point
+#              if answer == True:
+#                      self.doSeek(self.resume_point)
+               self.hideAfterResume()
+
        def showAfterCuesheetOperation(self):
-               self.show()
+               if not self.in_menu:
+                       self.show()
 
        def createSummary(self):
                print "DVDCreateSummary"
                return DVDSummary
 
+#override some InfoBarSeek functions
+       def doEof(self):
+               self.setSeekState(self.SEEK_STATE_PLAY)
+
+       def calcRemainingTime(self):
+               return 0
+
 def main(session, **kwargs):
        session.open(DVDPlayer)