From 6d3428ca9e901b0fa633f219ff2da3ca804fbff6 Mon Sep 17 00:00:00 2001 From: Kushal Das Date: Fri, 3 Oct 2008 14:57:33 +0530 Subject: Now next and previous buttons are working , only problem is to set default play/pause button --- ControlToolbar.py | 27 +++++++++++++++++++++++++++ jukeboxactivity.py | 22 +++++++++++++++++----- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/ControlToolbar.py b/ControlToolbar.py index 1069c72..8cbaa42 100644 --- a/ControlToolbar.py +++ b/ControlToolbar.py @@ -42,6 +42,17 @@ class ControlToolbar(gtk.Toolbar): gtk.Toolbar.__init__(self) self.toolbox = toolbox self.jukebox = jukebox + self.prev_image = gtk.image_new_from_stock(gtk.STOCK_MEDIA_PREVIOUS, + gtk.ICON_SIZE_BUTTON) + self.prev_image.show() + + self.prev_button = gtk.ToolButton() + self.prev_button.set_icon_widget(self.prev_image) + self.prev_button.show() + self.prev_button.connect('clicked', self.prev_button_clicked_cb) + + self.insert(self.prev_button, -1) + self.pause_image = gtk.image_new_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_BUTTON) @@ -57,6 +68,17 @@ class ControlToolbar(gtk.Toolbar): self.button.connect('clicked', self._button_clicked_cb) self.insert(self.button, -1) + self.next_image = gtk.image_new_from_stock(gtk.STOCK_MEDIA_NEXT, + gtk.ICON_SIZE_BUTTON) + self.next_image.show() + + self.next_button = gtk.ToolButton() + self.next_button.set_icon_widget(self.next_image) + self.next_button.show() + self.next_button.connect('clicked', self.next_button_clicked_cb) + + self.insert(self.next_button, -1) + self.adjustment = gtk.Adjustment(0.0, 0.00, 100.0, 0.1, 1.0, 1.0) self.hscale = gtk.HScale(self.adjustment) @@ -93,7 +115,12 @@ class ControlToolbar(gtk.Toolbar): self._fullscreen.connect('clicked', self._fullscreen_cb) self.insert(self._fullscreen, -1) self._fullscreen.show() + + def prev_button_clicked_cb(self,widget): + self.jukebox.songchange('prev') + def next_button_clicked_cb(self,widget): + self.jukebox.songchange('next') def _button_clicked_cb(self, widget): self.jukebox.play_toggled() diff --git a/jukeboxactivity.py b/jukeboxactivity.py index 565aa2e..fbb4e60 100755 --- a/jukeboxactivity.py +++ b/jukeboxactivity.py @@ -114,11 +114,23 @@ class JukeboxActivity(activity.Activity): pass def songchange(self,direction): - if self.playflag: - self.playflag = False - return + #if self.playflag: + # self.playflag = False + # return self.player.seek(0L) - if direction == "next" and self.currentplaying < len(self.playlist) - 1: + if direction == "prev" and self.currentplaying > 0: + self.currentplaying -= 1 + self.player.stop() + self.player = GstPlayer(self.videowidget) + self.player.connect("error", self._player_error_cb) + self.player.connect("tag", self._player_new_tag_cb) + self.player.connect("stream-info", self._player_stream_info_cb) + self.player.set_uri(self.playlist[self.currentplaying]) + logging.info("prev: " + self.playlist[self.currentplaying]) + #self.playflag = True + self.play_toggled() + self.player.connect("eos", self._player_eos_cb) + elif direction == "next" and self.currentplaying < len(self.playlist) - 1: self.currentplaying += 1 self.player.stop() self.player = GstPlayer(self.videowidget) @@ -127,7 +139,7 @@ class JukeboxActivity(activity.Activity): self.player.connect("stream-info", self._player_stream_info_cb) self.player.set_uri(self.playlist[self.currentplaying]) logging.info("NExt: " + self.playlist[self.currentplaying]) - self.playflag = True + #self.playflag = True self.play_toggled() self.player.connect("eos", self._player_eos_cb) else: -- cgit