Code review comment for lp://staging/~samuel-buffet/entertainer/ftx2

Revision history for this message
Samuel Buffet (samuel-buffet) wrote :

Hi,

A small work around the MediaPlayer.

First, I've added error management to the gst pipeline bus handler.
and removed a none used method of the MediaPlayer.

Samuel

the diff :
=== modified file 'entertainerlib/frontend/media_player.py'
--- entertainerlib/frontend/media_player.py 2008-12-14 20:01:49 +0000
+++ entertainerlib/frontend/media_player.py 2009-01-06 11:57:34 +0000
@@ -8,11 +8,10 @@
 # see the pyclutter README for details

 import cluttergst
-import clutter
 import gst

-from entertainerlib.frontend.gui.widgets.texture import Texture
 from entertainerlib.frontend.medialibrary.playable import Playable
+from entertainerlib.utils.logger import Logger

 class MediaPlayer(object):
     """
@@ -58,6 +57,8 @@
         self.repeat = False # Repeat mode
         self.playing = False # Is media player currently playing

+ self.logger = Logger().getLogger('frontend.MediaPlayer')
+
         self.video_texture = cluttergst.VideoTexture()
         self.playbin = self.video_texture.get_playbin()
         self.bus = self.playbin.get_bus()
@@ -72,8 +73,6 @@
         Callback function that is called every time when message occurs on
         Gstreamer messagebus.
         """
- # TODO: Figure out what needs to be done (if anything) with the bus
- # variable on callback
         if message.type == gst.MESSAGE_EOS:
             if self.media.get_type() == Playable.VIDEO_STREAM \
                 or self.playlist is None:
@@ -81,6 +80,11 @@
                 self.video_texture.set_property("position", 0)
             else:
                 self.next()
+ elif message.type == gst.MESSAGE_ERROR:
+ self.video_texture.set_playing(False)
+ self.video_texture.set_property("position", 0)
+ err, debug = message.parse_error()
+ self.logger.error("Error: %s" % err, debug)

     def set_playlist(self, playlist):
         """
@@ -488,19 +492,3 @@
             y_offset = -int((fake_height - self.stage_height) / 2)
             self.video_texture.set_position(0, y_offset)

- def get_texture(self):
- """
- Get media's texture. This is a video texture or album art texture.
- @return: clutter.Actor
- """
- if self.media.get_type() == Playable.VIDEO_STREAM:
- return clutter.CloneTexture(self.video_texture)
-
- elif self.media.get_type() == Playable.AUDIO_STREAM:
- url = self.media.get_album_art_url()
- if url is not None:
- texture = Texture(url)
- return texture
- else:
- pass #FIXME: Return default album art
-

« Back to merge proposal