Add multi_src option into video widget

This commit is contained in:
Hadi Nategh 2022-01-28 15:51:33 +01:00
parent 66c6a4aef1
commit 8e26062854
2 changed files with 15 additions and 8 deletions

View File

@ -304,7 +304,7 @@ class multi_video extends HTMLElement {
*/ */
get paused() get paused()
{ {
return this.__getActiveVideo()[0].node.paused; return this.__getActiveVideo()[0]?.node?.paused;
} }
/** /**
@ -323,7 +323,7 @@ class multi_video extends HTMLElement {
*/ */
get muted() get muted()
{ {
return this.__getActiveVideo()[0].node.muted; return this.__getActiveVideo()[0]?.node?.muted;
} }
/** /**
@ -331,7 +331,7 @@ class multi_video extends HTMLElement {
*/ */
get ended() get ended()
{ {
return this._videos[this._videos.length-1].node.ended; return this._videos[this._videos.length-1]?.node?.ended;
} }
/** /**
@ -350,7 +350,7 @@ class multi_video extends HTMLElement {
*/ */
get playbackRate() get playbackRate()
{ {
return this.__getActiveVideo()[0].node.playbackRate; return this.__getActiveVideo()[0]?.node?.playbackRate;
} }
/** /**
@ -368,7 +368,7 @@ class multi_video extends HTMLElement {
*/ */
get volume() get volume()
{ {
return this.__getActiveVideo()[0].node.volume; return this.__getActiveVideo()[0]?.node?.volume;
} }
@ -380,7 +380,7 @@ class multi_video extends HTMLElement {
play() play()
{ {
this.__playing = true; this.__playing = true;
return this.__getActiveVideo()[0].node.play(); return this.__getActiveVideo()[0]?.node?.play();
} }
/** /**
@ -389,7 +389,7 @@ class multi_video extends HTMLElement {
pause() pause()
{ {
this.__playing = false; this.__playing = false;
this.__getActiveVideo()[0].node.pause(); this.__getActiveVideo()[0]?.node?.pause();
} }
} }

View File

@ -19,6 +19,7 @@ import { et2_baseWidget } from './et2_core_baseWidget'
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {WidgetConfig, et2_register_widget} from "./et2_core_widget"; import {WidgetConfig, et2_register_widget} from "./et2_core_widget";
import {et2_IDOMNode} from "./et2_core_interfaces"; import {et2_IDOMNode} from "./et2_core_interfaces";
import "./CustomHtmlElements/multi-video";
/** /**
* This widget represents the HTML5 video tag with all its optional attributes * This widget represents the HTML5 video tag with all its optional attributes
@ -61,6 +62,12 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode
"type": "string", "type": "string",
"description": "Defines the type the stream source provided" "description": "Defines the type the stream source provided"
}, },
"multi_src": {
"name": "Multi Video source",
"type": "boolean",
"default": false,
"description": "creates a multi-video tag in order to render all provided video sources"
},
"muted": { "muted": {
"name": "Audio control", "name": "Audio control",
"type": "boolean", "type": "boolean",
@ -167,7 +174,7 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode
return; return;
} }
//Create Video tag //Create Video tag
this.video = jQuery(document.createElement(this._isYoutube()?"div":"video")) this.video = jQuery(document.createElement(this._isYoutube()?"div":(this.options.multi_src ? "multi-video" : "video")))
.addClass('et2_video') .addClass('et2_video')
.attr('id', this.dom_id); .attr('id', this.dom_id);