From fa12f15a9a94c981856ff5cbf50dc1d378c9b546 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Tue, 1 Sep 2020 17:49:24 +0200 Subject: [PATCH] Start loop optionally --- clapper_src/player.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/clapper_src/player.js b/clapper_src/player.js index f12240c6..b90db86d 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -1,6 +1,6 @@ const { GLib, GObject, Gst, GstPlayer } = imports.gi; -const DEFAULTS = { +const GSTPLAYER_DEFAULTS = { position_update_interval: 1000, seek_accurate: false, user_agent: 'clapper', @@ -12,7 +12,7 @@ class ClapperPlayer extends GstPlayer.Player _init(opts) { opts = opts || {}; - Object.assign(opts, DEFAULTS); + Object.assign(opts, GSTPLAYER_DEFAULTS); let gtkglsink = Gst.ElementFactory.make('gtkglsink', null); let glsinkbin = Gst.ElementFactory.make('glsinkbin', null); @@ -30,12 +30,13 @@ class ClapperPlayer extends GstPlayer.Player let config = this.get_config(); - for(let setting of Object.keys(DEFAULTS)) + for(let setting of Object.keys(GSTPLAYER_DEFAULTS)) GstPlayer.Player[`config_set_${setting}`](config, opts[setting]); this.set_config(config); this.loop = GLib.MainLoop.new(null, false); + this.run_loop = opts.run_loop || false; this.widget = gtkglsink.widget; this.state = GstPlayer.PlayerState.STOPPED; @@ -58,12 +59,19 @@ class ClapperPlayer extends GstPlayer.Player this[action](); } + set_subtitle_font_desc(desc) + { + let pipeline = this.get_pipeline(); + pipeline.subtitle_font_desc = desc; + } + _onStateChanged(player, state) { this.state = state; if( - this.state === GstPlayer.PlayerState.STOPPED + this.run_loop + && this.state === GstPlayer.PlayerState.STOPPED && this.loop.is_running() ) this.loop.quit(); @@ -73,7 +81,10 @@ class ClapperPlayer extends GstPlayer.Player { this.play(); - if(!this.loop.is_running()) + if( + this.run_loop + && !this.loop.is_running() + ) this.loop.run(); }