[gnome-music/wip/mschraal/player-factor-out-gstreamer] gstplayer: Be more reliable about duration
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/player-factor-out-gstreamer] gstplayer: Be more reliable about duration
- Date: Sun, 18 Feb 2018 15:53:02 +0000 (UTC)
commit 99977225530d1704e6c40945d7505f09c1f9eebb
Author: Marinus Schraal <mschraal gnome org>
Date: Sat Feb 17 20:44:10 2018 +0100
gstplayer: Be more reliable about duration
gnomemusic/gstplayer.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/gstplayer.py b/gnomemusic/gstplayer.py
index 55a3cf9..e38ec82 100644
--- a/gnomemusic/gstplayer.py
+++ b/gnomemusic/gstplayer.py
@@ -227,10 +227,17 @@ class GstPlayer(GObject.GObject):
@log
def duration(self):
"""Total duration in seconds (float)"""
- if self._duration == None:
- self._duration = self._player.query_duration(
- Gst.Format.TIME)[1] / 10**9
- print("duration ", self._duration)
+ if self.state == Playback.STOPPED:
+ return None
+
+ success, duration = self._player.query_duration(
+ Gst.Format.TIME)
+
+ if success:
+ self._duration = duration / 10**9
+ else:
+ self._duration = None
+
return self._duration
@GObject.Property
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]