Port app to the new GstClapper API

This commit is contained in:
Rafał Dzięgiel
2021-01-27 22:07:17 +01:00
parent 08f86cf0cc
commit bee1889376
6 changed files with 40 additions and 40 deletions

View File

@@ -2,10 +2,10 @@ imports.gi.versions.Gdk = '4.0';
imports.gi.versions.Gtk = '4.0'; imports.gi.versions.Gtk = '4.0';
const { Gst } = imports.gi; const { Gst } = imports.gi;
const { App } = imports.src.app;
Gst.init(null); Gst.init(null);
const { App } = imports.src.app;
function main(argv) function main(argv)
{ {
new App().run(argv); new App().run(argv);

View File

@@ -1,4 +1,4 @@
const { Gio, GstAudio, GstPlayer, Gdk, Gtk } = imports.gi; const { Gio, GstAudio, GstClapper, Gdk, Gtk } = imports.gi;
const Debug = imports.src.debug; const Debug = imports.src.debug;
const { debug } = Debug; const { debug } = Debug;
@@ -52,7 +52,7 @@ function inhibitForState(state, window)
{ {
let isInhibited = false; let isInhibited = false;
if(state === GstPlayer.PlayerState.PLAYING) { if(state === GstClapper.ClapperState.PLAYING) {
if(inhibitCookie) if(inhibitCookie)
return; return;

View File

@@ -1,4 +1,4 @@
const { Gdk, Gio, GLib, GObject, Gst, GstPlayer, Gtk } = imports.gi; const { Gdk, Gio, GLib, GObject, Gst, GstClapper, Gtk } = imports.gi;
const ByteArray = imports.byteArray; const ByteArray = imports.byteArray;
const Debug = imports.src.debug; const Debug = imports.src.debug;
const Misc = imports.src.misc; const Misc = imports.src.misc;
@@ -188,7 +188,7 @@ class ClapperPlayer extends PlayerBase
this.seek_done = false; this.seek_done = false;
if(this.state === GstPlayer.PlayerState.STOPPED) if(this.state === GstClapper.ClapperState.STOPPED)
this.pause(); this.pause();
if(position < 0) if(position < 0)
@@ -213,7 +213,7 @@ class ClapperPlayer extends PlayerBase
/* FIXME: Remove this check when GstPlay(er) have set_seek_mode function */ /* FIXME: Remove this check when GstPlay(er) have set_seek_mode function */
if(this.set_seek_mode) { if(this.set_seek_mode) {
this.set_seek_mode(GstPlayer.PlayerSeekMode.DEFAULT); this.set_seek_mode(GstClapper.ClapperSeekMode.DEFAULT);
this.seekingMode = 'normal'; this.seekingMode = 'normal';
this.needsFastSeekRestore = true; this.needsFastSeekRestore = true;
} }
@@ -275,7 +275,7 @@ class ClapperPlayer extends PlayerBase
toggle_play() toggle_play()
{ {
const action = (this.state === GstPlayer.PlayerState.PLAYING) const action = (this.state === GstClapper.ClapperState.PLAYING)
? 'pause' ? 'pause'
: 'play'; : 'play';
@@ -387,11 +387,11 @@ class ClapperPlayer extends PlayerBase
this.state = state; this.state = state;
this.emitWs('state_changed', state); this.emitWs('state_changed', state);
if(state !== GstPlayer.PlayerState.BUFFERING) { if(state !== GstClapper.ClapperState.BUFFERING) {
const root = player.widget.get_root(); const root = player.widget.get_root();
if(this.quitOnStop) { if(this.quitOnStop) {
if(root && state === GstPlayer.PlayerState.STOPPED) if(root && state === GstClapper.ClapperState.STOPPED)
root.run_dispose(); root.run_dispose();
return; return;
@@ -402,11 +402,11 @@ class ClapperPlayer extends PlayerBase
const clapperWidget = player.widget.get_ancestor(Gtk.Grid); const clapperWidget = player.widget.get_ancestor(Gtk.Grid);
if(!clapperWidget) return; if(!clapperWidget) return;
if(!this.seek_done && state !== GstPlayer.PlayerState.BUFFERING) { if(!this.seek_done && state !== GstClapper.ClapperState.BUFFERING) {
clapperWidget.updateTime(); clapperWidget.updateTime();
if(this.needsFastSeekRestore) { if(this.needsFastSeekRestore) {
this.set_seek_mode(GstPlayer.PlayerSeekMode.FAST); this.set_seek_mode(GstClapper.ClapperSeekMode.FAST);
this.seekingMode = 'fast'; this.seekingMode = 'fast';
this.needsFastSeekRestore = false; this.needsFastSeekRestore = false;
} }
@@ -726,7 +726,7 @@ class ClapperPlayer extends PlayerBase
{ {
this._performCloseCleanup(window); this._performCloseCleanup(window);
if(this.state === GstPlayer.PlayerState.STOPPED) if(this.state === GstClapper.ClapperState.STOPPED)
return window.run_dispose(); return window.run_dispose();
this.quitOnStop = true; this.quitOnStop = true;

View File

@@ -1,4 +1,4 @@
const { Gio, GLib, GObject, Gst, GstPlayer, Gtk } = imports.gi; const { Gio, GLib, GObject, Gst, GstClapper, Gtk } = imports.gi;
const Debug = imports.src.debug; const Debug = imports.src.debug;
const Misc = imports.src.misc; const Misc = imports.src.misc;
const { PlaylistWidget } = imports.src.playlist; const { PlaylistWidget } = imports.src.playlist;
@@ -10,7 +10,7 @@ const { settings } = Misc;
let WebServer; let WebServer;
var PlayerBase = GObject.registerClass( var PlayerBase = GObject.registerClass(
class ClapperPlayerBase extends GstPlayer.Player class ClapperPlayerBase extends GstClapper.Clapper
{ {
_init() _init()
{ {
@@ -34,10 +34,10 @@ class ClapperPlayerBase extends GstPlayer.Player
const acquired = context.acquire(); const acquired = context.acquire();
debug(`default context acquired: ${acquired}`); debug(`default context acquired: ${acquired}`);
const dispatcher = new GstPlayer.PlayerGMainContextSignalDispatcher({ const dispatcher = new GstClapper.ClapperGMainContextSignalDispatcher({
application_context: context, application_context: context,
}); });
const renderer = new GstPlayer.PlayerVideoOverlayVideoRenderer({ const renderer = new GstClapper.ClapperVideoOverlayVideoRenderer({
video_sink: glsinkbin video_sink: glsinkbin
}); });
@@ -50,7 +50,7 @@ class ClapperPlayerBase extends GstPlayer.Player
this.widget.vexpand = true; this.widget.vexpand = true;
this.widget.hexpand = true; this.widget.hexpand = true;
this.state = GstPlayer.PlayerState.STOPPED; this.state = GstClapper.ClapperState.STOPPED;
this.visualization_enabled = false; this.visualization_enabled = false;
this.webserver = null; this.webserver = null;
@@ -87,13 +87,13 @@ class ClapperPlayerBase extends GstPlayer.Player
set_initial_config() set_initial_config()
{ {
const gstPlayerConfig = { const gstClapperConfig = {
position_update_interval: 1000, position_update_interval: 1000,
user_agent: 'clapper', user_agent: 'clapper',
}; };
for(let option of Object.keys(gstPlayerConfig)) for(let option of Object.keys(gstClapperConfig))
this.set_config_option(option, gstPlayerConfig[option]); this.set_config_option(option, gstClapperConfig[option]);
this.set_mute(false); this.set_mute(false);
@@ -104,7 +104,7 @@ class ClapperPlayerBase extends GstPlayer.Player
set_config_option(option, value) set_config_option(option, value)
{ {
const setOption = GstPlayer.Player[`config_set_${option}`]; const setOption = GstClapper.Clapper[`config_set_${option}`];
if(!setOption) if(!setOption)
return debug(`unsupported option: ${option}`, 'LEVEL_WARNING'); return debug(`unsupported option: ${option}`, 'LEVEL_WARNING');
@@ -158,7 +158,7 @@ class ClapperPlayerBase extends GstPlayer.Player
{ {
this.widget.ignore_textures = isEnabled; this.widget.ignore_textures = isEnabled;
if(this.state !== GstPlayer.PlayerState.PLAYING) if(this.state !== GstClapper.ClapperState.PLAYING)
this.widget.queue_render(); this.widget.queue_render();
} }
@@ -186,13 +186,13 @@ class ClapperPlayerBase extends GstPlayer.Player
switch(this.seekingMode) { switch(this.seekingMode) {
case 'fast': case 'fast':
if(isSeekMode) if(isSeekMode)
this.set_seek_mode(GstPlayer.PlayerSeekMode.FAST); this.set_seek_mode(GstClapper.ClapperSeekMode.FAST);
else else
this.set_config_option('seek_fast', true); this.set_config_option('seek_fast', true);
break; break;
case 'accurate': case 'accurate':
if(isSeekMode) if(isSeekMode)
this.set_seek_mode(GstPlayer.PlayerSeekMode.ACCURATE); this.set_seek_mode(GstClapper.ClapperSeekMode.ACCURATE);
else { else {
this.set_config_option('seek_fast', false); this.set_config_option('seek_fast', false);
this.set_config_option('seek_accurate', true); this.set_config_option('seek_accurate', true);
@@ -200,7 +200,7 @@ class ClapperPlayerBase extends GstPlayer.Player
break; break;
default: default:
if(isSeekMode) if(isSeekMode)
this.set_seek_mode(GstPlayer.PlayerSeekMode.DEFAULT); this.set_seek_mode(GstClapper.ClapperSeekMode.DEFAULT);
else { else {
this.set_config_option('seek_fast', false); this.set_config_option('seek_fast', false);
this.set_config_option('seek_accurate', false); this.set_config_option('seek_accurate', false);

View File

@@ -1,4 +1,4 @@
const { Gdk, GLib, GObject, GstPlayer, Gtk } = imports.gi; const { Gdk, GLib, GObject, GstClapper, Gtk } = imports.gi;
const { Controls } = imports.src.controls; const { Controls } = imports.src.controls;
const Debug = imports.src.debug; const Debug = imports.src.debug;
const Misc = imports.src.misc; const Misc = imports.src.misc;
@@ -237,7 +237,7 @@ class ClapperWidget extends Gtk.Grid
let type, text, codec; let type, text, codec;
switch(info.constructor) { switch(info.constructor) {
case GstPlayer.PlayerVideoInfo: case GstClapper.ClapperVideoInfo:
type = 'video'; type = 'video';
codec = info.get_codec() || 'Undetermined'; codec = info.get_codec() || 'Undetermined';
text = codec + ', ' + text = codec + ', ' +
@@ -248,7 +248,7 @@ class ClapperWidget extends Gtk.Grid
if(fps) if(fps)
text += `@${fps}`; text += `@${fps}`;
break; break;
case GstPlayer.PlayerAudioInfo: case GstClapper.ClapperAudioInfo:
type = 'audio'; type = 'audio';
codec = info.get_codec() || 'Undetermined'; codec = info.get_codec() || 'Undetermined';
if(codec.includes('(')) { if(codec.includes('(')) {
@@ -261,7 +261,7 @@ class ClapperWidget extends Gtk.Grid
text += ', ' + codec + ', ' text += ', ' + codec + ', '
+ info.get_channels() + ' Channels'; + info.get_channels() + ' Channels';
break; break;
case GstPlayer.PlayerSubtitleInfo: case GstClapper.ClapperSubtitleInfo:
type = 'subtitle'; type = 'subtitle';
text = info.get_language() || 'Undetermined'; text = info.get_language() || 'Undetermined';
break; break;
@@ -408,7 +408,7 @@ class ClapperWidget extends Gtk.Grid
{ {
if(isShow && !this.controls.visualizationsButton.isVisList) { if(isShow && !this.controls.visualizationsButton.isVisList) {
debug('creating visualizations list'); debug('creating visualizations list');
const visArr = GstPlayer.Player.visualizations_get(); const visArr = GstClapper.Clapper.visualizations_get();
if(!visArr.length) if(!visArr.length)
return; return;
@@ -446,7 +446,7 @@ class ClapperWidget extends Gtk.Grid
_onPlayerStateChanged(player, state) _onPlayerStateChanged(player, state)
{ {
switch(state) { switch(state) {
case GstPlayer.PlayerState.BUFFERING: case GstClapper.ClapperState.BUFFERING:
debug('player state changed to: BUFFERING'); debug('player state changed to: BUFFERING');
if(player.needsTocUpdate) { if(player.needsTocUpdate) {
this.controls._setChapterVisible(false); this.controls._setChapterVisible(false);
@@ -457,18 +457,18 @@ class ClapperWidget extends Gtk.Grid
this.needsTracksUpdate = true; this.needsTracksUpdate = true;
} }
break; break;
case GstPlayer.PlayerState.STOPPED: case GstClapper.ClapperState.STOPPED:
debug('player state changed to: STOPPED'); debug('player state changed to: STOPPED');
this.controls.currentPosition = 0; this.controls.currentPosition = 0;
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;
break; break;
case GstPlayer.PlayerState.PAUSED: case GstClapper.ClapperState.PAUSED:
debug('player state changed to: PAUSED'); debug('player state changed to: PAUSED');
this.controls.togglePlayButton.setPrimaryIcon(); this.controls.togglePlayButton.setPrimaryIcon();
break; break;
case GstPlayer.PlayerState.PLAYING: case GstClapper.ClapperState.PLAYING:
debug('player state changed to: PLAYING'); debug('player state changed to: PLAYING');
this.controls.togglePlayButton.setSecondaryIcon(); this.controls.togglePlayButton.setSecondaryIcon();
if(this.needsTracksUpdate) { if(this.needsTracksUpdate) {
@@ -483,7 +483,7 @@ class ClapperWidget extends Gtk.Grid
break; break;
} }
const isNotStopped = (state !== GstPlayer.PlayerState.STOPPED); const isNotStopped = (state !== GstClapper.ClapperState.STOPPED);
this.revealerTop.endTime.set_visible(isNotStopped); this.revealerTop.endTime.set_visible(isNotStopped);
} }

View File

@@ -1,4 +1,4 @@
const { GObject, Gtk, GstPlayer } = imports.gi; const { GObject, Gtk, GstClapper } = imports.gi;
const Buttons = imports.src.buttons; const Buttons = imports.src.buttons;
const Misc = imports.src.misc; const Misc = imports.src.misc;
const { PlayerRemote } = imports.src.playerRemote; const { PlayerRemote } = imports.src.playerRemote;
@@ -50,11 +50,11 @@ class ClapperWidgetRemote extends Gtk.Grid
switch(action) { switch(action) {
case 'state_changed': case 'state_changed':
switch(value) { switch(value) {
case GstPlayer.PlayerState.STOPPED: case GstClapper.ClapperState.STOPPED:
case GstPlayer.PlayerState.PAUSED: case GstClapper.ClapperState.PAUSED:
this.togglePlayButton.setPrimaryIcon(); this.togglePlayButton.setPrimaryIcon();
break; break;
case GstPlayer.PlayerState.PLAYING: case GstClapper.ClapperState.PLAYING:
this.togglePlayButton.setSecondaryIcon(); this.togglePlayButton.setSecondaryIcon();
break; break;
default: default: