[gnome-music/wip/jfelder/player-loading-state: 25/25] gstplayer: Introduce loading state
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/player-loading-state: 25/25] gstplayer: Introduce loading state
- Date: Wed, 22 Aug 2018 09:28:32 +0000 (UTC)
commit a7c0180ce439c7efba0fbe6e5c31836f6bf85c38
Author: Jean Felder <jfelder src gnome org>
Date: Thu Aug 16 18:32:23 2018 +0200
gstplayer: Introduce loading state
With player's latest reworks (mainly commit d83b7de3), the player now
does not need to be stopped to load a new song.
Introduce a LOADING Playback status to describe this new state.
This simplifies InhibitSuspend checks.
gnomemusic/gstplayer.py | 7 +++++--
gnomemusic/inhibitsuspend.py | 11 +++--------
gnomemusic/player.py | 2 +-
3 files changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/gnomemusic/gstplayer.py b/gnomemusic/gstplayer.py
index 08a038bc..13dcb920 100644
--- a/gnomemusic/gstplayer.py
+++ b/gnomemusic/gstplayer.py
@@ -42,8 +42,9 @@ playlists = Playlists.get_default()
class Playback(IntEnum):
"""Playback status enumerator"""
STOPPED = 0
- PAUSED = 1
- PLAYING = 2
+ LOADING = 1
+ PAUSED = 2
+ PLAYING = 3
class GstPlayer(GObject.GObject):
@@ -224,6 +225,8 @@ class GstPlayer(GObject.GObject):
self._player.set_state(Gst.State.PAUSED)
if state == Playback.STOPPED:
self._player.set_state(Gst.State.NULL)
+ if state == Playback.LOADING:
+ self._player.set_state(Gst.State.READY)
if state == Playback.PLAYING:
self._player.set_state(Gst.State.PLAYING)
diff --git a/gnomemusic/inhibitsuspend.py b/gnomemusic/inhibitsuspend.py
index daf69aba..b6fc9d03 100644
--- a/gnomemusic/inhibitsuspend.py
+++ b/gnomemusic/inhibitsuspend.py
@@ -83,15 +83,10 @@ class InhibitSuspend(GObject.GObject):
@log
def _on_playback_status_changed(self, arguments):
- if self._player.get_playback_status() == Playback.PLAYING:
+ if (self._player.get_playback_status() == Playback.PLAYING
+ or self._player.get_playback_status() == Playback.LOADING):
self._inhibit_suspend()
- # TODO: The additional check for has_next property is necessary
- # since after a track is done, the player
- # goes into STOPPED state before it goes back to PLAYING.
- # To be simplified when the player's behavior is corrected.
-
if (self._player.get_playback_status() == Playback.PAUSED
- or (self._player.get_playback_status() == Playback.STOPPED
- and not self._player.props.has_next)):
+ or self._player.get_playback_status() == Playback.STOPPED):
self._uninhibit_suspend()
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 64c8256e..c26cb20f 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -561,6 +561,7 @@ class Player(GObject.GObject):
@log
def _load(self, song):
+ self._player.state = Playback.LOADING
self._time_stamp = int(time.time())
url_ = song.get_url()
@@ -592,7 +593,6 @@ class Player(GObject.GObject):
return False
if self._player.state != Playback.PAUSED:
- self.stop()
self._load(self._playlist.props.current_song)
self._player.state = Playback.PLAYING
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]