make resume optional
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index 4f0e76b16375c246eea03be4e0b9234a1875a6d5..754b673ac04d3b91d5cea9ae4bde489acae4b124 100644 (file)
@@ -299,16 +299,36 @@ class InfoBarChannelSelection:
                self.session.execDialog(self.servicelist)
 
        def zapUp(self):
-               if currentConfigSelectionElement(config.usage.quickzap_bouquet_change) == "yes":
-                       if self.servicelist.inBouquet() and self.servicelist.atBegin():
-                               self.servicelist.prevBouquet()
-               self.servicelist.moveUp()
+               if self.servicelist.inBouquet():
+                       prev = self.servicelist.getCurrentSelection()
+                       if prev:
+                               prev = prev.toString()
+                               while True:
+                                       if currentConfigSelectionElement(config.usage.quickzap_bouquet_change) == "yes":
+                                               if self.servicelist.atBegin():
+                                                       self.servicelist.prevBouquet()
+                                       self.servicelist.moveUp()
+                                       cur = self.servicelist.getCurrentSelection()
+                                       if not cur or (not (cur.flags & 64)) or cur.toString() == prev:
+                                               break
+               else:
+                       self.servicelist.moveUp()
                self.servicelist.zap()
                self.doShow()
 
        def zapDown(self):
-               if currentConfigSelectionElement(config.usage.quickzap_bouquet_change) == "yes" and self.servicelist.inBouquet() and self.servicelist.atEnd():
-                       self.servicelist.nextBouquet()
+               if self.servicelist.inBouquet():
+                       prev = self.servicelist.getCurrentSelection()
+                       if prev:
+                               prev = prev.toString()
+                               while True:
+                                       if currentConfigSelectionElement(config.usage.quickzap_bouquet_change) == "yes" and self.servicelist.atEnd():
+                                               self.servicelist.nextBouquet()
+                                       else:
+                                               self.servicelist.moveDown()
+                                       cur = self.servicelist.getCurrentSelection()
+                                       if not cur or (not (cur.flags & 64)) or cur.toString() == prev:
+                                               break
                else:
                        self.servicelist.moveDown()
                self.servicelist.zap()
@@ -1423,6 +1443,9 @@ class InfoBarCueSheetSupport:
        CUT_TYPE_IN = 0
        CUT_TYPE_OUT = 1
        CUT_TYPE_MARK = 2
+       CUT_TYPE_LAST = 3
+       
+       ENABLE_RESUME_SUPPORT = False
        
        def __init__(self):
                self["CueSheetActions"] = HelpableActionMap(self, "InfobarCueSheetActions", 
@@ -1433,14 +1456,34 @@ class InfoBarCueSheetSupport:
                        }, prio=1) 
                
                self.cut_list = [ ]
+               self.is_closing = False
                self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
                        {
                                iPlayableService.evStart: self.__serviceStarted,
                        })
 
        def __serviceStarted(self):
+               if self.is_closing:
+                       return
                print "new service started! trying to download cuts!"
                self.downloadCuesheet()
+               
+               if self.ENABLE_RESUME_SUPPORT:
+                       last = None
+                       
+                       for (pts, what) in self.cut_list:
+                               if what == self.CUT_TYPE_LAST:
+                                       last = pts
+                       
+                       if last is not None:
+                               self.resume_point = last
+                               Notifications.AddNotificationWithCallback(self.playLastCB, MessageBox, _("Do you want to resume this playback?"), timeout=10)
+
+       def playLastCB(self, answer):
+               if answer == True:
+                       seekable = self.__getSeekable()
+                       if seekable is not None:
+                               seekable.seekTo(self.resume_point)
 
        def __getSeekable(self):
                service = self.session.nav.getCurrentService()