mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 08:21:59 +02:00
Update media info on idle after playback starts. Fixes #32
This commit is contained in:
@@ -34,7 +34,6 @@ var Widget = GObject.registerClass({
|
|||||||
this.isSeekable = false;
|
this.isSeekable = false;
|
||||||
|
|
||||||
this.needsTracksUpdate = true;
|
this.needsTracksUpdate = true;
|
||||||
this.mediaInfoSignal = null;
|
|
||||||
|
|
||||||
this.overlay = new Gtk.Overlay();
|
this.overlay = new Gtk.Overlay();
|
||||||
this.revealerTop = new Revealers.RevealerTop();
|
this.revealerTop = new Revealers.RevealerTop();
|
||||||
@@ -199,10 +198,11 @@ var Widget = GObject.registerClass({
|
|||||||
this.controlsBox.set_visible(!isOnTop);
|
this.controlsBox.set_visible(!isOnTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onMediaInfoUpdated(player, mediaInfo)
|
_updateMediaInfo()
|
||||||
{
|
{
|
||||||
if(this.mediaInfoSignal)
|
let mediaInfo = this.player.get_media_info();
|
||||||
player.disconnect(this.mediaInfoSignal);
|
if(!mediaInfo)
|
||||||
|
return GLib.SOURCE_REMOVE;
|
||||||
|
|
||||||
/* Set titlebar media title and path */
|
/* Set titlebar media title and path */
|
||||||
this.updateTitles(mediaInfo);
|
this.updateTitles(mediaInfo);
|
||||||
@@ -242,13 +242,13 @@ var Widget = GObject.registerClass({
|
|||||||
codec.indexOf(')')
|
codec.indexOf(')')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
text = info.get_language() || 'Unknown';
|
text = info.get_language() || 'Undetermined';
|
||||||
text += ', ' + codec + ', '
|
text += ', ' + codec + ', '
|
||||||
+ info.get_channels() + ' Channels';
|
+ info.get_channels() + ' Channels';
|
||||||
break;
|
break;
|
||||||
case GstPlayer.PlayerSubtitleInfo:
|
case GstPlayer.PlayerSubtitleInfo:
|
||||||
type = 'subtitle';
|
type = 'subtitle';
|
||||||
text = info.get_language() || 'Unknown';
|
text = info.get_language() || 'Undetermined';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
debug(`unrecognized media info type: ${info.constructor}`);
|
debug(`unrecognized media info type: ${info.constructor}`);
|
||||||
@@ -273,7 +273,7 @@ var Widget = GObject.registerClass({
|
|||||||
let anyButtonShown = false;
|
let anyButtonShown = false;
|
||||||
|
|
||||||
for(let type of ['video', 'audio', 'subtitle']) {
|
for(let type of ['video', 'audio', 'subtitle']) {
|
||||||
let currStream = player[`get_current_${type}_track`]();
|
let currStream = this.player[`get_current_${type}_track`]();
|
||||||
let activeId = (currStream) ? currStream.get_index() : -1;
|
let activeId = (currStream) ? currStream.get_index() : -1;
|
||||||
|
|
||||||
if(currStream && type !== 'subtitle') {
|
if(currStream && type !== 'subtitle') {
|
||||||
@@ -300,9 +300,9 @@ var Widget = GObject.registerClass({
|
|||||||
|
|
||||||
anyButtonShown = true;
|
anyButtonShown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.controls.revealTracksRevealer.set_visible(anyButtonShown);
|
this.controls.revealTracksRevealer.set_visible(anyButtonShown);
|
||||||
this.mediaInfoSignal = null;
|
|
||||||
|
return GLib.SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTitles(mediaInfo)
|
updateTitles(mediaInfo)
|
||||||
@@ -402,10 +402,6 @@ var Widget = GObject.registerClass({
|
|||||||
this.controls.positionScale.set_value(0);
|
this.controls.positionScale.set_value(0);
|
||||||
this.controls.togglePlayButton.setPrimaryIcon();
|
this.controls.togglePlayButton.setPrimaryIcon();
|
||||||
this.needsTracksUpdate = true;
|
this.needsTracksUpdate = true;
|
||||||
if(this.mediaInfoSignal) {
|
|
||||||
player.disconnect(this.mediaInfoSignal);
|
|
||||||
this.mediaInfoSignal = null;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case GstPlayer.PlayerState.PAUSED:
|
case GstPlayer.PlayerState.PAUSED:
|
||||||
debug('player state changed to: PAUSED');
|
debug('player state changed to: PAUSED');
|
||||||
@@ -414,10 +410,11 @@ var Widget = GObject.registerClass({
|
|||||||
case GstPlayer.PlayerState.PLAYING:
|
case GstPlayer.PlayerState.PLAYING:
|
||||||
debug('player state changed to: PLAYING');
|
debug('player state changed to: PLAYING');
|
||||||
this.controls.togglePlayButton.setSecondaryIcon();
|
this.controls.togglePlayButton.setSecondaryIcon();
|
||||||
if(this.needsTracksUpdate && !this.mediaInfoSignal) {
|
if(this.needsTracksUpdate) {
|
||||||
this.needsTracksUpdate = false;
|
this.needsTracksUpdate = false;
|
||||||
this.mediaInfoSignal = player.connect(
|
GLib.idle_add(
|
||||||
'media-info-updated', this._onMediaInfoUpdated.bind(this)
|
GLib.PRIORITY_DEFAULT_IDLE,
|
||||||
|
this._updateMediaInfo.bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user