Vladimir Kolev avatar Vladimir Kolev committed 7469e21

Fix for the playing issues. EOS is never tracked, on_stopped now calls play_next no metter what, the play/stop buttons are not handeled with a message_cb function. The notification has a small timeout.

Comments (0)

Files changed (2)

                 n = pynotify.Notification(_("Now playing"),
                     "%s - %s" % (song['ArtistName'], song['SongName']),
                     "audio-x-generic")
+                n.set_timeout(50)
                 n.show()
         else:
             self.staticon.set_from_file("%s/data/gsharkdown_16.png" % BASEPATH)
                                key["result"]["%s" % self.songid]["streamKey"])
         self.win.player.set_property('uri', play_url)
         self.win.player.set_state(gst.STATE_PLAYING)
+        self.win.play_button.set_stock_id(gtk.STOCK_MEDIA_STOP)
         if self.lastfm != "":
             if self.win.scrobbled == 0:
                 self.lastfm.scrobble(self.song['ArtistName'],
         bus = self.win.player.get_bus()
         bus.enable_sync_message_emission()
         bus.add_signal_watch()
-        bus.connect("message", self.on_message_cb)
+# I will leave this commented out just till it's confirmed that
+# it's not needed anymore.
+#        bus.connect("message", self.on_message_cb)
         bus.connect('message::eos', self.on_stopped)
 
-    def on_message_cb(self, bus, message):
-        if message.type == gst.MESSAGE_STATE_CHANGED:
-            old, new, pending = message.parse_state_changed()
-            self.update_buttons(new)
-        return gst.BUS_PASS
+#    def on_message_cb(self, bus, message):
+#        if message.type == gst.MESSAGE_STATE_CHANGED:
+#            old, new, pending = message.parse_state_changed()
+#            self.update_buttons(new)
+#        return gst.BUS_PASS
 
     def on_stopped(self, config, widget=None, data=None):
-        if self.repeat == 1:
-            self.win.play_next(self.win.ff_button)
-        else:
-            self.win.play_button.set_stock_id(gtk.STOCK_MEDIA_PLAY)
-            self.win.staticon.set_from_file("%s/data/gsharkdown_16.png" % basepath)
-            self.win.staticon.set_tooltip(_("gSharkDown : Grooveshark Downloader"))
+        """
+        Called when the player reaches the end of the stream
+        sets state gst.STATE_NULL and calls the play_next 
+        method.
+        """
+        self.win.player.set_state(gst.STATE_NULL)
+        self.win.play_button.set_stock_id(gtk.STOCK_MEDIA_STOP)
+        self.win.play_next(self.win.ff_button)
 
-    def update_buttons(self, state):
-        if state == gst.STATE_NULL:
-            self.win.play_button.set_stock_id(gtk.STOCK_MEDIA_PLAY)
-        else:
-            self.win.play_button.set_stock_id(gtk.STOCK_MEDIA_STOP)
+#    def update_buttons(self, state):
+#        if state == gst.STATE_NULL:
+#            self.win.play_button.set_stock_id(gtk.STOCK_MEDIA_PLAY)
+#        else:
+#            self.win.play_button.set_stock_id(gtk.STOCK_MEDIA_STOP)
+            
 
 class t_key_listener(threading.Thread):
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.