Author: dmeyer
Date: Sun Mar 11 09:52:24 2007
New Revision: 9318

Added:
   trunk/ui/src/video/plugins/config.cxml
   trunk/ui/src/video/plugins/resume.py
      - copied, changed from r9316, 
/trunk/WIP/broken_plugins/video.bookmarker.py
Modified:
   trunk/WIP/broken_plugins/video.bookmarker.py

Log:
make autoresume work again

Modified: trunk/WIP/broken_plugins/video.bookmarker.py
==============================================================================
--- trunk/WIP/broken_plugins/video.bookmarker.py        (original)
+++ trunk/WIP/broken_plugins/video.bookmarker.py        Sun Mar 11 09:52:24 2007
@@ -9,9 +9,6 @@
 # 2. Later, to get back there, choose the actions button in the menu, and it'll
 #    have a list of bookmarks in a submenu, click on one of those to resume
 #    from where you saved.
-# 3. When stopping a movie while blackback, the current playtime will be stored
-#    in as auto bookmark. After that, a RESUME action is in the item menu to
-#    start were the plackback stopped.
 #
 # Todo: Currently this only works for files without subitems or variant.
 #
@@ -55,21 +52,11 @@
 # the logging object
 log = logging.getLogger()
 
-# variable to store the auto resume
-RESUME = 'autobookmark_resume'
-
-kaa.beacon.register_file_type_attrs('video',
-    autobookmark_resume = (int, kaa.beacon.ATTR_SIMPLE))
-
 class PluginInterface(ItemPlugin):
     """
     class to handle auto bookmarks
     """
 
-    def __init__(self):
-        ItemPlugin.__init__(self)
-        self._ignore_end = False
-        
     def get_bookmarkfile(self, filename):
         """
         Get the bookmark file for the given filename.
@@ -87,28 +74,12 @@
             # only works for video items
             return []
         actions = []
-        if item[RESUME]:
-            actions.append(Action(_('Resume playback'), self.resume))
         if item.mode == 'file' and not item.subitems \
                and os.path.exists(self.get_bookmarkfile(item.filename)):
             actions.append(Action(_('Bookmarks'), self.bookmark_menu))
         return actions
 
 
-    def resume(self, item):
-        """
-        Resume playback
-        """
-        t = max(0, item[RESUME] - 10)
-        info = kaa.metadata.parse(item.filename)
-        if hasattr(info, 'seek') and t:
-            mplayer_options = '-sb %s' % info.seek(t)
-        else:
-            mplayer_options = '-ss %s' % t
-        item.get_menustack().delete_submenu()
-        item.play(mplayer_options = mplayer_options)
-
-
     def bookmark_menu(self, item):
         """
         Bookmark list
@@ -144,25 +115,6 @@
         """
         Handle video events for bookmark support.
         """
-        # auto bookmark store
-        if event == STOP:
-            if item.mode == 'file' and not item.subitems and item.elapsed:
-                # this will store in kaa.beacon
-                log.info('auto-bookmark store')
-                item[RESUME]= item.elapsed
-                self._ignore_end = True
-            else:
-                log.info('auto-bookmark not supported for this item')
-            return False
-
-        # auto bookmark delete
-        if event == PLAY_END:
-            if self._ignore_end:
-                self._ignore_end = False
-            else:
-                item[RESUME] = None
-            return False
-
         # bookmark the current time into a file
         if event == STORE_BOOKMARK:
             bookmarkfile = self.get_bookmarkfile(item.filename)

Added: trunk/ui/src/video/plugins/config.cxml
==============================================================================
--- (empty file)
+++ trunk/ui/src/video/plugins/config.cxml      Sun Mar 11 09:52:24 2007
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<config name="video.plugin">
+    <desc lang="en">video plugins</desc>
+    <group name="resume" plugin="10">
+        <desc>
+            Add resume option to video files. The plugin will remember the
+            position when playback is stopped and add a resume option to the
+            item menu. If the plugin level is lower than 10 resume will be the
+            default option.
+        </desc>
+    </group>
+</config>

Copied: trunk/ui/src/video/plugins/resume.py (from r9316, 
/trunk/WIP/broken_plugins/video.bookmarker.py)
==============================================================================
--- /trunk/WIP/broken_plugins/video.bookmarker.py       (original)
+++ trunk/ui/src/video/plugins/resume.py        Sun Mar 11 09:52:24 2007
@@ -1,28 +1,17 @@
 # -*- coding: iso-8859-1 -*-
 # -----------------------------------------------------------------------------
-# bookmarker.py - Plugin to handle bookmarking
+# resume.py - Plugin to handle resume playback
 # -----------------------------------------------------------------------------
 # $Id$
 #
-# 1. while watching a movie file, hit the 'record' button and it'll save a
-#    bookmark. There is no visual feedback though.
-# 2. Later, to get back there, choose the actions button in the menu, and it'll
-#    have a list of bookmarks in a submenu, click on one of those to resume
-#    from where you saved.
-# 3. When stopping a movie while blackback, the current playtime will be stored
-#    in as auto bookmark. After that, a RESUME action is in the item menu to
-#    start were the plackback stopped.
-#
-# Todo: Currently this only works for files without subitems or variant.
-#
 # -----------------------------------------------------------------------------
 # Freevo - A Home Theater PC framework
-# Copyright (C) 2002-2005 Krister Lagerstrom, Dirk Meyer, et al.
+# Copyright (C) 2002 Krister Lagerstrom, 2003-2007 Dirk Meyer, et al.
 #
 # First Edition: Aubin Paul <[EMAIL PROTECTED]>
 # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
 #
-# Please see the file doc/CREDITS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -41,9 +30,7 @@
 # -----------------------------------------------------------------------------
 
 # python imports
-import os
 import logging
-import kaa.metadata
 import kaa.beacon
 
 # freevo imports
@@ -61,6 +48,7 @@
 kaa.beacon.register_file_type_attrs('video',
     autobookmark_resume = (int, kaa.beacon.ATTR_SIMPLE))
 
+
 class PluginInterface(ItemPlugin):
     """
     class to handle auto bookmarks
@@ -69,80 +57,30 @@
     def __init__(self):
         ItemPlugin.__init__(self)
         self._ignore_end = False
-        
-    def get_bookmarkfile(self, filename):
-        """
-        Get the bookmark file for the given filename.
-        """
-        myfile = os.path.basename(filename)
-        myfile = freevo.conf.datafile(myfile + '.bookmark')
-        return myfile
+        self._seek = 0
 
 
     def actions(self, item):
         """
         Return additional actions for the item.
         """
-        if item.type == 'dir' or item.type == 'playlist' or item.iscopy:
-            # only works for video items
-            return []
-        actions = []
         if item[RESUME]:
-            actions.append(Action(_('Resume playback'), self.resume))
-        if item.mode == 'file' and not item.subitems \
-               and os.path.exists(self.get_bookmarkfile(item.filename)):
-            actions.append(Action(_('Bookmarks'), self.bookmark_menu))
-        return actions
+            return [ Action(_('Resume playback'), self.resume) ]
+        return []
 
 
     def resume(self, item):
         """
         Resume playback
         """
-        t = max(0, item[RESUME] - 10)
-        info = kaa.metadata.parse(item.filename)
-        if hasattr(info, 'seek') and t:
-            mplayer_options = '-sb %s' % info.seek(t)
-        else:
-            mplayer_options = '-ss %s' % t
+        self._seek = max(0, item[RESUME] - 10)
         item.get_menustack().delete_submenu()
-        item.play(mplayer_options = mplayer_options)
-
-
-    def bookmark_menu(self, item):
-        """
-        Bookmark list
-        """
-        bookmarkfile = self.get_bookmarkfile(item.filename)
-        item.get_menustack().delete_submenu(False)
-
-        items = []
-        fd = open(bookmarkfile, 'r')
-        for line in fd.readline():
-            copy = item.copy()
-
-            sec  = int(line)
-            hour = int(sec/3600)
-            min  = int((sec-(hour*3600))/60)
-            sec  = int(sec%60)
-            time = '%0.2d:%0.2d:%0.2d' % (hour,min,sec)
-
-            # set a new title
-            copy.name = _('Jump to %s') % (time)
-            if not copy.mplayer_options:
-                copy.mplayer_options = ''
-            copy.mplayer_options += ' -ss %s' % time
-            items.append(copy)
-        fd.close()
-        
-        if items:
-            moviemenu = Menu(item.name, items)
-            item.pushmenu(moviemenu)
+        item.play()
 
 
     def eventhandler(self, item, event):
         """
-        Handle video events for bookmark support.
+        Handle video events.
         """
         # auto bookmark store
         if event == STOP:
@@ -155,6 +93,12 @@
                 log.info('auto-bookmark not supported for this item')
             return False
 
+        # seek to the given position
+        if event == PLAY_START and self._seek:
+            Event(SEEK, self._seek).post()
+            self._seek = 0
+            return False
+
         # auto bookmark delete
         if event == PLAY_END:
             if self._ignore_end:
@@ -163,15 +107,4 @@
                 item[RESUME] = None
             return False
 
-        # bookmark the current time into a file
-        if event == STORE_BOOKMARK:
-            bookmarkfile = self.get_bookmarkfile(item.filename)
-
-            handle = open(bookmarkfile,'a+')
-            handle.write(str(item.elapsed))
-            handle.write('\n')
-            handle.close()
-            OSD_MESSAGE.post(_('Added Bookmark'))
-            return True
-
         return False

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to