[gnome-music/wip/jfelder/smoothscale-player: 2/5] player: Use second unit to set position



commit 15e921fe708c400cb17b0f2aa0b465bb8131faec
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Oct 10 08:53:25 2018 +0200

    player: Use second unit to set position
    
    Current position requested unit seems to microsecond but it's not
    clear. It clearly does not work with current mpris implementation.
    Change it to second to make it consistent with get_position method
    wich returns a position in seconds.
    
    Mpris seek methods still need additional work to work reliably.

 gnomemusic/player.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 1557e700..e99f6b13 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -815,6 +815,13 @@ class Player(GObject.GObject):
     # TODO: used by MPRIS
     @log
     def set_position(self, offset, start_if_ne=False, next_on_overflow=False):
+        """Change GstPlayer position.
+
+        :param int offset: requested position in second
+        :param bool start_if_ne: if position is negative, set it to zero
+        :param bool next_on_overflow: next song if position is greater than
+                                      duration
+        """
         if offset < 0:
             if start_if_ne:
                 offset = 0
@@ -824,8 +831,8 @@ class Player(GObject.GObject):
         if self.props.duration == -1.:
             return
 
-        if self.props.duration >= offset * 1000:
-            self._player.seek(offset * 1000)
+        if self.props.duration >= offset:
+            self._player.seek(offset)
             self.emit('seeked', offset)
         elif next_on_overflow:
             self.next()


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