-# import order is important here since Clutter 0.8,
+# import order is important here since Clutter 0.8,
# see the pyclutter README for details
import cluttergst
@@ -13,6 +13,7 @@
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 +59,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 +75,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 +82,12 @@ 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: %(err)s, %(debug)s" % \
+ {'err': err, 'debug': debug})
Right, thanks for that catch Matt.
So, now the get_texture is reintroduced and return None if there's no art available for the currently playing media.
Then, the main screen display the *default-art* in the preview area.
The same philosophy is used in other screens.
new diff :
=== modified file 'entertainerlib /frontend/ gui/screens/ main_screen. py' frontend/ gui/screens/ main_screen. py 2008-12-08 17:26:56 +0000 frontend/ gui/screens/ main_screen. py 2009-01-08 09:38:04 +0000
--- entertainerlib/
+++ entertainerlib/
@@ -110,6 +110,8 @@
# Video preview of current media
video_ texture = player. get_texture( ) self.theme. getImage( "default_ album_art" )) get_size( ) HEIGHT - 50) / float(height)
+ if video_texture == None:
+ video_texture = Texture(
width, height = video_texture.
x_ratio = (self.PREVIEW_WIDTH - 50) / float(width)
y_ratio = (self.PREVIEW_
=== modified file 'entertainerlib /frontend/ media_player. py' frontend/ media_player. py 2008-12-14 20:01:49 +0000 frontend/ media_player. py 2009-01-08 15:37:51 +0000
--- entertainerlib/
+++ entertainerlib/
@@ -4,7 +4,7 @@
__copyright__ = "2007, Lauri Taimila"
__author__ = "Lauri Taimila <email address hidden>"
-# import order is important here since Clutter 0.8,
+# import order is important here since Clutter 0.8,
# see the pyclutter README for details
import cluttergst
@@ -13,6 +13,7 @@
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 +59,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: %(err)s, %(debug)s" % \
+
self.bus = self.playbin.
@@ -72,8 +75,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 +82,12 @@
else:
+ elif message.type == gst.MESSAGE_ERROR:
+ self.video_
+ self.video_
+ err, debug = message.
+ self.logger.
+ {'err': err, 'debug': debug})
def set_playlist(self, playlist):
texture = Texture(url)
return texture
"""
@@ -502,5 +509,5 @@
else:
- pass #FIXME: Return default album art
+ return None