Add player seek_done property

This commit is contained in:
Rafostar
2020-10-16 13:24:18 +02:00
parent eafc65d15d
commit 8297be45ba
2 changed files with 27 additions and 10 deletions

View File

@@ -345,7 +345,7 @@ class ClapperInterface extends Gtk.Grid
{
switch(state) {
case GstPlayer.PlayerState.BUFFERING:
if(!this._player.isLocalFile)
if(!this._player.is_local_file)
this.needsTracksUpdate = true;
break;
case GstPlayer.PlayerState.STOPPED:
@@ -395,6 +395,7 @@ class ClapperInterface extends Gtk.Grid
{
if(
!this.isSeekable
|| !this._player.seek_done
|| this.controls.isPositionSeeking
|| this._player.state === GstPlayer.PlayerState.BUFFERING
)

View File

@@ -51,7 +51,8 @@ class ClapperPlayer extends GstPlayer.Player
this.renderer = renderer;
this.gstRegistry = Gst.Registry.get();
this.isLocalFile = false;
this.is_local_file = false;
this.seek_done = true;
this._playerSignals = [];
this._widgetSignals = [];
@@ -100,6 +101,7 @@ class ClapperPlayer extends GstPlayer.Player
this.connect('state-changed', this._onStateChanged.bind(this));
this.connect('uri-loaded', this._onUriLoaded.bind(this));
this.connect('seek-done', this._onSeekDone.bind(this));
this.connect('end-of-stream', this._onStreamEnded.bind(this));
this.connect('warning', this._onPlayerWarning.bind(this));
this.connect('error', this._onPlayerError.bind(this));
@@ -117,7 +119,7 @@ class ClapperPlayer extends GstPlayer.Player
debug(`parsed source to URI: ${source}`);
if(Gst.Uri.get_protocol(source) !== 'file') {
this.isLocalFile = false;
this.is_local_file = false;
return this.set_uri(source);
}
@@ -136,7 +138,7 @@ class ClapperPlayer extends GstPlayer.Player
if(file.get_path().endsWith(`.${this.playlist_ext}`))
return this.load_playlist_file(file);
this.isLocalFile = true;
this.is_local_file = true;
this.set_uri(source);
}
@@ -198,6 +200,13 @@ class ClapperPlayer extends GstPlayer.Player
return this.visualization_enabled;
}
seek(position)
{
this.seek_done = false;
super.seek(position);
}
seek_seconds(position)
{
this.seek(position * 1000000000);
@@ -252,13 +261,20 @@ class ClapperPlayer extends GstPlayer.Player
{
this.state = state;
if(this.state === GstPlayer.PlayerState.STOPPED) {
this.seek_done = true;
if(
this.run_loop
&& this.state === GstPlayer.PlayerState.STOPPED
&& this.loop.is_running()
)
this.loop.quit();
}
}
_onSeekDone()
{
this.seek_done = true;
}
_onStreamEnded(player)
{