Author: dmeyer
Date: Sun Apr 15 09:01:54 2007
New Revision: 9452

Added:
   trunk/ui/src/video/playlist.py
Modified:
   trunk/ui/src/video/__init__.py
   trunk/ui/src/video/configure.py
   trunk/ui/src/video/plugins/resume.py
   trunk/ui/src/video/videoitem.py

Log:
Remove subitems support from VideoItem. A VideoItem with
more than one url is just a playlist. So there is VideoPlaylist
now but that code is not tested yet because nothing can
create such an item (yet).


Modified: trunk/ui/src/video/__init__.py
==============================================================================
--- trunk/ui/src/video/__init__.py      (original)
+++ trunk/ui/src/video/__init__.py      Sun Apr 15 09:01:54 2007
@@ -41,3 +41,4 @@
 
 # used by video plugins
 from videoitem import VideoItem
+from playlist import VideoPlaylist

Modified: trunk/ui/src/video/configure.py
==============================================================================
--- trunk/ui/src/video/configure.py     (original)
+++ trunk/ui/src/video/configure.py     Sun Apr 15 09:01:54 2007
@@ -70,15 +70,6 @@
     play_movie(item, chapter=chapter)
 
 
-def start_subitem(item, pos):
-    """
-    Handle subitem selection.
-    """
-    item.conf_select_this_item = item.subitems[pos]
-    item.show_menu(False)
-    play_movie(item)
-
-
 def audio_selection(item):
     """
     Submenu for audio selection.
@@ -150,18 +141,6 @@
     item.pushmenu(Menu(_('Player Selection'), menu_items))
 
     
-def subitem_selection(item):
-    """
-    Submenu for subitem selection.
-    """
-    menu_items = []
-    for pos in range(len(item.subitems)):
-        a = ActionItem(_('Play chapter %s') % (pos+1), item, start_subitem)
-        a.parameter(pos)
-        menu_items.append(a)
-    item.pushmenu(Menu(_('Chapter Menu'), menu_items))
-
-
 def toggle(item, name, variable):
     """
     Basic toggle function.
@@ -203,10 +182,6 @@
         # if item.info.has_key('chapters') and item.info['chapters'] > 1:
         #   a = ActionItem(_('Chapter selection'), item, chapter_selection)
         #   items.append(a)
-    if item.subitems:
-        # show subitems as chapter
-        a = ActionItem(_('Chapter selection'), item, subitem_selection)
-        items.append(a)
 
     items.append(add_toggle(item, _('deinterlacing'), 'interlaced'))
     items.append(ActionItem(_('Select player'), item, player_selection))

Added: trunk/ui/src/video/playlist.py
==============================================================================
--- (empty file)
+++ trunk/ui/src/video/playlist.py      Sun Apr 15 09:01:54 2007
@@ -0,0 +1,46 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# playlist.py - VideoItem with more than one url
+# -----------------------------------------------------------------------------
+# $Id: videoitem.py 9443 2007-04-14 19:48:49Z dmeyer $
+#
+# Note: this is not tested yet because there is no working code right now
+# that supports subitems for video items.
+#
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2007 Dirk Meyer, et al.
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------------
+
+# freevo imports
+from freevo.ui.playlist import Playlist
+
+class VideoPlaylist(Playlist):
+    type = 'video'
+
+    def __id__(self):
+        """
+        Return a unique id of the item. This id should be the same when the
+        item is rebuild later with the same informations
+        """
+        return ''.join([ c.__id__() for c in self.choices ])

Modified: trunk/ui/src/video/plugins/resume.py
==============================================================================
--- trunk/ui/src/video/plugins/resume.py        (original)
+++ trunk/ui/src/video/plugins/resume.py        Sun Apr 15 09:01:54 2007
@@ -82,7 +82,7 @@
         """
         # auto bookmark store
         if event == STOP:
-            if item.mode == 'file' and not item.subitems and item.elapsed:
+            if item.mode == 'file' and item.elapsed:
                 # this will store in kaa.beacon
                 log.info('auto-bookmark store')
                 item[RESUME]= item.elapsed

Modified: trunk/ui/src/video/videoitem.py
==============================================================================
--- trunk/ui/src/video/videoitem.py     (original)
+++ trunk/ui/src/video/videoitem.py     Sun Apr 15 09:01:54 2007
@@ -5,11 +5,9 @@
 # $Id$
 #
 # This file contains a VideoItem. A VideoItem can not only hold a simple
-# video file, it can also store subitems if the video is splitted into several
-# files. DVD and VCD are also VideoItems.
+# video file. DVD and VCD are also VideoItems.
 #
 # TODO: o maybe split this file into file/vcd/dvd or
-#         move subitem to extra file
 #       o create better 'arg' handling in play
 #
 # -----------------------------------------------------------------------------
@@ -71,9 +69,6 @@
     def __init__(self, url, parent):
         MediaItem.__init__(self, parent, type='video')
 
-        self.subitems          = []         # more than one file/track to play
-        self.current_subitem   = None
-
         self.subtitle_file     = {}         # text subtitles
         self.audio_file        = {}         # audio dubbing
 
@@ -165,18 +160,6 @@
         return c
     
 
-    def __id__(self):
-        """
-        Return a unique id of the item. This id should be the same when the
-        item is rebuild later with the same informations
-        """
-        ret = self.url
-        if self.subitems:
-            for s in self.subitems:
-                ret += s.__id__()
-        return ret
-
-
     def __getitem__(self, key):
         """
         return the specific attribute
@@ -228,48 +211,6 @@
         return MediaItem.__getitem__(self, key)
 
 
-    def __set_next_available_subitem(self):
-        """
-        select the next available subitem. Loops on each subitem and checks if
-        the needed media is really there.
-        If the media is there, sets self.current_subitem to the given subitem
-        and returns 1.
-        If no media has been found, we set self.current_subitem to None.
-          If the search for the next available subitem did start from the
-            beginning of the list, then we consider that no media at all was
-            available for any subitem: we return 0.
-          If the search for the next available subitem did not start from the
-            beginning of the list, then we consider that at least one media
-            had been found in the past: we return 1.
-        """
-        if hasattr(self, 'conf_select_this_item'):
-            # XXX bad hack, clean me up
-            self.current_subitem = self.conf_select_this_item
-            del self.conf_select_this_item
-            return True
-
-        cont = 1
-        from_start = 0
-        si = self.current_subitem
-        while cont:
-            if not si:
-                # No subitem selected yet: take the first one
-                si = self.subitems[0]
-                from_start = 1
-            else:
-                pos = self.subitems.index(si)
-                # Else take the next one
-                if pos < len(self.subitems)-1:
-                    # Let's get the next subitem
-                    si = self.subitems[pos+1]
-                else:
-                    # No next subitem
-                    si = None
-                    cont = 0
-        self.current_subitem = None
-        return not from_start
-
-
     # ------------------------------------------------------------------------
     # actions:
 
@@ -318,42 +259,6 @@
         """
         Play the item.
         """
-        if self.subitems:
-            # if we have subitems (a movie with more than one file),
-            # we start playing the first that is physically available
-            self.error_in_subitem = 0
-            self.last_error_msg   = ''
-            self.current_subitem  = None
-
-            result = self.__set_next_available_subitem()
-            if self.current_subitem: # 'result' is always 1 in this case
-                # When playing a subitem, the menu must be hidden. If it is
-                # not, the playing will stop after the first subitem, since the
-                # PLAY_END event is not forwarded to the parent
-                # videoitem.
-                # And besides, we don't need the menu between two subitems.
-                self.last_error_msg=self.current_subitem.play()
-                if self.last_error_msg:
-                    self.error_in_subitem = 1
-                    # Go to the next playable subitem, using the loop in
-                    # eventhandler()
-                    self.eventhandler(PLAY_END)
-
-            elif not result:
-                # No media at all was found: error
-                txt = (_('No media found for "%s".\n')+
-                       _('Please insert the media.')) % self.name
-                box = ConfirmWindow(txt, (_('Retry'), _('Abort')))
-                box.buttons[0].connect(self.play)
-                box.show()
-                
-            # done, everything else is handled in 'play' of the subitem
-            return
-
-        if self.url.startswith('file://'):
-            # normal playback of one file
-            file = self.filename
-
         # call the player to play the item
         videoplayer.play(self, **kwargs)
 
@@ -363,27 +268,3 @@
         stop playing
         """
         videoplayer.stop()
-
-
-    def eventhandler(self, event):
-        """
-        eventhandler for this item
-        """
-        # PLAY_END: do we have to play another file?
-        if self.subitems:
-            if event == PLAY_END:
-                self.__set_next_available_subitem()
-                # Loop until we find a subitem which plays without error
-                while self.current_subitem:
-                    log.info('playing next item')
-                    error = self.current_subitem.play()
-                    if error:
-                        self.last_error_msg = error
-                        self.error_in_subitem = 1
-                        self.__set_next_available_subitem()
-                    else:
-                        return True
-                if self.error_in_subitem:
-                    # No more subitems to play, and an error occured
-                    MessageWindow(self.last_error_msg).show()
-        return MediaItem.eventhandler(self, event)

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to