mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 00:11:59 +02:00
Update video info during non-local file playback
With this player will always show current video resolution when playing fragmented media like HLS or MPD online videos
This commit is contained in:
8
clapper_src/controls.js
vendored
8
clapper_src/controls.js
vendored
@@ -71,13 +71,9 @@ var Controls = GObject.registerClass({
|
|||||||
|
|
||||||
setLiveMode(isLive, isSeekable)
|
setLiveMode(isLive, isSeekable)
|
||||||
{
|
{
|
||||||
/* This update must always happen
|
if(isLive)
|
||||||
* after media duration is set */
|
this.elapsedButton.set_label('LIVE');
|
||||||
let text = (isLive)
|
|
||||||
? 'LIVE'
|
|
||||||
: '00:00:00' + '/' + this.durationFormated;
|
|
||||||
|
|
||||||
this.elapsedButton.set_label(text);
|
|
||||||
this.positionScale.visible = isSeekable;
|
this.positionScale.visible = isSeekable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@ class ClapperInterface extends Gtk.Grid
|
|||||||
this.needsTracksUpdate = true;
|
this.needsTracksUpdate = true;
|
||||||
this.headerBar = null;
|
this.headerBar = null;
|
||||||
this.defaultTitle = null;
|
this.defaultTitle = null;
|
||||||
|
this.mediaInfoSignal = null;
|
||||||
|
|
||||||
this.videoBox = new Gtk.Box();
|
this.videoBox = new Gtk.Box();
|
||||||
this.overlay = new Gtk.Overlay();
|
this.overlay = new Gtk.Overlay();
|
||||||
@@ -124,9 +125,9 @@ class ClapperInterface extends Gtk.Grid
|
|||||||
debug(`interface in fullscreen mode: ${isFullscreen}`);
|
debug(`interface in fullscreen mode: ${isFullscreen}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMediaTracks()
|
_onMediaInfoUpdated(player, mediaInfo)
|
||||||
{
|
{
|
||||||
let mediaInfo = this._player.get_media_info();
|
this._player.disconnect(this.mediaInfoSignal);
|
||||||
|
|
||||||
/* Set titlebar media title and path */
|
/* Set titlebar media title and path */
|
||||||
this.updateTitles(mediaInfo);
|
this.updateTitles(mediaInfo);
|
||||||
@@ -223,6 +224,8 @@ class ClapperInterface extends Gtk.Grid
|
|||||||
this.controls[`${type}TracksButton`].show();
|
this.controls[`${type}TracksButton`].show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.mediaInfoSignal = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTitles(mediaInfo)
|
updateTitles(mediaInfo)
|
||||||
@@ -345,17 +348,26 @@ class ClapperInterface extends Gtk.Grid
|
|||||||
{
|
{
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case GstPlayer.PlayerState.BUFFERING:
|
case GstPlayer.PlayerState.BUFFERING:
|
||||||
|
if(!this._player.isLocalFile)
|
||||||
|
this.needsTracksUpdate = true;
|
||||||
break;
|
break;
|
||||||
case GstPlayer.PlayerState.STOPPED:
|
case GstPlayer.PlayerState.STOPPED:
|
||||||
this.needsTracksUpdate = true;
|
this.needsTracksUpdate = true;
|
||||||
|
if(this.mediaInfoSignal) {
|
||||||
|
this._player.disconnect(this.mediaInfoSignal);
|
||||||
|
this.mediaInfoSignal = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case GstPlayer.PlayerState.PAUSED:
|
case GstPlayer.PlayerState.PAUSED:
|
||||||
this.controls.togglePlayButton.setPrimaryIcon();
|
this.controls.togglePlayButton.setPrimaryIcon();
|
||||||
break;
|
break;
|
||||||
case GstPlayer.PlayerState.PLAYING:
|
case GstPlayer.PlayerState.PLAYING:
|
||||||
this.controls.togglePlayButton.setSecondaryIcon();
|
this.controls.togglePlayButton.setSecondaryIcon();
|
||||||
if(this.needsTracksUpdate) {
|
if(this.needsTracksUpdate && !this.mediaInfoSignal) {
|
||||||
this.needsTracksUpdate = false;
|
this.needsTracksUpdate = false;
|
||||||
this.updateMediaTracks();
|
this.mediaInfoSignal = this._player.connect(
|
||||||
|
'media_info_updated', this._onMediaInfoUpdated.bind(this)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -365,7 +377,7 @@ class ClapperInterface extends Gtk.Grid
|
|||||||
|
|
||||||
_onPlayerDurationChanged(player)
|
_onPlayerDurationChanged(player)
|
||||||
{
|
{
|
||||||
let duration = player.get_duration() / 1000000000;
|
let duration = this._player.get_duration() / 1000000000;
|
||||||
let increment = (duration < 1)
|
let increment = (duration < 1)
|
||||||
? 0
|
? 0
|
||||||
: (duration < 100)
|
: (duration < 100)
|
||||||
|
@@ -51,6 +51,7 @@ 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._playerSignals = [];
|
this._playerSignals = [];
|
||||||
this._widgetSignals = [];
|
this._widgetSignals = [];
|
||||||
@@ -115,8 +116,10 @@ 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;
|
||||||
return this.set_uri(source);
|
return this.set_uri(source);
|
||||||
|
}
|
||||||
|
|
||||||
let file = Gio.file_new_for_uri(source);
|
let file = Gio.file_new_for_uri(source);
|
||||||
|
|
||||||
@@ -133,6 +136,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.set_uri(source);
|
this.set_uri(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,12 +234,18 @@ class ClapperPlayer extends GstPlayer.Player
|
|||||||
|
|
||||||
connect(signal, fn)
|
connect(signal, fn)
|
||||||
{
|
{
|
||||||
this._playerSignals.push(super.connect(signal, fn));
|
let connection = super.connect(signal, fn);
|
||||||
|
this._playerSignals.push(connection);
|
||||||
|
|
||||||
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
connectWidget(signal, fn)
|
connectWidget(signal, fn)
|
||||||
{
|
{
|
||||||
this._widgetSignals.push(this.widget.connect(signal, fn));
|
let connection = this.widget.connect(signal, fn);
|
||||||
|
this._widgetSignals.push(connection);
|
||||||
|
|
||||||
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onStateChanged(player, state)
|
_onStateChanged(player, state)
|
||||||
|
Reference in New Issue
Block a user