+#!/usr/bin/env python
+#
+# This file is part of Jamaendo.
+# Copyright (c) 2010 Kristoffer Gronlund
+#
+# Jamaendo is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Jamaendo is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Jamaendo. If not, see <http://www.gnu.org/licenses/>.
+#
+# Player code heavily based on http://thpinfo.com/2008/panucci/:
+# A resuming media player for Podcasts and Audiobooks
+# Copyright (c) 2008-05-26 Thomas Perl <thpinfo.com>
+# (based on http://pygstdocs.berlios.de/pygst-tutorial/seeking.html)
+#
import gtk
import hildon
-import jamaendo
from settings import settings
+from postoffice import postoffice
from player import Playlist, the_player
class PlayerWindow(hildon.StackableWindow):
hildon.StackableWindow.__init__(self)
self.set_title("jamaendo")
- self.connect('hide', self.on_hide)
self.connect('destroy', self.on_destroy)
self.playlist = Playlist(playlist)
hbox = gtk.HBox()
self.cover = gtk.Image()
- self.cover.set_size_request(200, 200)
self.cover.set_from_stock(gtk.STOCK_CDROM, gtk.ICON_SIZE_DIALOG)
vbox2 = gtk.VBox()
hbox.pack_start(self.volume, False)
self.add(vbox)
+ postoffice.connect('album-cover', self.set_album_cover)
+
print "Created player window, playlist: %s" % (self.playlist)
- def on_hide(self, wnd):
- print "Hiding player window"
+ def get_album_id(self):
+ if self.playlist and self.playlist.current_index() > -1:
+ return self.playlist.current().album_id
+ return None
def on_destroy(self, wnd):
- print "Destroying player window"
- if self.player:
- self.player.stop()
+ postoffice.disconnect('album-cover', self.set_album_cover)
def add_stock_button(self, btns, stock, cb):
btn = hildon.GtkButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
print "current:", item
self.set_labels(item.name, item.artist_name, item.album_name,
self.playlist.current_index(), self.playlist.size())
- coverfile = jamaendo.get_album_cover(int(item.album_id), size=200)
- print "coverfile:", coverfile
- self.cover.set_from_file(coverfile)
+ postoffice.notify('request-album-cover', int(item.album_id), 300)
+ #jamaendo.get_album_cover_async(album_cover_receiver, int(item.album_id), size=200)
+ #coverfile = jamaendo.get_album_cover(int(item.album_id), size=200)
+ #print "coverfile:", coverfile
+ #self.cover.set_from_file(coverfile)
+
+ def set_album_cover(self, albumid, size, cover):
+ if size == 300:
+ playing = self.get_album_id()
+ if int(playing) == int(albumid):
+ self.cover.set_from_file(cover)
def play_tracks(self, tracks):
self.playlist = Playlist(tracks)