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



commit 87576d801cfeed3e20c74028cbc953191a6605d8
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 766bb919..2bc11c3f 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -817,6 +817,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
@@ -826,8 +833,8 @@ class Player(GObject.GObject):
         if self.props.duration == 0:
             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]