Hi Olivier
I tried out two approaches
One was to do some kind of duck-typing and taste on the model. It worked fine
but the code was ugly and not intuitive.
I then tried out your suggestion about adding a method to externally set values
for the OSD and the image.
It worked perfectly and is easy to use:
In poblesec/player_video.py I did the following:
In __init__ for the Player I added the following member variables:
self.external_small_image_path = None
self.external_background_image_path = None
self.external_title = None
self.external_details = None
self.external_details_2 = None
I also added a set-method to the Player:
def set_display_values(self, small_image_path, background_image_path,
title_label, details_label, details_2_label):
self.external_small_image_path = small_image_path
self.external_background_image_path = background_image_path
self.external_title = title_label
self.external_details = details_label
self.external_details_2 = details_2_label
In the PlayerController in method _player_status_cb I added an extra
else-clause at the poster-stuff:
poster = None
.........
elif isinstance(model, TVEpisode):
try:
poster = model.thumbnail_path
except AttributeError:
poster = None
else:
got_artwork(poster)
def got_tvshow(tvshow, season):
osd_details.details.label = tvshow.name
season_txt = _("Season %s") % season.number
osd_details.details_2.label = season_txt
def got_season(season):
dfr = season.tvshow
dfr.addCallback(got_tvshow, season)
return dfr
osd_details.title.label = "%s. %s" % (model.number,
model.name)
dfr = model.season
dfr.addCallback(got_season)
# begin - my code
else:
if self.player.external_small_image_path is not None:
poster = self.player.external_small_image_path
# if self.player.external_background_image_path is not None:
# = self.player.external_background_image_path
if self.player.external_title is not None:
osd_details.title.label = self.player.external_title
if self.player.external_details is not None:
osd_details.details.label = self.player.external_details
if self.player.external_details_2 is not None:
osd_details.details_2.label =
self.player.external_details_2
# end - my code
if poster is not None:
got_artwork(poster)
else:
self.player_osd.cover_overlay.cover.clear()
icon =
'elisa.plugins.poblesec.player.thumbnail.default_movie'
self.frontend.load_from_theme \
(icon, self.player_osd.status.preview)
if status == player.PLAYING:
In my own plugin-controller I call set_display_values before setting my stream
for playback, like:
player.player.set_display_values(station.resource, None,
station.title, station.description, None)
player.player.play_model(station)
There might be some issues regarding other plugins not reseting all the values
Now that I have a possible solution, what happens now?
Best Regards,
Kristian Lippert
> Date: Tue, 17 Mar 2009 12:07:34 +0100
> From: [email protected]
> To: [email protected]
> CC: [email protected]; [email protected]
> Subject: Re: [Elisa] My weekly cry for help:-) How to put image in player
>
> Hi Kristian,
>
> I got confronted to the same problem some time ago when writing a plugin
> for a webradio. With only one stream, the artwork is never going to
> change even if some new metadata is available from the plugin. Well not
> without a lot of dirty hacks anyway.
>
> One quick and relatively easy change to the player I would suggest is a
> set of public method for setting (getting as well?) the current metadata
> as displayed by the OSD. That would allow external plugins to easily
> interact with the player. I'm mentioning the OSD but of course that
> could be extended to the background image of the player, if that's what
> you need. This kind of change shouldn't require too much work and remain
> relatively safe.
>
> I hope this helps.
>
> Olivier
>
>
> Kristian Lippert a écrit :
> > Hi Guillaume
> > I had a feeling that it was going in that direction :-( -
> >
> > So - I had a quick glance at _player_status_cb()
> > It looks like a lot logic is bound to types (models) already known by elisa.
> > If we want to refactor this the model for the plugin must either inherit
> > from a well-defined class that knows about covers/images or do some sort
> > of "duck-typing" (taste the present model and see if it has some sort of
> > attribute resembling an image/cover.
> > The first will affect a lot of existing code, while the second will be a
> > extra clause (simple I hope - but I might have misunderstood something)
> >
> > I tried to put a pdb.set_trace() in _player_status_cb() to how it
> > behaves in the database-plugin-case and in my custom-plugin-case - but
> > it does not seem to affect the program execution
> > I have a development version (0.5.29 + 0.5.31) and the official release
> > (0.5.27 + 0.5.31) installed on my ubuntu 8.10
> > I tried to put the set_trace both places but nothing happened.
> >
> > Removing
> > /usr/lib/python2.5/site-packages/elisa/plugins/poblesec/player_video.pyc
> > will not generate a new pyc-file when running elisa and it is the only
> > player_video.pyc file I could find on my Ubuntu-box
> >
> > Is there another binary version of the files in my filesystem in some
> > precompiled-python-files (I do not know much about python)
> >
> > Please advice on how to debug (put in a pdb.set_trace()) in the
> > player_video.py-code.
> >
> > Best Regards,
> > Kristian Lippert
> >
> >
> >> Date: Thu, 12 Mar 2009 22:05:40 +0100
> >> From: [email protected]
> >> To: [email protected]
> >> CC: [email protected]
> >> Subject: Re: [Elisa] My weekly cry for help:-) How to put image in player
> >>
> >> Hi Kristian,
> >>
> >> Thanks for your interest in Elisa, and on hacking for Elisa!
> >>
> >> I'm very sorry nobody has answered that question yet, but the thing is:
> >> it's a tricky one.
> >> The problem is that the present architecture of the player does not
> >> allow for a lot of control from plugins. For now, the displaying of
> >> these images, as well as a lot of other things that should be specific
> >> to some plugins, is handled entirely in the player.
> >> To make it possible to put an image in the background of the player from
> >> a plugin, we would need to do quite some refactoring work in the
> >> PlayerController (in poblesec/player_video.py; yes, the file is called
> >> player_video, but that's what's used for music as well), and in
> >> particualr in its (huge) _player_status_cb() method. I don't know if
> >> anyone has planned to do such a thing, but reworking the player is
> >> definitely something we should do sooner than later, right now, it's
> >> next to properly interact with it from a plugin...
> >>
> >> So, in a nutshell, if you haven't figured out how to do it, and if
> >> nobody was able to tell you how to do it, that's simply because it's not
> >> possible.
> >> Of course, if you have time to spend working on that (non trivial) task
> >> of refactoring the player, we would be happy to advise you and to review
> >> a patch.
> >>
> >> Guillaume
> >>
> >> On 21:44 Thu 12 Mar , Kristian Lippert wrote:
> >> >
> >> > Hi
> >> >
> >> > Here is my weekly cry for help:
> >> >
> >> > I still havn't figured out how to put an image in the player when
> > using a custom plugin
> >> >
> >> > Could any with knowledge of the player or the database plugin please
> > help me!
> >> >
> >> > At least point me to some code I can look at.
> >> >
> >> >
> >> >
> >> > Best Regards,
> >> >
> >> > Kristian Lippert
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces.
It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us