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()
{
return this.__getActiveVideo()[0].node.paused;
return this.__getActiveVideo()[0]?.node?.paused;
}
/**
@ -323,7 +323,7 @@ class multi_video extends HTMLElement {
*/
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()
{
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()
{
return this.__getActiveVideo()[0].node.playbackRate;
return this.__getActiveVideo()[0]?.node?.playbackRate;
}
/**
@ -368,7 +368,7 @@ class multi_video extends HTMLElement {
*/
get volume()
{
return this.__getActiveVideo()[0].node.volume;
return this.__getActiveVideo()[0]?.node?.volume;
}
@ -380,7 +380,7 @@ class multi_video extends HTMLElement {
play()
{
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()
{
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 {WidgetConfig, et2_register_widget} from "./et2_core_widget";
import {et2_IDOMNode} from "./et2_core_interfaces";
import "./CustomHtmlElements/multi-video";
/**
* 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",
"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": {
"name": "Audio control",
"type": "boolean",
@ -167,7 +174,7 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode
return;
}
//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')
.attr('id', this.dom_id);