Author: duncan
Date: Fri Jun  1 18:04:59 2007
New Revision: 9627

Modified:
   branches/rel-1/freevo/ChangeLog
   branches/rel-1/freevo/src/video/plugins/mplayer.py
   branches/rel-1/freevo/src/video/plugins/xine.py

Log:
[ 1729603 ] Xine video plug-in should process the stdout and stderr
Updated and changed mplayer to have a sensible argument name


Modified: branches/rel-1/freevo/ChangeLog
==============================================================================
--- branches/rel-1/freevo/ChangeLog     (original)
+++ branches/rel-1/freevo/ChangeLog     Fri Jun  1 18:04:59 2007
@@ -18,6 +18,7 @@
 
  * Added personal web pages to the webserver, using PERSONAL_WWW_PAGE 
(F#1729595)
  * Updated childapp to use subprocess instead of popen (F#1729597)
+ * Updated xine video plug-in to process stdout and stderr message (F#1729603)
  * Fixed tv recordings manager not deleting files when out of space (B#1728182)
  * Fixed problem with FXD.setattr not working correctly in all cases 
(B#1728421)
 

Modified: branches/rel-1/freevo/src/video/plugins/mplayer.py
==============================================================================
--- branches/rel-1/freevo/src/video/plugins/mplayer.py  (original)
+++ branches/rel-1/freevo/src/video/plugins/mplayer.py  Fri Jun  1 18:04:59 2007
@@ -489,7 +489,7 @@
     class controlling the in and output from the mplayer process
     """
 
-    def __init__(self, app, mplayer):
+    def __init__(self, command, mplayer):
         self.RE_TIME   = re.compile("^A: *([0-9]+)").match
         self.RE_START  = re.compile("^Starting playback\.\.\.").match
         self.RE_EXIT   = re.compile("^Exiting\.\.\. \((.*)\)$").match
@@ -519,8 +519,7 @@
                 self.elapsed_plugins.append(p)
 
         # init the child (== start the threads)
-        childapp.ChildApp2.__init__(self, app)
-
+        childapp.ChildApp2.__init__(self, command)
 
 
     def stop_event(self):

Modified: branches/rel-1/freevo/src/video/plugins/xine.py
==============================================================================
--- branches/rel-1/freevo/src/video/plugins/xine.py     (original)
+++ branches/rel-1/freevo/src/video/plugins/xine.py     Fri Jun  1 18:04:59 2007
@@ -50,9 +50,9 @@
 
 
 class PluginInterface(plugin.Plugin):
-    """
+    '''
     Xine plugin for the video player.
-    """
+    '''
     def __init__(self):
         plugin.Plugin.__init__(self)
 
@@ -77,30 +77,31 @@
 
 
 class Xine:
-    """
-    the main class to control xine
-    """
+    '''the main class to control xine
+    '''
     def __init__(self, type):
+        '''Xine contructor
+        '''
         self.name      = 'xine'
 
-        self.app_mode  = ''
+        self.app_mode  = 'video'
         self.xine_type = type
         self.app       = None
+        self.plugins   = []
 
         self.command = [ '--prio=%s' % config.MPLAYER_NICE ] + \
-                       config.XINE_COMMAND.split(' ') + \
-                       [ '--stdctl', '-V', config.XINE_VO_DEV,
-                         '-A', config.XINE_AO_DEV ] + \
-                       config.XINE_ARGS_DEF.split(' ')
+            config.XINE_COMMAND.split(' ') +  \
+            [ '--stdctl', '-V', config.XINE_VO_DEV, '-A', config.XINE_AO_DEV ] 
+ \
+            config.XINE_ARGS_DEF.split(' ')
 
 
     def rate(self, item):
-        """
+        '''
         How good can this player play the file:
         2 = good
         1 = possible, but not good
         0 = unplayable
-        """
+        '''
         if item.url.startswith('dvd://'):
             return 2
         if item.url.startswith('vcd://'):
@@ -116,10 +117,10 @@
 
 
     def play(self, options, item):
-        """
+        '''
         play a dvd with xine
-        """
-        self.item     = item
+        '''
+        self.item = item
         if config.EVENTS.has_key(item.mode):
             self.app_mode = item.mode
         else:
@@ -173,27 +174,33 @@
         else:
             command.append(item.url)
 
-        _debug_('Xine.play(): Starting cmd=%s' % command)
+        #_debug_('Xine.play(): Starting cmd=%s' % command)
+
+        self.stdout_plugins = []
 
         rc.app(self)
-        self.app = childapp.ChildApp2(command)
+
+        self.app = XineApp(command, self)
         return None
 
 
     def stop(self):
-        """
+        '''
         Stop xine
-        """
-        if self.app:
-            self.app.stop('quit\n')
-            rc.app(None)
+        '''
+        if not self.app:
+            return
+
+        self.app.stop('quit\n')
+        rc.app(None)
+        self.app = None
 
 
     def eventhandler(self, event, menuw=None):
-        """
+        '''
         eventhandler for xine control. If an event is not bound in this
         function it will be passed over to the items eventhandler
-        """
+        '''
         if not self.app:
             return self.item.eventhandler(event)
 
@@ -329,3 +336,39 @@
 
         # nothing found? Try the eventhandler of the object who called us
         return self.item.eventhandler(event)
+
+
+
+class XineApp(childapp.ChildApp2):
+    '''
+    class controlling the in and output from the xine process
+    '''
+    def __init__(self, command, player):
+        _debug_('XineApp.__init__(command=%r, player=%r)' % (command, player), 
3)
+        self.item = player.item
+        self.player = player
+
+        childapp.ChildApp2.__init__(self, command)
+
+    def stdout_cb(self, line):
+        '''
+        parse the stdout of the xine process
+        '''
+        # show connection status for network play
+        if self.item.network_play:
+            pass
+
+    def stderr_cb(self, line):
+        '''
+        parse the stderr of the xine process
+        '''
+        _debug_('%r' % line, 2)
+        # Has it started?
+        if line.find('playing mrl') >= 0:
+            _debug_('playback started')
+
+        # Has it finished?
+        if line.find('playback finished for mrl') >= 0:
+            _debug_('playback finished')
+            if self.player:
+                self.player.stop()

-------------------------------------------------------------------------
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