New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pluginjs/video

Package Overview
Dependencies
Maintainers
2
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pluginjs/video - npm Package Compare versions

Comparing version 0.8.3 to 0.8.4

2

dist/video.common.js
/*!
* @pluginjs/video v0.8.3 (https://pluginjs.com)
* @pluginjs/video v0.8.4 (https://pluginjs.com)
* Copyright 2020 Creation Studio Limited

@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License.

/*!
* @pluginjs/video v0.8.3 (https://pluginjs.com)
* @pluginjs/video v0.8.4 (https://pluginjs.com)
* Copyright 2020 Creation Studio Limited

@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License.

/*!
* @pluginjs/video v0.8.3 (https://pluginjs.com)
* @pluginjs/video v0.8.4 (https://pluginjs.com)
* Copyright 2020 Creation Studio Limited

@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License.

/*!
* @pluginjs/video v0.8.3 (https://pluginjs.com)
* @pluginjs/video v0.8.4 (https://pluginjs.com)
* Copyright 2020 Creation Studio Limited

@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License.

/*!
* @pluginjs/video v0.8.3 (https://pluginjs.com)
* @pluginjs/video v0.8.4 (https://pluginjs.com)
* Copyright 2020 Creation Studio Limited

@@ -12,4 +12,4 @@ * Released under the GPL-3.0 License.

Component = Component && Component.hasOwnProperty('default') ? Component['default'] : Component;
Pj = Pj && Pj.hasOwnProperty('default') ? Pj['default'] : Pj;
Component = Component && Object.prototype.hasOwnProperty.call(Component, 'default') ? Component['default'] : Component;
Pj = Pj && Object.prototype.hasOwnProperty.call(Pj, 'default') ? Pj['default'] : Pj;

@@ -69,2 +69,15 @@ function _classCallCheck(instance, Constructor) {

function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _assertThisInitialized(self) {

@@ -86,2 +99,21 @@ if (self === void 0) {

function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function () {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
function _superPropBase(object, property) {

@@ -150,5 +182,3 @@ while (!Object.prototype.hasOwnProperty.call(object, property)) {

var Html5 =
/*#__PURE__*/
function () {
var Html5 = /*#__PURE__*/function () {
function Html5(instance, element) {

@@ -327,5 +357,3 @@ _classCallCheck(this, Html5);

var Vimeo =
/*#__PURE__*/
function () {
var Vimeo = /*#__PURE__*/function () {
function Vimeo(instance, element) {

@@ -557,5 +585,3 @@ _classCallCheck(this, Vimeo);

var Youtube =
/*#__PURE__*/
function () {
var Youtube = /*#__PURE__*/function () {
function Youtube(instance, element) {

@@ -758,7 +784,7 @@ _classCallCheck(this, Youtube);

methods: methods
}), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = _dec5(_class =
/*#__PURE__*/
function (_Component) {
}), _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = _dec5(_class = /*#__PURE__*/function (_Component) {
_inherits(Video, _Component);
var _super = _createSuper(Video);
function Video(element) {

@@ -771,3 +797,3 @@ var _this;

_this = _possibleConstructorReturn(this, _getPrototypeOf(Video).call(this, element));
_this = _super.call(this, element);

@@ -774,0 +800,0 @@ _this.setupOptions(options);

/*!
* @pluginjs/video v0.8.3 (https://pluginjs.com)
* @pluginjs/video v0.8.4 (https://pluginjs.com)
* Copyright 2020 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@pluginjs/component"),require("@pluginjs/decorator"),require("@pluginjs/styled"),require("@pluginjs/classes"),require("@pluginjs/dom"),require("@pluginjs/is"),require("@pluginjs/utils"),require("@pluginjs/factory")):"function"==typeof define&&define.amd?define(["@pluginjs/component","@pluginjs/decorator","@pluginjs/styled","@pluginjs/classes","@pluginjs/dom","@pluginjs/is","@pluginjs/utils","@pluginjs/factory"],t):(e=e||self)["@pluginjs/video"]=t(e["@pluginjs/component"],e["@pluginjs/decorator"],e["@pluginjs/styled"],e["@pluginjs/classes"],e["@pluginjs/dom"],e["@pluginjs/is"],e["@pluginjs/utils"],e["@pluginjs/factory"])}(this,(function(e,t,i,n,o,s,r,a){"use strict";function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,t,i){return t&&l(e.prototype,t),i&&l(e,i),e}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function y(e,t,i){return(y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=c(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(i):o.value}})(e,t,i||e)}e=e&&e.hasOwnProperty("default")?e.default:e,a=a&&a.hasOwnProperty("default")?a.default:a;var f={READY:"ready",DESTROY:"destroy",LOAD:"load",LOADED:"loaded",PLAY:"play",PAUSE:"pause",STOP:"stop",ENDED:"ended",ERROR:"error",BUFFERING:"buffering"},v={NAMESPACE:"pj-".concat("video"),THEME:"{namespace}--{theme}",POSTER:"{namespace}-poster",POSTERHIDE:"{namespace}-poster-hide"},m=function(){function e(t,i){u(this,e),this.element=i,this.options=Object.assign({autoplay:!1,controls:!0,loop:!0,muted:!1},t.options),this.instance=t}return p(e,[{key:"init",value:function(e){this.$player=document.createElement("video"),this.$player.autoplay=this.options.autoplay,this.$player.controls=this.options.controls,this.$player.loop=this.options.loop,this.$player.muted=this.options.muted,o.append(this.$player,this.element),e()}},{key:"load",value:function(){this.instance.trigger(f.LOAD),this.setSources(this.options.url),this.bind()}},{key:"bind",value:function(){var e=this;this.listeners={canplay:function(){e.instance.trigger(f.LOADED),e.instance.hidePoster()},play:function(){e.instance.trigger(f.PLAY)},pause:function(){e.instance.trigger(f.PAUSE)},ended:function(){e.instance.trigger(f.ENDED)},waiting:function(){e.instance.trigger(f.BUFFERING)},error:function(t){e.instance.trigger(f.ERROR,t)}},r.each(this.listeners,(function(t,i){e.$player.addEventListener(t,i)}))}},{key:"unbind",value:function(){var e=this;r.each(this.listeners,(function(t,i){e.$player.removeEventListener(t,i)}))}},{key:"setSources",value:function(e){var t=this;s.isArray(e)?e.forEach((function(e){t.addSource(e)})):this.addSource(e)}},{key:"addSource",value:function(e){var t=e.split(".").pop(),i=document.createElement("source");i.src=e,i.type="video/".concat(t),o.append(i,this.$player)}},{key:"setSize",value:function(e,t){i.setStyle({width:e,height:t},this.element),i.setStyle({width:e,height:t},this.$player)}},{key:"swichVideo",value:function(e){this.pause(),this.$player.innerHTML="",this.setSources(e),this.$player.load()}},{key:"currentTime",value:function(){return this.$player.currentTime}},{key:"duration",value:function(){return this.$player.duration}},{key:"setCurrentTime",value:function(e){this.$player.currentTime=e}},{key:"pause",value:function(){this.$player.pause()}},{key:"play",value:function(){this.$player.play()}},{key:"mute",value:function(){this.$player.muted=!0}},{key:"unMute",value:function(){this.$player.muted=!1}},{key:"stop",value:function(){this.$player.currentTime=0,this.$player.pause(),this.instance.trigger(f.STOP)}},{key:"volume",value:function(e){this.$player.volume=e/100}},{key:"destroy",value:function(){this.unbind(),this.$player.remove()}}]),e}();window.PJVIMEOAPIREADY=!1;var g=function(){function e(t,i){u(this,e),this.element=i,this.options=Object.assign({autopause:!0,autoplay:!1,background:!t.options.controls,byline:!1,color:"#00adef",loop:!0,muted:!1,playsinline:!0,portrait:!1,speed:!1,title:!1,transparent:!1},t.options),this.instance=t}return p(e,[{key:"init",value:function(e){this._duration=null,this._currentTime=null,this.$player=document.createElement("div"),i.setStyle({width:this.options.width,height:this.options.height},this.$player),o.append(this.$player,this.element),window.PJVIMEOAPIREADY?e():(a.emitter.on("video:vimeo:ready",(function(){e()})),this.constructor.prepare())}},{key:"load",value:function(){this.instance.trigger(f.LOAD);var e=this.options;this.api=new window.Vimeo.Player(this.$player,{id:this.getId(),autopause:e.autopause,autoplay:e.autoplay,background:e.background,byline:e.byline,color:e.color,loop:e.loop,muted:e.muted,playsinline:e.playsinline,portrait:e.portrait,speed:e.speed,title:e.title,transparent:e.transparent}),this.bind()}},{key:"getId",value:function(){return this.options.id?this.options.id:this.options.url?this.options.url.split("/")[3].split("?")[0]:void 0}},{key:"bind",value:function(){var e=this;this.api.on("play",(function(){e.instance.trigger(f.PLAY)})),this.api.on("pause",(function(){e.instance.trigger(f.PAUSE)})),this.api.on("ended",(function(){e.instance.trigger(f.ENDED)})),this.api.on("loaded",(function(){e.instance.trigger(f.LOADED),e.instance.hidePoster(),e.$iframe=o.query("iframe",e.$player),e.$iframe.setAttribute("width","100%"),e.$iframe.setAttribute("height","100%"),e.options.background&&!e.options.muted&&e.volume(50),e.api.getDuration().then((function(t){e._duration=t}))})),this.api.on("timeupdate",(function(t){e._currentTime=t.seconds})),this.api.on("error",(function(t){e.instance.trigger(f.ERROR,t)})),this.api.on("bufferstart",(function(){e.instance.trigger(f.BUFFERING)}))}},{key:"setSize",value:function(e,t){i.setStyle({width:e,height:t},this.element),i.setStyle({width:e,height:t},this.$player)}},{key:"swichVideo",value:function(e){this.api.loadVideo(e)}},{key:"currentTime",value:function(){return this._currentTime}},{key:"duration",value:function(){return this._duration}},{key:"setCurrentTime",value:function(e){this.api.setCurrentTime(e)}},{key:"stop",value:function(){this.api.setCurrentTime(0),this.api.pause(),this.instance.trigger(f.STOP)}},{key:"mute",value:function(){var e=this;this.api.getVolume().then((function(t){e._preVolume=t})),this.volume(0)}},{key:"unMute",value:function(){this._preVolume&&this.api.setVolume(this._preVolume)}},{key:"pause",value:function(){this.api.pause()}},{key:"volume",value:function(e){return void 0===e?this.api.getVolume():this.api.setVolume(e/100)}},{key:"play",value:function(){this.api.play()}},{key:"destroy",value:function(){this.api&&this.api.destroy(),this.$player.remove()}}],[{key:"prepare",value:function(){if(!window.PJVIMEOAPIREADY){var e=document.createElement("script");e.onload=function(){window.PJVIMEOAPIREADY=!0,a.emitter.emit("video:vimeo:ready")},e.src="https://player.vimeo.com/api/player.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}}}]),e}();window.PJYTAPIREADY=!1;var k,E=function(){function e(t,i){u(this,e),this.element=i,this.options=Object.assign({autoplay:!0,controls:!1,muted:!1,disablekb:!1,fs:!1,iv_load_policy:!0,loop:!0,modestbranding:!1,playsinline:!0,rel:!1,showinfo:!1},t.options),this.instance=t}return p(e,[{key:"init",value:function(e){this.$player=document.createElement("div"),o.append(this.$player,this.element),window.PJYTAPIREADY?e():(a.emitter.on("video:youtube:ready",(function(){e()})),this.constructor.prepare())}},{key:"load",value:function(){var e=this;this.instance.trigger(f.LOAD);var t=this.options;this.api=new window.YT.Player(this.$player,{videoId:this.getId(),width:t.width,height:t.height,playerVars:{autoplay:t.autoplay?1:0,cc_load_policy:t.cc_load_policy?1:0,controls:t.controls?2:0,disablekb:t.keyboard?0:1,enablejsapi:0,fs:t.fullscreen?1:0,iv_load_policy:t.iv_load_policy?1:3,loop:t.loop?0:1,modestbranding:t.modestbranding?1:0,origin:window.location.origin,playsinline:t.playsinline?1:0,rel:t.rel?1:0,showinfo:t.showinfo?1:0,wmode:"opaque"},events:{onReady:function(){e.instance.trigger(f.LOADED),e.instance.hidePoster(),t.muted&&e.api.mute()},onStateChange:function(t){1===t.data?e.instance.trigger(f.PLAY):2===t.data?e.instance.trigger(f.PAUSE):0===t.data?e.instance.trigger(f.ENDED):3===t.data&&e.instance.trigger(f.BUFFERING)},onError:function(t){e.instance.trigger(f.ERROR,t)}}})}},{key:"getId",value:function(){return this.options.id?this.options.id:this.options.url?this.options.url.split("/")[3].split("?v=")[1]:void 0}},{key:"setSize",value:function(e,t){i.setStyle({width:e,height:t},this.element),i.setStyle({width:e,height:t},this.element)}},{key:"swichVideo",value:function(e){this.api.loadVideoById({videoId:e})}},{key:"currentTime",value:function(){return this.api.getCurrentTime()}},{key:"duration",value:function(){return this.api.getDuration()}},{key:"setCurrentTime",value:function(e){this.api.seekTo(e,!0)}},{key:"volume",value:function(e){this.api.setVolume(e)}},{key:"mute",value:function(){this.api.mute()}},{key:"unMute",value:function(){this.api.unMute()}},{key:"pause",value:function(){this.api.pauseVideo()}},{key:"stop",value:function(){this.api.stopVideo(),this.instance.trigger(f.STOP)}},{key:"play",value:function(){this.api.playVideo()}},{key:"destroy",value:function(){this.api&&this.api.destroy(),this.$player.remove()}}],[{key:"prepare",value:function(){window.onYouTubeIframeAPIReady=function(){window.PJYTAPIREADY=!0,a.emitter.emit("video:youtube:ready")};var e=document.createElement("script");e.src="https://www.youtube.com/iframe_api";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}}]),e}(),w={},b=t.styleable(v)(k=t.eventable(f)(k=t.stateable()(k=t.optionable({width:"100%",height:"100%",url:"",id:"",type:"",autoplay:!1,loop:!0,controls:!0,muted:!1,poster:""},!0)(k=t.register("video",{methods:["enable","disable","destroy","pause","load","play","stop","volume","setSize","swichVideo","duration","currentTime","mute","unMute","setCurrentTime"]})(k=function(e){function t(e){var i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return u(this,t),(i=d(this,c(t).call(this,e))).setupOptions(n),i.setupClasses(),i.setupStates(),i.initialize(),i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}(t,e),p(t,[{key:"initialize",value:function(){var e=this;this.initVideo(),this.initPoster(),void 0!==w[this.options.type]&&(this.player=new w[this.options.type](this,this.$video)),this.player.init((function(){e.load(),e.enter("initialized"),e.trigger(f.READY)}))}},{key:"initVideo",value:function(){this.$video=this.element,n.addClass(this.classes.NAMESPACE,this.$video),this.options.theme&&n.addClass(this.getThemeClass(),this.$video)}},{key:"initPoster",value:function(){this.options.poster&&(this.$poster=document.createElement("div"),n.addClass(this.classes.POSTER,this.$poster),i.setStyle("background-image","url(".concat(this.options.poster,")"),this.$poster),o.append(this.$poster,this.$video))}},{key:"hidePoster",value:function(){this.options.poster&&n.addClass(this.classes.POSTERHIDE,this.$poster)}},{key:"load",value:function(){this.is("loaded")||(this.player.load(),this.enter("loaded"))}},{key:"switchVideo",value:function(e){this.is("loaded")&&this.player.swichVideo(e)}},{key:"duration",value:function(){if(this.is("loaded"))return this.player.duration()}},{key:"currentTime",value:function(){if(this.is("loaded"))return this.player.currentTime()}},{key:"setCurrentTime",value:function(e){this.is("loaded")&&this.player.setCurrentTime(e)}},{key:"setSize",value:function(e,t){this.is("loaded")&&(this.player.setSize(e,t),this.options.width=e,this.options.height=t)}},{key:"play",value:function(){this.is("loaded")&&this.player.play()}},{key:"stop",value:function(){this.is("loaded")&&this.player.stop()}},{key:"volume",value:function(e){this.is("loaded")&&this.player.volume(e)}},{key:"pause",value:function(){this.is("loaded")&&this.player.pause()}},{key:"mute",value:function(){this.is("loaded")&&this.player.mute()}},{key:"unMute",value:function(){this.is("loaded")&&this.player.unMute()}},{key:"destroy",value:function(){this.is("initialized")&&(this.leave("initialized"),n.removeClass(this.classes.NAMESPACE,this.$video),this.options.theme&&n.removeClass(this.getThemeClass(),this.$video),this.options.poster&&this.$poster.remove(),this.player.destroy()),this.is("loaded")&&this.leave("loaded"),this.trigger(f.DESTROY),y(c(t.prototype),"destroy",this).call(this)}}],[{key:"registerSource",value:function(e,t){w[e]=t}},{key:"prepare",value:function(e){void 0!==w[e]&&"prepare"in w[e]&&w[e].prepare()}}]),t}(e))||k)||k)||k)||k)||k;return b.registerSource("youtube",E),b.registerSource("vimeo",g),b.registerSource("html5",m),b}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@pluginjs/component"),require("@pluginjs/decorator"),require("@pluginjs/styled"),require("@pluginjs/classes"),require("@pluginjs/dom"),require("@pluginjs/is"),require("@pluginjs/utils"),require("@pluginjs/factory")):"function"==typeof define&&define.amd?define(["@pluginjs/component","@pluginjs/decorator","@pluginjs/styled","@pluginjs/classes","@pluginjs/dom","@pluginjs/is","@pluginjs/utils","@pluginjs/factory"],t):(e=e||self)["@pluginjs/video"]=t(e["@pluginjs/component"],e["@pluginjs/decorator"],e["@pluginjs/styled"],e["@pluginjs/classes"],e["@pluginjs/dom"],e["@pluginjs/is"],e["@pluginjs/utils"],e["@pluginjs/factory"])}(this,(function(e,t,i,n,o,s,r,a){"use strict";function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,t,i){return t&&l(e.prototype,t),i&&l(e,i),e}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function y(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var i,n=c(e);if(t){var o=c(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return d(this,i)}}function f(e,t,i){return(f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=c(e)););return e}(e,t);if(n){var o=Object.getOwnPropertyDescriptor(n,t);return o.get?o.get.call(i):o.value}})(e,t,i||e)}e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,a=a&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a;var v={READY:"ready",DESTROY:"destroy",LOAD:"load",LOADED:"loaded",PLAY:"play",PAUSE:"pause",STOP:"stop",ENDED:"ended",ERROR:"error",BUFFERING:"buffering"},m={NAMESPACE:"pj-".concat("video"),THEME:"{namespace}--{theme}",POSTER:"{namespace}-poster",POSTERHIDE:"{namespace}-poster-hide"},g=function(){function e(t,i){u(this,e),this.element=i,this.options=Object.assign({autoplay:!1,controls:!0,loop:!0,muted:!1},t.options),this.instance=t}return p(e,[{key:"init",value:function(e){this.$player=document.createElement("video"),this.$player.autoplay=this.options.autoplay,this.$player.controls=this.options.controls,this.$player.loop=this.options.loop,this.$player.muted=this.options.muted,o.append(this.$player,this.element),e()}},{key:"load",value:function(){this.instance.trigger(v.LOAD),this.setSources(this.options.url),this.bind()}},{key:"bind",value:function(){var e=this;this.listeners={canplay:function(){e.instance.trigger(v.LOADED),e.instance.hidePoster()},play:function(){e.instance.trigger(v.PLAY)},pause:function(){e.instance.trigger(v.PAUSE)},ended:function(){e.instance.trigger(v.ENDED)},waiting:function(){e.instance.trigger(v.BUFFERING)},error:function(t){e.instance.trigger(v.ERROR,t)}},r.each(this.listeners,(function(t,i){e.$player.addEventListener(t,i)}))}},{key:"unbind",value:function(){var e=this;r.each(this.listeners,(function(t,i){e.$player.removeEventListener(t,i)}))}},{key:"setSources",value:function(e){var t=this;s.isArray(e)?e.forEach((function(e){t.addSource(e)})):this.addSource(e)}},{key:"addSource",value:function(e){var t=e.split(".").pop(),i=document.createElement("source");i.src=e,i.type="video/".concat(t),o.append(i,this.$player)}},{key:"setSize",value:function(e,t){i.setStyle({width:e,height:t},this.element),i.setStyle({width:e,height:t},this.$player)}},{key:"swichVideo",value:function(e){this.pause(),this.$player.innerHTML="",this.setSources(e),this.$player.load()}},{key:"currentTime",value:function(){return this.$player.currentTime}},{key:"duration",value:function(){return this.$player.duration}},{key:"setCurrentTime",value:function(e){this.$player.currentTime=e}},{key:"pause",value:function(){this.$player.pause()}},{key:"play",value:function(){this.$player.play()}},{key:"mute",value:function(){this.$player.muted=!0}},{key:"unMute",value:function(){this.$player.muted=!1}},{key:"stop",value:function(){this.$player.currentTime=0,this.$player.pause(),this.instance.trigger(v.STOP)}},{key:"volume",value:function(e){this.$player.volume=e/100}},{key:"destroy",value:function(){this.unbind(),this.$player.remove()}}]),e}();window.PJVIMEOAPIREADY=!1;var k=function(){function e(t,i){u(this,e),this.element=i,this.options=Object.assign({autopause:!0,autoplay:!1,background:!t.options.controls,byline:!1,color:"#00adef",loop:!0,muted:!1,playsinline:!0,portrait:!1,speed:!1,title:!1,transparent:!1},t.options),this.instance=t}return p(e,[{key:"init",value:function(e){this._duration=null,this._currentTime=null,this.$player=document.createElement("div"),i.setStyle({width:this.options.width,height:this.options.height},this.$player),o.append(this.$player,this.element),window.PJVIMEOAPIREADY?e():(a.emitter.on("video:vimeo:ready",(function(){e()})),this.constructor.prepare())}},{key:"load",value:function(){this.instance.trigger(v.LOAD);var e=this.options;this.api=new window.Vimeo.Player(this.$player,{id:this.getId(),autopause:e.autopause,autoplay:e.autoplay,background:e.background,byline:e.byline,color:e.color,loop:e.loop,muted:e.muted,playsinline:e.playsinline,portrait:e.portrait,speed:e.speed,title:e.title,transparent:e.transparent}),this.bind()}},{key:"getId",value:function(){return this.options.id?this.options.id:this.options.url?this.options.url.split("/")[3].split("?")[0]:void 0}},{key:"bind",value:function(){var e=this;this.api.on("play",(function(){e.instance.trigger(v.PLAY)})),this.api.on("pause",(function(){e.instance.trigger(v.PAUSE)})),this.api.on("ended",(function(){e.instance.trigger(v.ENDED)})),this.api.on("loaded",(function(){e.instance.trigger(v.LOADED),e.instance.hidePoster(),e.$iframe=o.query("iframe",e.$player),e.$iframe.setAttribute("width","100%"),e.$iframe.setAttribute("height","100%"),e.options.background&&!e.options.muted&&e.volume(50),e.api.getDuration().then((function(t){e._duration=t}))})),this.api.on("timeupdate",(function(t){e._currentTime=t.seconds})),this.api.on("error",(function(t){e.instance.trigger(v.ERROR,t)})),this.api.on("bufferstart",(function(){e.instance.trigger(v.BUFFERING)}))}},{key:"setSize",value:function(e,t){i.setStyle({width:e,height:t},this.element),i.setStyle({width:e,height:t},this.$player)}},{key:"swichVideo",value:function(e){this.api.loadVideo(e)}},{key:"currentTime",value:function(){return this._currentTime}},{key:"duration",value:function(){return this._duration}},{key:"setCurrentTime",value:function(e){this.api.setCurrentTime(e)}},{key:"stop",value:function(){this.api.setCurrentTime(0),this.api.pause(),this.instance.trigger(v.STOP)}},{key:"mute",value:function(){var e=this;this.api.getVolume().then((function(t){e._preVolume=t})),this.volume(0)}},{key:"unMute",value:function(){this._preVolume&&this.api.setVolume(this._preVolume)}},{key:"pause",value:function(){this.api.pause()}},{key:"volume",value:function(e){return void 0===e?this.api.getVolume():this.api.setVolume(e/100)}},{key:"play",value:function(){this.api.play()}},{key:"destroy",value:function(){this.api&&this.api.destroy(),this.$player.remove()}}],[{key:"prepare",value:function(){if(!window.PJVIMEOAPIREADY){var e=document.createElement("script");e.onload=function(){window.PJVIMEOAPIREADY=!0,a.emitter.emit("video:vimeo:ready")},e.src="https://player.vimeo.com/api/player.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}}}]),e}();window.PJYTAPIREADY=!1;var E,w=function(){function e(t,i){u(this,e),this.element=i,this.options=Object.assign({autoplay:!0,controls:!1,muted:!1,disablekb:!1,fs:!1,iv_load_policy:!0,loop:!0,modestbranding:!1,playsinline:!0,rel:!1,showinfo:!1},t.options),this.instance=t}return p(e,[{key:"init",value:function(e){this.$player=document.createElement("div"),o.append(this.$player,this.element),window.PJYTAPIREADY?e():(a.emitter.on("video:youtube:ready",(function(){e()})),this.constructor.prepare())}},{key:"load",value:function(){var e=this;this.instance.trigger(v.LOAD);var t=this.options;this.api=new window.YT.Player(this.$player,{videoId:this.getId(),width:t.width,height:t.height,playerVars:{autoplay:t.autoplay?1:0,cc_load_policy:t.cc_load_policy?1:0,controls:t.controls?2:0,disablekb:t.keyboard?0:1,enablejsapi:0,fs:t.fullscreen?1:0,iv_load_policy:t.iv_load_policy?1:3,loop:t.loop?0:1,modestbranding:t.modestbranding?1:0,origin:window.location.origin,playsinline:t.playsinline?1:0,rel:t.rel?1:0,showinfo:t.showinfo?1:0,wmode:"opaque"},events:{onReady:function(){e.instance.trigger(v.LOADED),e.instance.hidePoster(),t.muted&&e.api.mute()},onStateChange:function(t){1===t.data?e.instance.trigger(v.PLAY):2===t.data?e.instance.trigger(v.PAUSE):0===t.data?e.instance.trigger(v.ENDED):3===t.data&&e.instance.trigger(v.BUFFERING)},onError:function(t){e.instance.trigger(v.ERROR,t)}}})}},{key:"getId",value:function(){return this.options.id?this.options.id:this.options.url?this.options.url.split("/")[3].split("?v=")[1]:void 0}},{key:"setSize",value:function(e,t){i.setStyle({width:e,height:t},this.element),i.setStyle({width:e,height:t},this.element)}},{key:"swichVideo",value:function(e){this.api.loadVideoById({videoId:e})}},{key:"currentTime",value:function(){return this.api.getCurrentTime()}},{key:"duration",value:function(){return this.api.getDuration()}},{key:"setCurrentTime",value:function(e){this.api.seekTo(e,!0)}},{key:"volume",value:function(e){this.api.setVolume(e)}},{key:"mute",value:function(){this.api.mute()}},{key:"unMute",value:function(){this.api.unMute()}},{key:"pause",value:function(){this.api.pauseVideo()}},{key:"stop",value:function(){this.api.stopVideo(),this.instance.trigger(v.STOP)}},{key:"play",value:function(){this.api.playVideo()}},{key:"destroy",value:function(){this.api&&this.api.destroy(),this.$player.remove()}}],[{key:"prepare",value:function(){window.onYouTubeIframeAPIReady=function(){window.PJYTAPIREADY=!0,a.emitter.emit("video:youtube:ready")};var e=document.createElement("script");e.src="https://www.youtube.com/iframe_api";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}}]),e}(),b={},P=t.styleable(m)(E=t.eventable(v)(E=t.stateable()(E=t.optionable({width:"100%",height:"100%",url:"",id:"",type:"",autoplay:!1,loop:!0,controls:!0,muted:!1,poster:""},!0)(E=t.register("video",{methods:["enable","disable","destroy","pause","load","play","stop","volume","setSize","swichVideo","duration","currentTime","mute","unMute","setCurrentTime"]})(E=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}(s,e);var t=y(s);function s(e){var i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return u(this,s),(i=t.call(this,e)).setupOptions(n),i.setupClasses(),i.setupStates(),i.initialize(),i}return p(s,[{key:"initialize",value:function(){var e=this;this.initVideo(),this.initPoster(),void 0!==b[this.options.type]&&(this.player=new b[this.options.type](this,this.$video)),this.player.init((function(){e.load(),e.enter("initialized"),e.trigger(v.READY)}))}},{key:"initVideo",value:function(){this.$video=this.element,n.addClass(this.classes.NAMESPACE,this.$video),this.options.theme&&n.addClass(this.getThemeClass(),this.$video)}},{key:"initPoster",value:function(){this.options.poster&&(this.$poster=document.createElement("div"),n.addClass(this.classes.POSTER,this.$poster),i.setStyle("background-image","url(".concat(this.options.poster,")"),this.$poster),o.append(this.$poster,this.$video))}},{key:"hidePoster",value:function(){this.options.poster&&n.addClass(this.classes.POSTERHIDE,this.$poster)}},{key:"load",value:function(){this.is("loaded")||(this.player.load(),this.enter("loaded"))}},{key:"switchVideo",value:function(e){this.is("loaded")&&this.player.swichVideo(e)}},{key:"duration",value:function(){if(this.is("loaded"))return this.player.duration()}},{key:"currentTime",value:function(){if(this.is("loaded"))return this.player.currentTime()}},{key:"setCurrentTime",value:function(e){this.is("loaded")&&this.player.setCurrentTime(e)}},{key:"setSize",value:function(e,t){this.is("loaded")&&(this.player.setSize(e,t),this.options.width=e,this.options.height=t)}},{key:"play",value:function(){this.is("loaded")&&this.player.play()}},{key:"stop",value:function(){this.is("loaded")&&this.player.stop()}},{key:"volume",value:function(e){this.is("loaded")&&this.player.volume(e)}},{key:"pause",value:function(){this.is("loaded")&&this.player.pause()}},{key:"mute",value:function(){this.is("loaded")&&this.player.mute()}},{key:"unMute",value:function(){this.is("loaded")&&this.player.unMute()}},{key:"destroy",value:function(){this.is("initialized")&&(this.leave("initialized"),n.removeClass(this.classes.NAMESPACE,this.$video),this.options.theme&&n.removeClass(this.getThemeClass(),this.$video),this.options.poster&&this.$poster.remove(),this.player.destroy()),this.is("loaded")&&this.leave("loaded"),this.trigger(v.DESTROY),f(c(s.prototype),"destroy",this).call(this)}}],[{key:"registerSource",value:function(e,t){b[e]=t}},{key:"prepare",value:function(e){void 0!==b[e]&&"prepare"in b[e]&&b[e].prepare()}}]),s}(e))||E)||E)||E)||E)||E;return P.registerSource("youtube",w),P.registerSource("vimeo",k),P.registerSource("html5",g),P}));

@@ -14,3 +14,3 @@ {

},
"version": "0.8.3",
"version": "0.8.4",
"category": "media",

@@ -41,17 +41,17 @@ "main": "dist/video.common.js",

"dependencies": {
"@pluginjs/classes": "^0.8.3",
"@pluginjs/component": "^0.8.3",
"@pluginjs/decorator": "^0.8.3",
"@pluginjs/dom": "^0.8.3",
"@pluginjs/factory": "^0.8.3",
"@pluginjs/is": "^0.8.3",
"@pluginjs/styled": "^0.8.3",
"@pluginjs/utils": "^0.8.3"
"@pluginjs/classes": "^0.8.4",
"@pluginjs/component": "^0.8.4",
"@pluginjs/decorator": "^0.8.4",
"@pluginjs/dom": "^0.8.4",
"@pluginjs/factory": "^0.8.4",
"@pluginjs/is": "^0.8.4",
"@pluginjs/styled": "^0.8.4",
"@pluginjs/utils": "^0.8.4"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@pluginjs/browserslist-config": "^1.3.0",
"@pluginjs/cli": "^0.8.0",
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@babel/core": "^7.10.2",
"@pluginjs/browserslist-config": "^1.3.1",
"@pluginjs/cli": "^0.8.1",
"@rollup/plugin-commonjs": "^12.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"babel-jest": "*",

@@ -61,3 +61,3 @@ "jest": "*",

"rename": "^1.0.4",
"rollup": "^1.31.0",
"rollup": "^2.12.0",
"rollup-plugin-babel": "*",

@@ -81,3 +81,3 @@ "rollup-plugin-terser": "*"

],
"gitHead": "02c3afa7042f2cdee5fd639d3646320bd14e3587"
"gitHead": "c7a30bcc922362e40dbc35af4290a259c9b29566"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc