[gnome-music/wip/jfelder/gstplayer-disable-about-to-finish-http-files: 2/3] gstplayer: Handle buffering
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/gstplayer-disable-about-to-finish-http-files: 2/3] gstplayer: Handle buffering
- Date: Fri, 29 May 2020 20:08:22 +0000 (UTC)
commit 34f9549dca439bc3aecd73b6bbbd053a9618f898
Author: Jean Felder <jfelder src gnome org>
Date: Wed May 27 01:10:40 2020 +0200
gstplayer: Handle buffering
When percent is smaller than 100, the pipeline is buffering. In that
case, the pipeline needs to be in the PAUSED state. Once the buffering
is complete, the pipeline can switch to the PLAYING state.
See
https://gstreamer.freedesktop.org/documentation/application-development/advanced/buffering.html
Closes: #350
gnomemusic/gstplayer.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/gnomemusic/gstplayer.py b/gnomemusic/gstplayer.py
index 5cff75ab..8b8b61af 100644
--- a/gnomemusic/gstplayer.py
+++ b/gnomemusic/gstplayer.py
@@ -63,6 +63,7 @@ class GstPlayer(GObject.GObject):
Gst.init(None)
self._application = application
+ self._buffering = False
self._duration = -1.
self._log = application.props.log
self._seek = False
@@ -82,6 +83,7 @@ class GstPlayer(GObject.GObject):
None, self._settings.get_value('replaygain'))
self._bus.connect('message::async-done', self._on_async_done)
+ self._bus.connect("message::buffering", self._on_bus_buffering)
self._bus.connect('message::error', self._on_bus_error)
self._bus.connect('message::element', self._on_bus_element)
self._bus.connect('message::eos', self._on_bus_eos)
@@ -153,6 +155,17 @@ class GstPlayer(GObject.GObject):
if GstPbutils.is_missing_plugin_message(message):
self._missing_plugin_messages.append(message)
+ def _on_bus_buffering(self, bus, message):
+ percent = message.parse_buffering()
+
+ if (percent < 100
+ and not self._buffering):
+ self._buffering = True
+ self.props.state = Playback.PAUSED
+ elif percent == 100:
+ self._buffering = False
+ self.props.state = Playback.PLAYING
+
def _on_bus_stream_start(self, bus, message):
def delayed_query():
self._on_async_done(None, None)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]