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

View File

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