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



commit b4d52dab8e76762b22edb4065a9f1cccf4231c82
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. At least it does not work with current mpris implementation.
    Change it to second to make it consistend 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 a3c1d44d..0296ca63 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -818,6 +818,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
@@ -827,8 +834,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]