[gnome-music/wip/mschraal/gapless-v3: 14/14] fix duration
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/gapless-v3: 14/14] fix duration
- Date: Sun, 21 Oct 2018 22:32:15 +0000 (UTC)
commit 1fd71703d532761e657cd5fdb8e8df3783f4e312
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Oct 17 15:38:05 2018 +0200
fix duration
sometimes a 0 duration is sent
gnomemusic/widgets/playertoolbar.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index 3bafbf23..4f131e64 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -83,6 +83,7 @@ class PlayerToolbar(Gtk.ActionBar):
self._player.connect('clock-tick', self._on_clock_tick)
self._player.connect('song-changed', self._update_view)
self._player.connect('prev-next-invalidated', self._sync_prev_next)
+ self._player.connect('notify::duration', self._on_duration_changed)
self._player.connect('notify::repeat-mode', self._sync_repeat_image)
self._player.connect('notify::state', self._sync_playing)
@@ -148,6 +149,14 @@ class PlayerToolbar(Gtk.ActionBar):
self._next_button.props.sensitive = self._player.props.has_next
self._prev_button.props.sensitive = self._player.props.has_previous
+ @log
+ def _on_duration_changed(self, klass, data=None):
+ duration = klass.props.duration
+
+ if duration != -1:
+ self._duration_label.set_label(
+ utils.seconds_to_string(int(duration)))
+
@log
def _update_view(self, player, position):
"""Updates model when the song changes
@@ -156,10 +165,6 @@ class PlayerToolbar(Gtk.ActionBar):
:param int position: current song position
"""
current_song = player.props.current_song
- duration = player.props.duration
- if duration != -1:
- self._duration_label.set_label(
- utils.seconds_to_string(int(duration)))
self._play_button.set_sensitive(True)
self._sync_prev_next()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]