2014-08-19 12:10:09 +02:00
|
|
|
/**
|
|
|
|
* EGroupware eTemplate2 - JS Description object
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage api
|
2021-06-07 17:33:53 +02:00
|
|
|
* @link https://www.egroupware.org
|
2014-08-19 12:10:09 +02:00
|
|
|
* @author Hadi Nategh <hn[at]stylite.de>
|
2021-06-07 17:33:53 +02:00
|
|
|
* @copyright EGroupware GmbH 2020-2021
|
2014-08-19 12:10:09 +02:00
|
|
|
*/
|
|
|
|
/*egw:uses
|
2020-01-21 16:14:45 +01:00
|
|
|
/vendor/bower-asset/jquery/dist/jquery.js;
|
|
|
|
et2_core_interfaces;
|
|
|
|
et2_core_baseWidget;
|
2014-08-19 12:10:09 +02:00
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
import { et2_baseWidget } from './et2_core_baseWidget';
|
|
|
|
import { ClassWithAttributes } from "./et2_core_inheritance";
|
|
|
|
import { et2_register_widget } from "./et2_core_widget";
|
2014-08-19 12:10:09 +02:00
|
|
|
/**
|
2016-02-29 21:40:43 +01:00
|
|
|
* This widget represents the HTML5 video tag with all its optional attributes
|
|
|
|
*
|
2014-08-19 12:10:09 +02:00
|
|
|
* The widget can be created in the following ways:
|
|
|
|
* <code>
|
|
|
|
* var videoTag = et2_createWidget("video", {
|
|
|
|
* video_src: "../../test.mp4",
|
|
|
|
* src_type: "video/mp4",
|
|
|
|
* muted: true,
|
|
|
|
* autoplay: true,
|
|
|
|
* controls: true,
|
|
|
|
* poster: "../../poster.jpg",
|
|
|
|
* loop: true,
|
|
|
|
* height: 100,
|
|
|
|
* width: 200,
|
|
|
|
* });
|
|
|
|
* </code>
|
|
|
|
* Or by adding XET-tag in your template (.xet) file:
|
|
|
|
* <code>
|
|
|
|
* <video [attributes...]/>
|
|
|
|
* </code>
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Class which implements the "video" XET-Tag
|
|
|
|
*
|
|
|
|
* @augments et2_baseWidget
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
export class et2_video extends et2_baseWidget {
|
|
|
|
constructor(_parent, _attrs, _child) {
|
|
|
|
super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_video._attributes, _child || {}));
|
|
|
|
this.video = null;
|
2021-02-15 12:24:33 +01:00
|
|
|
/**
|
|
|
|
* keeps internal state of previousTime video played
|
|
|
|
* @private
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
this._previousTime = 0;
|
|
|
|
this.set_src_type(this.options.src_type);
|
2021-05-15 20:26:28 +02:00
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
set_src_type(_type) {
|
2021-05-15 20:26:28 +02:00
|
|
|
this.options.src_type = _type;
|
|
|
|
if (this.video && this._isYoutube() === (this.video[0].tagName === 'DIV')) {
|
|
|
|
return;
|
|
|
|
}
|
2020-01-21 16:14:45 +01:00
|
|
|
//Create Video tag
|
2021-05-15 20:26:28 +02:00
|
|
|
this.video = jQuery(document.createElement(this._isYoutube() ? "div" : "video"))
|
|
|
|
.addClass('et2_video')
|
|
|
|
.attr('id', this.dom_id);
|
|
|
|
if (this._isYoutube()) {
|
2021-02-16 18:00:33 +01:00
|
|
|
// this div will be replaced by youtube iframe api when youtube gets ready
|
2021-05-15 20:26:28 +02:00
|
|
|
this.youtubeFrame = jQuery(document.createElement('div'))
|
|
|
|
.appendTo(this.video)
|
|
|
|
.attr('id', et2_video.youtubePrefixId + this.id);
|
2021-02-25 13:51:20 +01:00
|
|
|
if (!document.getElementById('youtube-api-script')) {
|
|
|
|
//Load youtube iframe api
|
2021-06-07 17:33:53 +02:00
|
|
|
let tag = document.createElement('script');
|
2021-02-25 13:51:20 +01:00
|
|
|
tag.id = 'youtube-api-script';
|
|
|
|
tag.src = "https://www.youtube.com/iframe_api";
|
2021-06-07 17:33:53 +02:00
|
|
|
let firstScriptTag = document.getElementsByTagName('script')[0];
|
2021-02-25 13:51:20 +01:00
|
|
|
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
|
|
|
}
|
2021-02-15 16:58:04 +01:00
|
|
|
}
|
2021-05-15 20:26:28 +02:00
|
|
|
if (!this._isYoutube() && this.options.controls) {
|
|
|
|
this.video.attr("controls", 1);
|
2020-01-21 16:14:45 +01:00
|
|
|
}
|
2021-05-15 20:26:28 +02:00
|
|
|
if (!this._isYoutube() && this.options.autoplay) {
|
|
|
|
this.video.attr("autoplay", 1);
|
2020-01-21 16:14:45 +01:00
|
|
|
}
|
2021-05-15 20:26:28 +02:00
|
|
|
if (this.options.muted) {
|
|
|
|
this.video.attr("muted", 1);
|
2020-01-21 16:14:45 +01:00
|
|
|
}
|
2021-05-15 20:26:28 +02:00
|
|
|
if (this.options.video_src) {
|
|
|
|
this.set_src(this.options.video_src);
|
2020-01-21 16:14:45 +01:00
|
|
|
}
|
2021-05-15 20:26:28 +02:00
|
|
|
if (this.options.loop) {
|
|
|
|
this.video.attr("loop", 1);
|
2020-01-21 16:14:45 +01:00
|
|
|
}
|
2021-05-15 20:26:28 +02:00
|
|
|
this.setDOMNode(this.video[0]);
|
|
|
|
this.set_width(this.options.width || 'auto');
|
|
|
|
this.set_height(this.options.height || 'auto');
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2020-01-21 16:14:45 +01:00
|
|
|
/**
|
|
|
|
* Set video src
|
|
|
|
*
|
|
|
|
* @param {string} _value url
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
set_src(_value) {
|
|
|
|
let self = this;
|
2021-05-15 20:26:28 +02:00
|
|
|
this.options.video_src = _value;
|
2021-02-15 16:58:04 +01:00
|
|
|
if (_value && !this._isYoutube()) {
|
2021-05-15 20:26:28 +02:00
|
|
|
this.video.attr('src', _value);
|
2020-01-21 16:14:45 +01:00
|
|
|
if (this.options.src_type) {
|
2021-05-15 20:26:28 +02:00
|
|
|
this.video.attr('type', this.options.src_type);
|
2020-01-21 16:14:45 +01:00
|
|
|
}
|
|
|
|
}
|
2021-02-15 16:58:04 +01:00
|
|
|
else if (_value) {
|
2021-02-25 13:51:20 +01:00
|
|
|
if (typeof YT == 'undefined') {
|
|
|
|
//initiate youtube Api object, it gets called automatically by iframe_api script from the api
|
|
|
|
window.onYouTubeIframeAPIReady = this._onYoutubeIframeAPIReady;
|
2021-05-15 20:26:28 +02:00
|
|
|
window.addEventListener('et2_video.onYoutubeIframeAPIReady', function () {
|
|
|
|
self._createYoutubePlayer(self.options.video_src);
|
|
|
|
});
|
2021-02-25 13:51:20 +01:00
|
|
|
}
|
2021-05-15 20:26:28 +02:00
|
|
|
else {
|
2021-02-25 13:51:20 +01:00
|
|
|
self._createYoutubePlayer(self.options.video_src);
|
2021-05-15 20:26:28 +02:00
|
|
|
}
|
2021-02-15 16:58:04 +01:00
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2020-01-21 16:14:45 +01:00
|
|
|
/**
|
|
|
|
* Set autoplay option for video
|
|
|
|
* -If autoplay is set, video would be played automatically after the page is loaded
|
|
|
|
*
|
|
|
|
* @param {string} _value true set the autoplay and false not to set
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
set_autoplay(_value) {
|
2021-02-15 16:58:04 +01:00
|
|
|
if (_value && !this._isYoutube()) {
|
2020-01-21 16:14:45 +01:00
|
|
|
this.video.attr("autoplay", _value);
|
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2020-01-21 16:14:45 +01:00
|
|
|
/**
|
|
|
|
* Set controls option for video
|
|
|
|
*
|
|
|
|
* @param {string} _value true set the autoplay and false not to set
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
set_controls(_value) {
|
2021-02-15 16:58:04 +01:00
|
|
|
if (_value && !this._isYoutube()) {
|
2020-01-21 16:14:45 +01:00
|
|
|
this.video.attr("controls", _value);
|
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2020-01-21 16:14:45 +01:00
|
|
|
/**
|
|
|
|
* Set poster attribute in order to specify
|
|
|
|
* an image to be shown while video is loading or before user play it
|
|
|
|
*
|
2020-05-08 12:20:37 +02:00
|
|
|
* @param {string} _url url or image spec like "api/mime128_video"
|
2020-01-21 16:14:45 +01:00
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
set_poster(_url) {
|
2020-01-21 16:14:45 +01:00
|
|
|
if (_url) {
|
2020-05-08 12:20:37 +02:00
|
|
|
if (_url[0] !== '/' && !_url.match(/^https?:\/\//)) {
|
|
|
|
_url = this.egw().image(_url);
|
|
|
|
}
|
2020-01-21 16:14:45 +01:00
|
|
|
this.video.attr("poster", _url);
|
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2020-05-10 14:52:47 +02:00
|
|
|
/**
|
|
|
|
* Seek to a time / position
|
|
|
|
*
|
|
|
|
* @param _vtime in seconds
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
seek_video(_vtime) {
|
2021-02-15 16:58:04 +01:00
|
|
|
if (this._isYoutube()) {
|
2021-02-16 18:00:33 +01:00
|
|
|
if (this.youtube.seekTo) {
|
|
|
|
this.youtube.seekTo(_vtime, true);
|
|
|
|
this._currentTime = _vtime;
|
|
|
|
}
|
2021-02-15 16:58:04 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.video[0].currentTime = _vtime;
|
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2020-05-10 14:52:47 +02:00
|
|
|
/**
|
|
|
|
* Play video
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
play_video() {
|
2021-02-16 18:00:33 +01:00
|
|
|
if (this._isYoutube()) {
|
2021-06-07 17:33:53 +02:00
|
|
|
let self = this;
|
2021-02-16 18:00:33 +01:00
|
|
|
return new Promise(function (resolve) {
|
2021-06-07 17:33:53 +02:00
|
|
|
if (self.youtube.playVideo) {
|
|
|
|
self.youtube.playVideo();
|
2021-02-16 18:00:33 +01:00
|
|
|
resolve();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return this.video[0].play();
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2020-05-10 14:52:47 +02:00
|
|
|
/**
|
|
|
|
* Pause video
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
pause_video() {
|
2021-02-15 16:58:04 +01:00
|
|
|
if (this._isYoutube()) {
|
2021-02-16 18:00:33 +01:00
|
|
|
if (this.youtube.pauseVideo) {
|
|
|
|
this.youtube.pauseVideo();
|
|
|
|
this.currentTime(this.youtube.getCurrentTime());
|
|
|
|
}
|
2021-02-15 16:58:04 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.video[0].pause();
|
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2020-05-10 14:52:47 +02:00
|
|
|
/**
|
2021-02-15 12:24:33 +01:00
|
|
|
* play video
|
|
|
|
* ***Internal use and should not be overriden in its extended class***
|
2020-05-10 14:52:47 +02:00
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
play() {
|
2021-02-15 16:58:04 +01:00
|
|
|
var _a;
|
|
|
|
return this._isYoutube() && ((_a = this.youtube) === null || _a === void 0 ? void 0 : _a.playVideo) ? this.youtube.playVideo() : this.video[0].play();
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2021-02-15 12:24:33 +01:00
|
|
|
/**
|
|
|
|
* Get/set current video time / position in seconds
|
|
|
|
* @return returns currentTime
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
currentTime(_time) {
|
2021-02-15 16:58:04 +01:00
|
|
|
var _a;
|
|
|
|
if (_time) {
|
|
|
|
if (this._isYoutube()) {
|
|
|
|
this.youtube.seekTo(_time);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.video[0].currentTime = _time;
|
|
|
|
}
|
2021-02-16 18:00:33 +01:00
|
|
|
return this._currentTime = _time;
|
2021-02-15 16:58:04 +01:00
|
|
|
}
|
|
|
|
if (this._isYoutube()) {
|
2021-02-16 18:00:33 +01:00
|
|
|
if (typeof this._currentTime != 'undefined') {
|
|
|
|
return this._currentTime;
|
|
|
|
}
|
2021-02-15 16:58:04 +01:00
|
|
|
return ((_a = this.youtube) === null || _a === void 0 ? void 0 : _a.getCurrentTime) ? this.youtube.getCurrentTime() : 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return this.video[0].currentTime;
|
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2021-02-15 12:24:33 +01:00
|
|
|
/**
|
|
|
|
* get duration time
|
|
|
|
* @return returns duration time
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
duration() {
|
2021-02-15 16:58:04 +01:00
|
|
|
var _a;
|
|
|
|
if (this._isYoutube()) {
|
|
|
|
return ((_a = this.youtube) === null || _a === void 0 ? void 0 : _a.getDuration) ? this.youtube.getDuration() : 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return this.video[0].duration;
|
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2021-02-15 12:24:33 +01:00
|
|
|
/**
|
|
|
|
* get pasued
|
|
|
|
* @return returns paused flag
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
paused() {
|
2021-02-15 16:58:04 +01:00
|
|
|
if (this._isYoutube()) {
|
|
|
|
return this.youtube.getPlayerState() == et2_video.youtube_player_states.paused;
|
|
|
|
}
|
2021-02-15 12:24:33 +01:00
|
|
|
return this.video[0].paused;
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2021-02-15 12:24:33 +01:00
|
|
|
/**
|
|
|
|
* get ended
|
|
|
|
* @return returns ended flag
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
ended() {
|
2021-02-15 16:58:04 +01:00
|
|
|
if (this._isYoutube()) {
|
|
|
|
return this.youtube.getPlayerState() == et2_video.youtube_player_states.ended;
|
|
|
|
}
|
2021-02-15 12:24:33 +01:00
|
|
|
return this.video[0].ended;
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2021-02-15 12:24:33 +01:00
|
|
|
/**
|
|
|
|
* get/set priviousTime
|
|
|
|
* @param _time
|
|
|
|
* @return returns time
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
previousTime(_time) {
|
2021-02-15 12:24:33 +01:00
|
|
|
if (_time)
|
|
|
|
this._previousTime = _time;
|
|
|
|
return this._previousTime;
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
|
|
|
doLoadingFinished() {
|
|
|
|
super.doLoadingFinished();
|
|
|
|
let self = this;
|
2021-02-15 16:58:04 +01:00
|
|
|
if (!this._isYoutube()) {
|
|
|
|
this.video[0].addEventListener("loadedmetadata", function () {
|
|
|
|
self._onReady();
|
|
|
|
});
|
2021-02-16 18:00:33 +01:00
|
|
|
this.video[0].addEventListener("timeupdate", function () {
|
|
|
|
self._onTimeUpdate();
|
|
|
|
});
|
2021-02-15 16:58:04 +01:00
|
|
|
}
|
2021-02-25 13:51:20 +01:00
|
|
|
else {
|
|
|
|
// need to create the player after the DOM is ready otherwise player won't show up
|
|
|
|
if (window.YT)
|
|
|
|
this._createYoutubePlayer(this.options.video_src);
|
|
|
|
}
|
2021-02-02 12:35:28 +01:00
|
|
|
return false;
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
|
|
|
videoLoadnigIsFinished() {
|
2021-02-02 12:35:28 +01:00
|
|
|
if (this.options.starttime) {
|
|
|
|
this.seek_video(this.options.starttime);
|
2021-02-26 13:17:44 +01:00
|
|
|
// unfortunately, youtube api autoplays the video after seekTo on initiation
|
|
|
|
// and there's no way to stop that therefore we need to trick it by manually
|
|
|
|
// pausing the video (this would bring up the spinner with the black screen,
|
|
|
|
// in order to avoid that we let the video plays for a second then we pause).
|
|
|
|
// since the youtube timeline is one second advanced we need to seek back to
|
|
|
|
// the original stattime although this time because it was manually paused
|
|
|
|
// we won't have the spinner and black screen instead we get the preview.
|
|
|
|
if (this._isYoutube())
|
|
|
|
window.setTimeout(function () {
|
|
|
|
this.youtube.pauseVideo();
|
|
|
|
this.youtube.seekTo(this.options.starttime);
|
|
|
|
;
|
|
|
|
}.bind(this), 1000);
|
2021-02-02 12:35:28 +01:00
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
|
|
|
_onReady() {
|
2021-02-16 18:00:33 +01:00
|
|
|
// need to set the video dom to transformed iframe
|
|
|
|
if (this._isYoutube() && this.youtube.getIframe)
|
|
|
|
this.youtubeFrame = jQuery(this.youtube.getIframe());
|
2021-06-07 17:33:53 +02:00
|
|
|
let event = document.createEvent("Event");
|
2021-02-15 16:58:04 +01:00
|
|
|
event.initEvent('et2_video.onReady.' + this.id, true, true);
|
|
|
|
this.video[0].dispatchEvent(event);
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
|
|
|
_onTimeUpdate() {
|
2021-02-16 18:00:33 +01:00
|
|
|
// update currentTime manually since youtube currentTime might be updated due to the loading
|
|
|
|
if (this._isYoutube() && this.youtube.getCurrentTime)
|
|
|
|
this._currentTime = this.youtube.getCurrentTime();
|
2021-06-07 17:33:53 +02:00
|
|
|
let event = document.createEvent("Event");
|
2021-02-16 18:00:33 +01:00
|
|
|
event.initEvent('et2_video.onTimeUpdate.' + this.id, true, true);
|
|
|
|
this.video[0].dispatchEvent(event);
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2021-02-15 16:58:04 +01:00
|
|
|
/**
|
|
|
|
* check if the video is a youtube type
|
|
|
|
* @return return true if it's a youtube type video
|
|
|
|
* @private
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
_isYoutube() {
|
2021-02-15 16:58:04 +01:00
|
|
|
return !!this.options.src_type.match('youtube');
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
|
|
|
_onStateChangeYoutube(_data) {
|
2021-02-16 18:00:33 +01:00
|
|
|
switch (_data.data) {
|
|
|
|
case et2_video.youtube_player_states.unstarted:
|
2021-02-26 10:16:02 +01:00
|
|
|
// do nothing
|
2021-02-16 18:00:33 +01:00
|
|
|
break;
|
|
|
|
case et2_video.youtube_player_states.playing:
|
|
|
|
this._youtubeOntimeUpdateIntrv = window.setInterval(jQuery.proxy(this._onTimeUpdate, this), 100);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
window.clearInterval(this._youtubeOntimeUpdateIntrv);
|
|
|
|
}
|
|
|
|
console.log(_data);
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2021-02-25 13:51:20 +01:00
|
|
|
/**
|
|
|
|
* youtube on IframeAPI ready event
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
_onYoutubeIframeAPIReady() {
|
|
|
|
let event = document.createEvent("Event");
|
2021-02-25 13:51:20 +01:00
|
|
|
event.initEvent('et2_video.onYoutubeIframeAPIReady', true, true);
|
|
|
|
window.dispatchEvent(event);
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
2021-02-25 13:51:20 +01:00
|
|
|
/**
|
|
|
|
* create youtube player
|
|
|
|
*
|
|
|
|
* @param _value
|
|
|
|
*/
|
2021-06-07 17:33:53 +02:00
|
|
|
_createYoutubePlayer(_value) {
|
|
|
|
const matches = _value === null || _value === void 0 ? void 0 : _value.match(et2_video.youtubeRegexp);
|
2021-05-15 20:26:28 +02:00
|
|
|
if (matches && typeof YT != 'undefined') {
|
2021-02-25 13:51:20 +01:00
|
|
|
this.youtube = new YT.Player(et2_video.youtubePrefixId + this.id, {
|
|
|
|
height: this.options.height || '400',
|
|
|
|
width: '100%',
|
|
|
|
playerVars: {
|
|
|
|
'autoplay': 0,
|
|
|
|
'controls': 0,
|
|
|
|
'modestbranding': 1,
|
|
|
|
'fs': 0,
|
|
|
|
'disablekb': 1,
|
|
|
|
'rel': 0,
|
|
|
|
'iv_load_policy': 0,
|
|
|
|
'cc_load_policy': 0
|
|
|
|
},
|
2021-05-15 20:26:28 +02:00
|
|
|
videoId: matches[4],
|
2021-02-25 13:51:20 +01:00
|
|
|
events: {
|
|
|
|
'onReady': jQuery.proxy(this._onReady, this),
|
|
|
|
'onStateChange': jQuery.proxy(this._onStateChangeYoutube, this)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-06-07 17:33:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
et2_video._attributes = {
|
|
|
|
"video_src": {
|
|
|
|
"name": "Video",
|
|
|
|
"type": "string",
|
|
|
|
"description": "Source of video to display"
|
|
|
|
},
|
|
|
|
"src_type": {
|
|
|
|
"name": "Source type",
|
|
|
|
"type": "string",
|
|
|
|
"description": "Defines the type the stream source provided"
|
|
|
|
},
|
|
|
|
"muted": {
|
|
|
|
"name": "Audio control",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false,
|
|
|
|
"description": "Defines that the audio output of the video should be muted"
|
|
|
|
},
|
|
|
|
"autoplay": {
|
|
|
|
"name": "Autoplay",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false,
|
|
|
|
"description": "Defines if Video will start playing as soon as it is ready"
|
|
|
|
},
|
|
|
|
starttime: {
|
|
|
|
"name": "Inital position of video",
|
|
|
|
"type": "float",
|
|
|
|
"default": 0,
|
|
|
|
"description": "Set initial position of video"
|
|
|
|
},
|
|
|
|
"controls": {
|
|
|
|
"name": "Control buttons",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false,
|
|
|
|
"description": "Defines if Video controls, play/pause buttons should be displayed"
|
|
|
|
},
|
|
|
|
"poster": {
|
|
|
|
"name": "Video Poster",
|
|
|
|
"type": "string",
|
|
|
|
"default": "",
|
|
|
|
"description": "Specifies an image to be shown while video is loading or before user play it"
|
|
|
|
},
|
|
|
|
"loop": {
|
|
|
|
"name": "Video loop",
|
|
|
|
"type": "boolean",
|
|
|
|
"default": false,
|
|
|
|
"description": "Defines if the video should be played repeatedly"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
et2_video.youtube_player_states = {
|
|
|
|
unstarted: -1,
|
|
|
|
ended: 0,
|
|
|
|
playing: 1,
|
|
|
|
paused: 2,
|
|
|
|
buffering: 3,
|
|
|
|
video_cued: 5
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* prefix id used for addressing youtube player dom
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
et2_video.youtubePrefixId = "frame-";
|
|
|
|
et2_video.youtubeRegexp = new RegExp(/^https:\/\/((www\.|m\.)?youtube(-nocookie)?\.com|youtu\.be)\/.*(?:\/|%3D|v=|vi=)([0-9A-z-_]{11})(?:[%#?&]|$)/m);
|
|
|
|
et2_register_widget(et2_video, ["video"]);
|
2020-01-21 19:45:21 +01:00
|
|
|
//# sourceMappingURL=et2_widget_video.js.map
|