From 904e6a96e133036abe51fe338cc363f61b541c85 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 16 Aug 2021 17:49:47 +0200 Subject: [PATCH] Add getter/setter for video's mute option and fix volume unit --- api/js/etemplate/et2_widget_video.ts | 31 +++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/api/js/etemplate/et2_widget_video.ts b/api/js/etemplate/et2_widget_video.ts index df92740033..9d89c098d0 100644 --- a/api/js/etemplate/et2_widget_video.ts +++ b/api/js/etemplate/et2_widget_video.ts @@ -307,7 +307,7 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode } else { - return this.video[0].volume; + return this.video[0].volume * 100; } } @@ -346,6 +346,35 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode } } + set_mute(_value) + { + if (this._isYoutube() && this.youtube) { + if (_value) + { + this.youtube.mute(); + } + else + { + this.youtube.unMute(); + } + } + else + { + this.video[0].muted = _value; + } + } + + get_mute(_value) + { + if (this._isYoutube() && this.youtube) + { + return this.youtube.isMuted(); + } + else + { + return this.video[0].muted; + } + } /** * Set poster attribute in order to specify * an image to be shown while video is loading or before user play it