From da652e1ec56893d689421d555ec0118034a9f35d Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Sun, 6 Sep 2020 10:34:27 +0200 Subject: [PATCH] Skip setting player option when unsupported --- clapper_src/player.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/clapper_src/player.js b/clapper_src/player.js index 394c1c1b..ae5481a9 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -1,4 +1,5 @@ const { GLib, GObject, Gst, GstPlayer } = imports.gi; +const Debug = imports.clapper_src.debug; const GSTPLAYER_DEFAULTS = { position_update_interval: 1000, @@ -6,6 +7,8 @@ const GSTPLAYER_DEFAULTS = { user_agent: 'clapper', }; +let { debug } = Debug; + var Player = GObject.registerClass( class ClapperPlayer extends GstPlayer.Player { @@ -37,8 +40,14 @@ class ClapperPlayer extends GstPlayer.Player let config = this.get_config(); - for(let setting of Object.keys(GSTPLAYER_DEFAULTS)) - GstPlayer.Player[`config_set_${setting}`](config, opts[setting]); + for(let setting of Object.keys(GSTPLAYER_DEFAULTS)) { + let setOption = GstPlayer.Player[`config_set_${setting}`]; + if(!setOption) { + debug(`unsupported option: ${setting}`, 'LEVEL_WARNING'); + continue; + } + setOption(config, opts[setting]); + } this.set_config(config);