From a7ea5b51bf2b13df095dddef7c8d95afc79bfba8 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 13 Aug 2021 12:39:38 +0200 Subject: [PATCH] Implements volume and playback options for video widget (both for html video and youtube) --- api/js/etemplate/et2_widget_video.ts | 83 ++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/api/js/etemplate/et2_widget_video.ts b/api/js/etemplate/et2_widget_video.ts index 1b0d44527e..e2ff53e67c 100644 --- a/api/js/etemplate/et2_widget_video.ts +++ b/api/js/etemplate/et2_widget_video.ts @@ -96,6 +96,18 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode "type": "boolean", "default": false, "description": "Defines if the video should be played repeatedly" + }, + "volume": { + "name": "Video volume", + "type": "float", + "default": 0, + "description": "Set video's volume" + }, + "playbackrate": { + "name": "Video playBackRate", + "type": "float", + "default": 1, + "description": "Set video's playBackRate" } }; @@ -264,6 +276,77 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode } } + /** + * Method to set volume + * @param _value + */ + set_volume(_value: number) + { + let value = _value>100?100:_value; + if (value>= 0) + { + if (this._isYoutube()) + { + this.youtube.set_volume(value); + } + else + { + this.video[0].volume = value/100; + } + } + } + + /** + * get volume + */ + get_volume() + { + if (this._isYoutube()) + { + return this.youtube.get_playBackRate(); + } + else + { + return this.video[0].playBackRate; + } + } + + /** + * method to set playBackRate + * @param _value + */ + set_playBackRate(_value: number) + { + let value = _value>16?16:_value; + if (value>= 0) + { + if (this._isYoutube()) + { + this.youtube.playBackRate(value); + } + else + { + this.video[0].playBackRate = value; + } + } + } + + /** + * get playBackRate + */ + get_playBackRate() + { + if (this._isYoutube()) + { + return this.youtube.get_volume(); + } + else + { + return this.video[0].volume; + } + } + + } /** * Set poster attribute in order to specify * an image to be shown while video is loading or before user play it