Do not import GstClapper for remote app

No need to import and initialize whole GStreamer for web application if the only thing needed there is a single enum.
This commit is contained in:
Rafał Dzięgiel
2021-02-22 16:34:08 +01:00
parent 8df5c38357
commit 6950cf1bbb
5 changed files with 19 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
const { GObject, Gst, Gtk } = imports.gi; const { GObject, Gtk } = imports.gi;
const Dialogs = imports.src.dialogs; const Dialogs = imports.src.dialogs;
var actions = { var actions = {

View File

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

View File

@@ -1,4 +1,4 @@
const { Gdk, Gio, GLib, GObject, Gst, GstClapper, Gtk } = imports.gi; const { Gdk, Gio, 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;
@@ -320,7 +320,8 @@ class ClapperPlayer extends PlayerBase
return; return;
} }
Misc.inhibitForState(state, root); const isInhibit = (state === GstClapper.ClapperState.PLAYING);
Misc.setAppInhibit(isInhibit, root);
} }
const clapperWidget = player.widget.get_ancestor(Gtk.Grid); const clapperWidget = player.widget.get_ancestor(Gtk.Grid);

View File

@@ -1,6 +1,13 @@
const { GObject } = imports.gi; const { GObject } = imports.gi;
const { WebClient } = imports.src.webClient; const { WebClient } = imports.src.webClient;
var ClapperState = {
STOPPED: 0,
BUFFERING: 1,
PAUSED: 2,
PLAYING: 3,
};
var PlayerRemote = GObject.registerClass( var PlayerRemote = GObject.registerClass(
class ClapperPlayerRemote extends GObject.Object class ClapperPlayerRemote extends GObject.Object
{ {

View File

@@ -1,7 +1,7 @@
const { GObject, Gtk, GstClapper } = imports.gi; const { GObject, Gtk } = 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, ClapperState } = imports.src.playerRemote;
var WidgetRemote = GObject.registerClass( var WidgetRemote = GObject.registerClass(
class ClapperWidgetRemote extends Gtk.Grid class ClapperWidgetRemote extends Gtk.Grid
@@ -50,11 +50,11 @@ class ClapperWidgetRemote extends Gtk.Grid
switch(action) { switch(action) {
case 'state_changed': case 'state_changed':
switch(value) { switch(value) {
case GstClapper.ClapperState.STOPPED: case ClapperState.STOPPED:
case GstClapper.ClapperState.PAUSED: case ClapperState.PAUSED:
this.togglePlayButton.setPrimaryIcon(); this.togglePlayButton.setPrimaryIcon();
break; break;
case GstClapper.ClapperState.PLAYING: case ClapperState.PLAYING:
this.togglePlayButton.setSecondaryIcon(); this.togglePlayButton.setSecondaryIcon();
break; break;
default: default: