[gnome-music: 1/4] player: Add new method get_current_media()



commit f5334aada61701502a24619c446f99a892890084
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Mon Aug 5 23:35:19 2013 +0800

    player: Add new method get_current_media()

 gnomemusic/player.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 8cc3f20..c16ab25 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -78,7 +78,7 @@ class Player(GObject.GObject):
         self.emit('playing-changed')
 
     def _onBusError(self, bus, message):
-        media = self.playlist.get_value(self.currentTrack, self.playlistField)
+        media = self.get_current_media()
         if media is not None:
             uri = media.get_url()
         else:
@@ -105,7 +105,7 @@ class Player(GObject.GObject):
             self.progressScale.set_sensitive(False)
             if self.playlist is not None:
                 self.currentTrack = self.playlist.get_iter_first()
-                self.load(self.playlist.get_value(self.currentTrack, self.playlistField))
+                self.load(self.get_current_media())
         else:
             #Stop playback
             self.stop()
@@ -213,7 +213,7 @@ class Player(GObject.GObject):
         else:
             self.pause()
 
-        media = self.playlist.get_value(self.currentTrack, self.playlistField)
+        media = self.get_current_media()
         self.playBtn.set_image(self._pauseImage)
         return media
 
@@ -253,7 +253,7 @@ class Player(GObject.GObject):
         if self.player.get_state(1)[1] != Gst.State.PAUSED:
             self.stop()
 
-        self.load(self.playlist.get_value(self.currentTrack, self.playlistField))
+        self.load(self.get_current_media())
 
         self.player.set_state(Gst.State.PLAYING)
         self._update_position_callback()
@@ -535,6 +535,11 @@ class Player(GObject.GObject):
         self.player.set_volume(GstAudio.StreamVolumeFormat.LINEAR, rate)
         self.emit('volume-changed')
 
+    def get_current_media(self):
+        if not self.currentTrack:
+            return None
+        return self.playlist.get_value(self.currentTrack, self.playlistField)
+
 
 class SelectionToolbar():
     def __init__(self):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]