[gnome-music/wip/mschraal/player-factor-out-gstreamer: 15/42] use state property changed signal
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/player-factor-out-gstreamer: 15/42] use state property changed signal
- Date: Fri, 9 Feb 2018 20:54:03 +0000 (UTC)
commit 5385fd5420c857cae5c2b82d6d98e0cf4b9bb563
Author: Marinus Schraal <mschraal gnome org>
Date: Fri Feb 9 09:52:14 2018 +0100
use state property changed signal
gnomemusic/gstplayer.py | 6 +-----
gnomemusic/player.py | 7 ++++++-
2 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/gnomemusic/gstplayer.py b/gnomemusic/gstplayer.py
index 0b6986a..8a2b5ee 100644
--- a/gnomemusic/gstplayer.py
+++ b/gnomemusic/gstplayer.py
@@ -52,15 +52,13 @@ class GstPlayer(GObject.GObject):
}
@log
- def __init__(self, player):
+ def __init__(self):
super().__init__()
Gst.init(None)
self._settings = Gio.Settings.new('org.gnome.Music')
- self._super_player = player
-
self._player = Gst.ElementFactory.make('playbin', 'player')
self._bus = self._player.get_bus()
self._bus.add_signal_watch()
@@ -136,8 +134,6 @@ class GstPlayer(GObject.GObject):
# message. In practice, self means only Gst.State.PLAYING and
# Gst.State.PAUSED are.
self.state = self.state
- self._super_player._sync_playing()
-
@log
def _on_bus_element(self, bus, message):
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index b9ba3f7..96768c0 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -120,8 +120,9 @@ class Player(GObject.GObject):
self.playlist_insert_handler = 0
self.playlist_delete_handler = 0
- self._player = GstPlayer(self)
+ self._player = GstPlayer()
self._player.connect('eos', self._on_eos)
+ self._player.connect('notify::state', self._on_state_change)
self._lastfm = LastFmScrobbler()
@@ -311,6 +312,10 @@ class Player(GObject.GObject):
def playing(self):
return self._player.is_playing()
+ @log
+ def _on_state_change(self, klass, arguments):
+ self._sync_playing()
+
@log
def _sync_playing(self):
if self._player.is_playing():
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]