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 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
-
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 : /frontend/ media_player. py' frontend/ media_player. py 2008-12-14 20:01:49 +0000 frontend/ media_player. py 2009-01-06 11:57:34 +0000
=== modified file 'entertainerlib
--- entertainerlib/
+++ entertainerlib/
@@ -8,11 +8,10 @@
# see the pyclutter README for details
import cluttergst
-import clutter
import gst
-from entertainerlib. frontend. gui.widgets. texture import Texture frontend. medialibrary. playable import Playable utils.logger import Logger
from entertainerlib.
+from entertainerlib.
class MediaPlayer( object) :
self. repeat = False # Repeat mode
self. playing = False # Is media player currently playing
"""
@@ -58,6 +57,8 @@
+ self.logger = Logger( ).getLogger( 'frontend. MediaPlayer' )
self. video_texture = cluttergst. VideoTexture( )
self. playbin = self.video_ texture. get_playbin( ) get_bus( ) get_type( ) == Playable. VIDEO_STREAM \
self. video_texture. set_property( "position" , 0)
self. next() texture. set_playing( False) texture. set_property( "position" , 0) parse_error( ) error(" Error: %s" % err, debug)
+
self.bus = self.playbin.
@@ -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.
or self.playlist is None:
@@ -81,6 +80,11 @@
else:
+ elif message.type == gst.MESSAGE_ERROR:
+ self.video_
+ self.video_
+ err, debug = message.
+ self.logger.
def set_playlist(self, playlist):
y_ offset = -int((fake_height - self.stage_height) / 2)
self. video_texture. set_position( 0, y_offset)
"""
@@ -488,19 +492,3 @@
- def get_texture(self): get_type( ) == Playable. VIDEO_STREAM: CloneTexture( self.video_ texture) get_type( ) == Playable. AUDIO_STREAM: get_album_ art_url( )
- """
- Get media's texture. This is a video texture or album art texture.
- @return: clutter.Actor
- """
- if self.media.
- return clutter.
-
- elif self.media.
- url = self.media.
- if url is not None:
- texture = Texture(url)
- return texture
- else:
- pass #FIXME: Return default album art
-