Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

video-worker

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

video-worker - npm Package Compare versions

Comparing version 2.1.3 to 2.1.4

13

dist/video-worker.esm.js
/*!
* Video Worker v2.1.3 (https://github.com/nk-o/video-worker)
* Video Worker v2.1.4 (https://github.com/nk-o/video-worker)
* Copyright 2022 nK <https://nkdev.info>

@@ -662,9 +662,12 @@ * Licensed under MIT (https://github.com/nk-o/video-worker/blob/master/LICENSE)

// mute
if (self.options.mute) {
self.$video.muted = true;
} else {
// set volume
if (typeof self.options.volume === 'number') {
self.setVolume(self.options.volume);
}
// mute (it is required to mute after the volume set)
if (self.options.mute) {
self.mute();
}
// loop

@@ -671,0 +674,0 @@ if (self.options.loop) {

/*!
* Video Worker v2.1.3 (https://github.com/nk-o/video-worker)
* Video Worker v2.1.4 (https://github.com/nk-o/video-worker)
* Copyright 2022 nK <https://nkdev.info>
* Licensed under MIT (https://github.com/nk-o/video-worker/blob/master/LICENSE)
*/
let e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=e;function o(){this.doneCallbacks=[],this.failCallbacks=[]}o.prototype={execute(e,t){let o=e.length;for(t=Array.prototype.slice.call(t);o;)o-=1,e[o].apply(null,t)},resolve(...e){this.execute(this.doneCallbacks,e)},reject(...e){this.execute(this.failCallbacks,e)},done(e){this.doneCallbacks.push(e)},fail(e){this.failCallbacks.push(e)}};var i={autoplay:!1,loop:!1,mute:!1,volume:100,showControls:!0,accessibilityHidden:!1,startTime:0,endTime:0};let a=0,s=0,l=0,r=0,n=0;const p=new o,d=new o;class u{constructor(e,t){const o=this;o.url=e,o.options_default={...i},o.options=function(e,...t){return e=e||{},Object.keys(t).forEach((o=>{t[o]&&Object.keys(t[o]).forEach((i=>{e[i]=t[o][i]}))})),e}({},o.options_default,t),o.videoID=o.parseURL(e),o.videoID&&(o.ID=a,a+=1,o.loadAPI(),o.init())}parseURL(e){const t=function(e){const t=e.match(/.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|shorts\/|watch\?v=)([^#\&\?]*).*/);return!(!t||11!==t[1].length)&&t[1]}(e),o=function(e){const t=e.match(/https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/);return!(!t||!t[3])&&t[3]}(e),i=function(e){const t=e.split(/,(?=mp4\:|webm\:|ogv\:|ogg\:)/),o={};let i=0;return t.forEach((e=>{const t=e.match(/^(mp4|webm|ogv|ogg)\:(.*)/);t&&t[1]&&t[2]&&(o["ogv"===t[1]?"ogg":t[1]]=t[2],i=1)})),!!i&&o}(e);return t?(this.type="youtube",t):o?(this.type="vimeo",o):!!i&&(this.type="local",i)}isValid(){return!!this.videoID}on(e,t){this.userEventsList=this.userEventsList||[],(this.userEventsList[e]||(this.userEventsList[e]=[])).push(t)}off(e,t){this.userEventsList&&this.userEventsList[e]&&(t?this.userEventsList[e].forEach(((o,i)=>{o===t&&(this.userEventsList[e][i]=!1)})):delete this.userEventsList[e])}fire(e,...t){this.userEventsList&&void 0!==this.userEventsList[e]&&this.userEventsList[e].forEach((e=>{e&&e.apply(this,t)}))}play(e){const o=this;o.player&&("youtube"===o.type&&o.player.playVideo&&(void 0!==e&&o.player.seekTo(e||0),t.YT.PlayerState.PLAYING!==o.player.getPlayerState()&&o.player.playVideo()),"vimeo"===o.type&&(void 0!==e&&o.player.setCurrentTime(e),o.player.getPaused().then((e=>{e&&o.player.play()}))),"local"===o.type&&(void 0!==e&&(o.player.currentTime=e),o.player.paused&&o.player.play()))}pause(){const e=this;e.player&&("youtube"===e.type&&e.player.pauseVideo&&t.YT.PlayerState.PLAYING===e.player.getPlayerState()&&e.player.pauseVideo(),"vimeo"===e.type&&e.player.getPaused().then((t=>{t||e.player.pause()})),"local"===e.type&&(e.player.paused||e.player.pause()))}mute(){const e=this;e.player&&("youtube"===e.type&&e.player.mute&&e.player.mute(),"vimeo"===e.type&&e.player.setVolume&&e.setVolume(0),"local"===e.type&&(e.$video.muted=!0))}unmute(){const e=this;e.player&&("youtube"===e.type&&e.player.mute&&e.player.unMute(),"vimeo"===e.type&&e.player.setVolume&&e.setVolume(e.options.volume||100),"local"===e.type&&(e.$video.muted=!1))}setVolume(e=!1){const t=this;t.player&&"number"==typeof e&&("youtube"===t.type&&t.player.setVolume&&t.player.setVolume(e),"vimeo"===t.type&&t.player.setVolume&&t.player.setVolume(e/100),"local"===t.type&&(t.$video.volume=e/100))}getVolume(e){const t=this;t.player?("youtube"===t.type&&t.player.getVolume&&e(t.player.getVolume()),"vimeo"===t.type&&t.player.getVolume&&t.player.getVolume().then((t=>{e(100*t)})),"local"===t.type&&e(100*t.$video.volume)):e(!1)}getMuted(e){const t=this;t.player?("youtube"===t.type&&t.player.isMuted&&e(t.player.isMuted()),"vimeo"===t.type&&t.player.getVolume&&t.player.getVolume().then((t=>{e(!!t)})),"local"===t.type&&e(t.$video.muted)):e(null)}getImageURL(e){const o=this;if(o.videoImage)e(o.videoImage);else{if("youtube"===o.type){const t=["maxresdefault","sddefault","hqdefault","0"];let i=0;const a=new Image;a.onload=function(){120!==(this.naturalWidth||this.width)||i===t.length-1?(o.videoImage=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`,e(o.videoImage)):(i+=1,this.src=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`)},a.src=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`}if("vimeo"===o.type){let i=t.innerWidth||1920;t.devicePixelRatio&&(i*=t.devicePixelRatio),i=Math.min(i,1920);let a=new XMLHttpRequest;a.open("GET",`https://vimeo.com/api/oembed.json?url=${o.url}&width=${i}`,!0),a.onreadystatechange=function(){if(4===this.readyState&&this.status>=200&&this.status<400){const t=JSON.parse(this.responseText);t.thumbnail_url&&(o.videoImage=t.thumbnail_url,e(o.videoImage))}},a.send(),a=null}}}getIframe(e){this.getVideo(e)}getVideo(e){const o=this;o.$video?e(o.$video):o.onAPIready((()=>{let i;if(o.$video||(i=document.createElement("div"),i.style.display="none"),"youtube"===o.type){let e,a;o.playerOptions={host:"https://www.youtube-nocookie.com",videoId:o.videoID,playerVars:{autohide:1,rel:0,autoplay:0,playsinline:1}},o.options.showControls||(o.playerOptions.playerVars.iv_load_policy=3,o.playerOptions.playerVars.modestbranding=1,o.playerOptions.playerVars.controls=0,o.playerOptions.playerVars.showinfo=0,o.playerOptions.playerVars.disablekb=1),o.playerOptions.events={onReady(e){if(o.options.mute?e.target.mute():"number"==typeof o.options.volume&&e.target.setVolume(o.options.volume),o.options.autoplay&&o.play(o.options.startTime),o.fire("ready",e),o.options.loop&&!o.options.endTime){const e=.1;o.options.endTime=o.player.getDuration()-e}setInterval((()=>{o.getVolume((t=>{o.options.volume!==t&&(o.options.volume=t,o.fire("volumechange",e))}))}),150)},onStateChange(i){o.options.loop&&i.data===t.YT.PlayerState.ENDED&&o.play(o.options.startTime),e||i.data!==t.YT.PlayerState.PLAYING||(e=1,o.fire("started",i)),i.data===t.YT.PlayerState.PLAYING&&o.fire("play",i),i.data===t.YT.PlayerState.PAUSED&&o.fire("pause",i),i.data===t.YT.PlayerState.ENDED&&o.fire("ended",i),i.data===t.YT.PlayerState.PLAYING?a=setInterval((()=>{o.fire("timeupdate",i),o.options.endTime&&o.player.getCurrentTime()>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())}),150):clearInterval(a)},onError(e){o.fire("error",e)}};const s=!o.$video;if(s){const e=document.createElement("div");e.setAttribute("id",o.playerID),i.appendChild(e),document.body.appendChild(i)}o.player=o.player||new t.YT.Player(o.playerID,o.playerOptions),s&&(o.$video=document.getElementById(o.playerID),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),o.videoWidth=parseInt(o.$video.getAttribute("width"),10)||1280,o.videoHeight=parseInt(o.$video.getAttribute("height"),10)||720)}if("vimeo"===o.type){if(o.playerOptions={dnt:1,id:o.videoID,autopause:0,transparent:0,autoplay:o.options.autoplay?1:0,loop:o.options.loop?1:0,muted:o.options.mute||0===o.options.volume?1:0},o.options.showControls||(o.playerOptions.controls=0),!o.options.showControls&&o.options.loop&&o.options.autoplay&&(o.playerOptions.background=1),!o.$video){let e="";Object.keys(o.playerOptions).forEach((t=>{""!==e&&(e+="&"),e+=`${t}=${encodeURIComponent(o.playerOptions[t])}`})),o.$video=document.createElement("iframe"),o.$video.setAttribute("id",o.playerID),o.$video.setAttribute("src",`https://player.vimeo.com/video/${o.videoID}?${e}`),o.$video.setAttribute("frameborder","0"),o.$video.setAttribute("mozallowfullscreen",""),o.$video.setAttribute("allowfullscreen",""),o.$video.setAttribute("title","Vimeo video player"),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),i.appendChild(o.$video),document.body.appendChild(i)}let e;o.player=o.player||new t.Vimeo.Player(o.$video,o.playerOptions),o.options.mute||"number"!=typeof o.options.volume||o.setVolume(o.options.volume),o.options.startTime&&o.options.autoplay&&o.player.setCurrentTime(o.options.startTime),o.player.getVideoWidth().then((e=>{o.videoWidth=e||1280})),o.player.getVideoHeight().then((e=>{o.videoHeight=e||720})),o.player.on("timeupdate",(t=>{e||(o.fire("started",t),e=1),o.fire("timeupdate",t),o.options.endTime&&o.options.endTime&&t.seconds>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())})),o.player.on("play",(e=>{o.fire("play",e),o.options.startTime&&0===e.seconds&&o.play(o.options.startTime)})),o.player.on("pause",(e=>{o.fire("pause",e)})),o.player.on("ended",(e=>{o.fire("ended",e)})),o.player.on("loaded",(e=>{o.fire("ready",e)})),o.player.on("volumechange",(e=>{o.getVolume((e=>{o.options.volume=e})),o.fire("volumechange",e)})),o.player.on("error",(e=>{o.fire("error",e)}))}if("local"===o.type){let e;o.$video||(o.$video=document.createElement("video"),o.options.showControls&&(o.$video.controls=!0),o.options.mute?o.$video.muted=!0:o.setVolume(o.options.volume),o.options.loop&&(o.$video.loop=!0),o.$video.setAttribute("playsinline",""),o.$video.setAttribute("webkit-playsinline",""),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),o.$video.setAttribute("id",o.playerID),i.appendChild(o.$video),document.body.appendChild(i),Object.keys(o.videoID).forEach((e=>{!function(e,t,o){const i=document.createElement("source");i.src=t,i.type=o,e.appendChild(i)}(o.$video,o.videoID[e],`video/${e}`)}))),o.player=o.player||o.$video,o.player.addEventListener("playing",(t=>{e||o.fire("started",t),e=1})),o.player.addEventListener("timeupdate",(function(e){o.fire("timeupdate",e),o.options.endTime&&o.options.endTime&&this.currentTime>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())})),o.player.addEventListener("play",(e=>{o.fire("play",e)})),o.player.addEventListener("pause",(e=>{o.fire("pause",e)})),o.player.addEventListener("ended",(e=>{o.fire("ended",e)})),o.player.addEventListener("loadedmetadata",(function(){o.videoWidth=this.videoWidth||1280,o.videoHeight=this.videoHeight||720,o.fire("ready"),o.options.autoplay&&o.play(o.options.startTime)})),o.player.addEventListener("volumechange",(e=>{o.getVolume((e=>{o.options.volume=e})),o.fire("volumechange",e)})),o.player.addEventListener("error",(e=>{o.fire("error",e)}))}e(o.$video)}))}init(){this.playerID=`VideoWorker-${this.ID}`}loadAPI(){if(s&&l)return;let e="";if("youtube"!==this.type||s||(s=1,e="https://www.youtube.com/iframe_api"),"vimeo"===this.type&&!l){if(l=1,void 0!==t.Vimeo)return;e="https://player.vimeo.com/api/player.js"}if(!e)return;let o=document.createElement("script"),i=document.getElementsByTagName("head")[0];o.src=e,i.appendChild(o),i=null,o=null}onAPIready(e){const o=this;if("youtube"===o.type&&(void 0!==t.YT&&0!==t.YT.loaded||r?"object"==typeof t.YT&&1===t.YT.loaded?e():p.done((()=>{e()})):(r=1,t.onYouTubeIframeAPIReady=function(){t.onYouTubeIframeAPIReady=null,p.resolve("done"),e()})),"vimeo"===o.type)if(void 0!==t.Vimeo||n)void 0!==t.Vimeo?e():d.done((()=>{e()}));else{n=1;const o=setInterval((()=>{void 0!==t.Vimeo&&(clearInterval(o),d.resolve("done"),e())}),20)}"local"===o.type&&e()}}export{u as default};//# sourceMappingURL=video-worker.esm.min.js.map
let e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=e;function o(){this.doneCallbacks=[],this.failCallbacks=[]}o.prototype={execute(e,t){let o=e.length;for(t=Array.prototype.slice.call(t);o;)o-=1,e[o].apply(null,t)},resolve(...e){this.execute(this.doneCallbacks,e)},reject(...e){this.execute(this.failCallbacks,e)},done(e){this.doneCallbacks.push(e)},fail(e){this.failCallbacks.push(e)}};var i={autoplay:!1,loop:!1,mute:!1,volume:100,showControls:!0,accessibilityHidden:!1,startTime:0,endTime:0};let a=0,s=0,l=0,r=0,n=0;const p=new o,d=new o;class u{constructor(e,t){const o=this;o.url=e,o.options_default={...i},o.options=function(e,...t){return e=e||{},Object.keys(t).forEach((o=>{t[o]&&Object.keys(t[o]).forEach((i=>{e[i]=t[o][i]}))})),e}({},o.options_default,t),o.videoID=o.parseURL(e),o.videoID&&(o.ID=a,a+=1,o.loadAPI(),o.init())}parseURL(e){const t=function(e){const t=e.match(/.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|shorts\/|watch\?v=)([^#\&\?]*).*/);return!(!t||11!==t[1].length)&&t[1]}(e),o=function(e){const t=e.match(/https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/);return!(!t||!t[3])&&t[3]}(e),i=function(e){const t=e.split(/,(?=mp4\:|webm\:|ogv\:|ogg\:)/),o={};let i=0;return t.forEach((e=>{const t=e.match(/^(mp4|webm|ogv|ogg)\:(.*)/);t&&t[1]&&t[2]&&(o["ogv"===t[1]?"ogg":t[1]]=t[2],i=1)})),!!i&&o}(e);return t?(this.type="youtube",t):o?(this.type="vimeo",o):!!i&&(this.type="local",i)}isValid(){return!!this.videoID}on(e,t){this.userEventsList=this.userEventsList||[],(this.userEventsList[e]||(this.userEventsList[e]=[])).push(t)}off(e,t){this.userEventsList&&this.userEventsList[e]&&(t?this.userEventsList[e].forEach(((o,i)=>{o===t&&(this.userEventsList[e][i]=!1)})):delete this.userEventsList[e])}fire(e,...t){this.userEventsList&&void 0!==this.userEventsList[e]&&this.userEventsList[e].forEach((e=>{e&&e.apply(this,t)}))}play(e){const o=this;o.player&&("youtube"===o.type&&o.player.playVideo&&(void 0!==e&&o.player.seekTo(e||0),t.YT.PlayerState.PLAYING!==o.player.getPlayerState()&&o.player.playVideo()),"vimeo"===o.type&&(void 0!==e&&o.player.setCurrentTime(e),o.player.getPaused().then((e=>{e&&o.player.play()}))),"local"===o.type&&(void 0!==e&&(o.player.currentTime=e),o.player.paused&&o.player.play()))}pause(){const e=this;e.player&&("youtube"===e.type&&e.player.pauseVideo&&t.YT.PlayerState.PLAYING===e.player.getPlayerState()&&e.player.pauseVideo(),"vimeo"===e.type&&e.player.getPaused().then((t=>{t||e.player.pause()})),"local"===e.type&&(e.player.paused||e.player.pause()))}mute(){const e=this;e.player&&("youtube"===e.type&&e.player.mute&&e.player.mute(),"vimeo"===e.type&&e.player.setVolume&&e.setVolume(0),"local"===e.type&&(e.$video.muted=!0))}unmute(){const e=this;e.player&&("youtube"===e.type&&e.player.mute&&e.player.unMute(),"vimeo"===e.type&&e.player.setVolume&&e.setVolume(e.options.volume||100),"local"===e.type&&(e.$video.muted=!1))}setVolume(e=!1){const t=this;t.player&&"number"==typeof e&&("youtube"===t.type&&t.player.setVolume&&t.player.setVolume(e),"vimeo"===t.type&&t.player.setVolume&&t.player.setVolume(e/100),"local"===t.type&&(t.$video.volume=e/100))}getVolume(e){const t=this;t.player?("youtube"===t.type&&t.player.getVolume&&e(t.player.getVolume()),"vimeo"===t.type&&t.player.getVolume&&t.player.getVolume().then((t=>{e(100*t)})),"local"===t.type&&e(100*t.$video.volume)):e(!1)}getMuted(e){const t=this;t.player?("youtube"===t.type&&t.player.isMuted&&e(t.player.isMuted()),"vimeo"===t.type&&t.player.getVolume&&t.player.getVolume().then((t=>{e(!!t)})),"local"===t.type&&e(t.$video.muted)):e(null)}getImageURL(e){const o=this;if(o.videoImage)e(o.videoImage);else{if("youtube"===o.type){const t=["maxresdefault","sddefault","hqdefault","0"];let i=0;const a=new Image;a.onload=function(){120!==(this.naturalWidth||this.width)||i===t.length-1?(o.videoImage=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`,e(o.videoImage)):(i+=1,this.src=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`)},a.src=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`}if("vimeo"===o.type){let i=t.innerWidth||1920;t.devicePixelRatio&&(i*=t.devicePixelRatio),i=Math.min(i,1920);let a=new XMLHttpRequest;a.open("GET",`https://vimeo.com/api/oembed.json?url=${o.url}&width=${i}`,!0),a.onreadystatechange=function(){if(4===this.readyState&&this.status>=200&&this.status<400){const t=JSON.parse(this.responseText);t.thumbnail_url&&(o.videoImage=t.thumbnail_url,e(o.videoImage))}},a.send(),a=null}}}getIframe(e){this.getVideo(e)}getVideo(e){const o=this;o.$video?e(o.$video):o.onAPIready((()=>{let i;if(o.$video||(i=document.createElement("div"),i.style.display="none"),"youtube"===o.type){let e,a;o.playerOptions={host:"https://www.youtube-nocookie.com",videoId:o.videoID,playerVars:{autohide:1,rel:0,autoplay:0,playsinline:1}},o.options.showControls||(o.playerOptions.playerVars.iv_load_policy=3,o.playerOptions.playerVars.modestbranding=1,o.playerOptions.playerVars.controls=0,o.playerOptions.playerVars.showinfo=0,o.playerOptions.playerVars.disablekb=1),o.playerOptions.events={onReady(e){if(o.options.mute?e.target.mute():"number"==typeof o.options.volume&&e.target.setVolume(o.options.volume),o.options.autoplay&&o.play(o.options.startTime),o.fire("ready",e),o.options.loop&&!o.options.endTime){const e=.1;o.options.endTime=o.player.getDuration()-e}setInterval((()=>{o.getVolume((t=>{o.options.volume!==t&&(o.options.volume=t,o.fire("volumechange",e))}))}),150)},onStateChange(i){o.options.loop&&i.data===t.YT.PlayerState.ENDED&&o.play(o.options.startTime),e||i.data!==t.YT.PlayerState.PLAYING||(e=1,o.fire("started",i)),i.data===t.YT.PlayerState.PLAYING&&o.fire("play",i),i.data===t.YT.PlayerState.PAUSED&&o.fire("pause",i),i.data===t.YT.PlayerState.ENDED&&o.fire("ended",i),i.data===t.YT.PlayerState.PLAYING?a=setInterval((()=>{o.fire("timeupdate",i),o.options.endTime&&o.player.getCurrentTime()>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())}),150):clearInterval(a)},onError(e){o.fire("error",e)}};const s=!o.$video;if(s){const e=document.createElement("div");e.setAttribute("id",o.playerID),i.appendChild(e),document.body.appendChild(i)}o.player=o.player||new t.YT.Player(o.playerID,o.playerOptions),s&&(o.$video=document.getElementById(o.playerID),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),o.videoWidth=parseInt(o.$video.getAttribute("width"),10)||1280,o.videoHeight=parseInt(o.$video.getAttribute("height"),10)||720)}if("vimeo"===o.type){if(o.playerOptions={dnt:1,id:o.videoID,autopause:0,transparent:0,autoplay:o.options.autoplay?1:0,loop:o.options.loop?1:0,muted:o.options.mute||0===o.options.volume?1:0},o.options.showControls||(o.playerOptions.controls=0),!o.options.showControls&&o.options.loop&&o.options.autoplay&&(o.playerOptions.background=1),!o.$video){let e="";Object.keys(o.playerOptions).forEach((t=>{""!==e&&(e+="&"),e+=`${t}=${encodeURIComponent(o.playerOptions[t])}`})),o.$video=document.createElement("iframe"),o.$video.setAttribute("id",o.playerID),o.$video.setAttribute("src",`https://player.vimeo.com/video/${o.videoID}?${e}`),o.$video.setAttribute("frameborder","0"),o.$video.setAttribute("mozallowfullscreen",""),o.$video.setAttribute("allowfullscreen",""),o.$video.setAttribute("title","Vimeo video player"),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),i.appendChild(o.$video),document.body.appendChild(i)}let e;o.player=o.player||new t.Vimeo.Player(o.$video,o.playerOptions),o.options.mute||"number"!=typeof o.options.volume||o.setVolume(o.options.volume),o.options.startTime&&o.options.autoplay&&o.player.setCurrentTime(o.options.startTime),o.player.getVideoWidth().then((e=>{o.videoWidth=e||1280})),o.player.getVideoHeight().then((e=>{o.videoHeight=e||720})),o.player.on("timeupdate",(t=>{e||(o.fire("started",t),e=1),o.fire("timeupdate",t),o.options.endTime&&o.options.endTime&&t.seconds>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())})),o.player.on("play",(e=>{o.fire("play",e),o.options.startTime&&0===e.seconds&&o.play(o.options.startTime)})),o.player.on("pause",(e=>{o.fire("pause",e)})),o.player.on("ended",(e=>{o.fire("ended",e)})),o.player.on("loaded",(e=>{o.fire("ready",e)})),o.player.on("volumechange",(e=>{o.getVolume((e=>{o.options.volume=e})),o.fire("volumechange",e)})),o.player.on("error",(e=>{o.fire("error",e)}))}if("local"===o.type){let e;o.$video||(o.$video=document.createElement("video"),o.options.showControls&&(o.$video.controls=!0),"number"==typeof o.options.volume&&o.setVolume(o.options.volume),o.options.mute&&o.mute(),o.options.loop&&(o.$video.loop=!0),o.$video.setAttribute("playsinline",""),o.$video.setAttribute("webkit-playsinline",""),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),o.$video.setAttribute("id",o.playerID),i.appendChild(o.$video),document.body.appendChild(i),Object.keys(o.videoID).forEach((e=>{!function(e,t,o){const i=document.createElement("source");i.src=t,i.type=o,e.appendChild(i)}(o.$video,o.videoID[e],`video/${e}`)}))),o.player=o.player||o.$video,o.player.addEventListener("playing",(t=>{e||o.fire("started",t),e=1})),o.player.addEventListener("timeupdate",(function(e){o.fire("timeupdate",e),o.options.endTime&&o.options.endTime&&this.currentTime>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())})),o.player.addEventListener("play",(e=>{o.fire("play",e)})),o.player.addEventListener("pause",(e=>{o.fire("pause",e)})),o.player.addEventListener("ended",(e=>{o.fire("ended",e)})),o.player.addEventListener("loadedmetadata",(function(){o.videoWidth=this.videoWidth||1280,o.videoHeight=this.videoHeight||720,o.fire("ready"),o.options.autoplay&&o.play(o.options.startTime)})),o.player.addEventListener("volumechange",(e=>{o.getVolume((e=>{o.options.volume=e})),o.fire("volumechange",e)})),o.player.addEventListener("error",(e=>{o.fire("error",e)}))}e(o.$video)}))}init(){this.playerID=`VideoWorker-${this.ID}`}loadAPI(){if(s&&l)return;let e="";if("youtube"!==this.type||s||(s=1,e="https://www.youtube.com/iframe_api"),"vimeo"===this.type&&!l){if(l=1,void 0!==t.Vimeo)return;e="https://player.vimeo.com/api/player.js"}if(!e)return;let o=document.createElement("script"),i=document.getElementsByTagName("head")[0];o.src=e,i.appendChild(o),i=null,o=null}onAPIready(e){const o=this;if("youtube"===o.type&&(void 0!==t.YT&&0!==t.YT.loaded||r?"object"==typeof t.YT&&1===t.YT.loaded?e():p.done((()=>{e()})):(r=1,t.onYouTubeIframeAPIReady=function(){t.onYouTubeIframeAPIReady=null,p.resolve("done"),e()})),"vimeo"===o.type)if(void 0!==t.Vimeo||n)void 0!==t.Vimeo?e():d.done((()=>{e()}));else{n=1;const o=setInterval((()=>{void 0!==t.Vimeo&&(clearInterval(o),d.resolve("done"),e())}),20)}"local"===o.type&&e()}}export{u as default};//# sourceMappingURL=video-worker.esm.min.js.map
/*!
* Video Worker v2.1.3 (https://github.com/nk-o/video-worker)
* Video Worker v2.1.4 (https://github.com/nk-o/video-worker)
* Copyright 2022 nK <https://nkdev.info>

@@ -668,9 +668,12 @@ * Licensed under MIT (https://github.com/nk-o/video-worker/blob/master/LICENSE)

// mute
if (self.options.mute) {
self.$video.muted = true;
} else {
// set volume
if (typeof self.options.volume === 'number') {
self.setVolume(self.options.volume);
}
// mute (it is required to mute after the volume set)
if (self.options.mute) {
self.mute();
}
// loop

@@ -677,0 +680,0 @@ if (self.options.loop) {

/*!
* Video Worker v2.1.3 (https://github.com/nk-o/video-worker)
* Video Worker v2.1.4 (https://github.com/nk-o/video-worker)
* Copyright 2022 nK <https://nkdev.info>
* Licensed under MIT (https://github.com/nk-o/video-worker/blob/master/LICENSE)
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VideoWorker=t()}(this,(function(){"use strict";let e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=e;function o(){this.doneCallbacks=[],this.failCallbacks=[]}o.prototype={execute(e,t){let o=e.length;for(t=Array.prototype.slice.call(t);o;)o-=1,e[o].apply(null,t)},resolve(...e){this.execute(this.doneCallbacks,e)},reject(...e){this.execute(this.failCallbacks,e)},done(e){this.doneCallbacks.push(e)},fail(e){this.failCallbacks.push(e)}};var i={autoplay:!1,loop:!1,mute:!1,volume:100,showControls:!0,accessibilityHidden:!1,startTime:0,endTime:0};let a=0,s=0,l=0,n=0,r=0;const p=new o,d=new o;return class{constructor(e,t){const o=this;o.url=e,o.options_default={...i},o.options=function(e,...t){return e=e||{},Object.keys(t).forEach((o=>{t[o]&&Object.keys(t[o]).forEach((i=>{e[i]=t[o][i]}))})),e}({},o.options_default,t),o.videoID=o.parseURL(e),o.videoID&&(o.ID=a,a+=1,o.loadAPI(),o.init())}parseURL(e){const t=function(e){const t=e.match(/.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|shorts\/|watch\?v=)([^#\&\?]*).*/);return!(!t||11!==t[1].length)&&t[1]}(e),o=function(e){const t=e.match(/https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/);return!(!t||!t[3])&&t[3]}(e),i=function(e){const t=e.split(/,(?=mp4\:|webm\:|ogv\:|ogg\:)/),o={};let i=0;return t.forEach((e=>{const t=e.match(/^(mp4|webm|ogv|ogg)\:(.*)/);t&&t[1]&&t[2]&&(o["ogv"===t[1]?"ogg":t[1]]=t[2],i=1)})),!!i&&o}(e);return t?(this.type="youtube",t):o?(this.type="vimeo",o):!!i&&(this.type="local",i)}isValid(){return!!this.videoID}on(e,t){this.userEventsList=this.userEventsList||[],(this.userEventsList[e]||(this.userEventsList[e]=[])).push(t)}off(e,t){this.userEventsList&&this.userEventsList[e]&&(t?this.userEventsList[e].forEach(((o,i)=>{o===t&&(this.userEventsList[e][i]=!1)})):delete this.userEventsList[e])}fire(e,...t){this.userEventsList&&void 0!==this.userEventsList[e]&&this.userEventsList[e].forEach((e=>{e&&e.apply(this,t)}))}play(e){const o=this;o.player&&("youtube"===o.type&&o.player.playVideo&&(void 0!==e&&o.player.seekTo(e||0),t.YT.PlayerState.PLAYING!==o.player.getPlayerState()&&o.player.playVideo()),"vimeo"===o.type&&(void 0!==e&&o.player.setCurrentTime(e),o.player.getPaused().then((e=>{e&&o.player.play()}))),"local"===o.type&&(void 0!==e&&(o.player.currentTime=e),o.player.paused&&o.player.play()))}pause(){const e=this;e.player&&("youtube"===e.type&&e.player.pauseVideo&&t.YT.PlayerState.PLAYING===e.player.getPlayerState()&&e.player.pauseVideo(),"vimeo"===e.type&&e.player.getPaused().then((t=>{t||e.player.pause()})),"local"===e.type&&(e.player.paused||e.player.pause()))}mute(){const e=this;e.player&&("youtube"===e.type&&e.player.mute&&e.player.mute(),"vimeo"===e.type&&e.player.setVolume&&e.setVolume(0),"local"===e.type&&(e.$video.muted=!0))}unmute(){const e=this;e.player&&("youtube"===e.type&&e.player.mute&&e.player.unMute(),"vimeo"===e.type&&e.player.setVolume&&e.setVolume(e.options.volume||100),"local"===e.type&&(e.$video.muted=!1))}setVolume(e=!1){const t=this;t.player&&"number"==typeof e&&("youtube"===t.type&&t.player.setVolume&&t.player.setVolume(e),"vimeo"===t.type&&t.player.setVolume&&t.player.setVolume(e/100),"local"===t.type&&(t.$video.volume=e/100))}getVolume(e){const t=this;t.player?("youtube"===t.type&&t.player.getVolume&&e(t.player.getVolume()),"vimeo"===t.type&&t.player.getVolume&&t.player.getVolume().then((t=>{e(100*t)})),"local"===t.type&&e(100*t.$video.volume)):e(!1)}getMuted(e){const t=this;t.player?("youtube"===t.type&&t.player.isMuted&&e(t.player.isMuted()),"vimeo"===t.type&&t.player.getVolume&&t.player.getVolume().then((t=>{e(!!t)})),"local"===t.type&&e(t.$video.muted)):e(null)}getImageURL(e){const o=this;if(o.videoImage)e(o.videoImage);else{if("youtube"===o.type){const t=["maxresdefault","sddefault","hqdefault","0"];let i=0;const a=new Image;a.onload=function(){120!==(this.naturalWidth||this.width)||i===t.length-1?(o.videoImage=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`,e(o.videoImage)):(i+=1,this.src=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`)},a.src=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`}if("vimeo"===o.type){let i=t.innerWidth||1920;t.devicePixelRatio&&(i*=t.devicePixelRatio),i=Math.min(i,1920);let a=new XMLHttpRequest;a.open("GET",`https://vimeo.com/api/oembed.json?url=${o.url}&width=${i}`,!0),a.onreadystatechange=function(){if(4===this.readyState&&this.status>=200&&this.status<400){const t=JSON.parse(this.responseText);t.thumbnail_url&&(o.videoImage=t.thumbnail_url,e(o.videoImage))}},a.send(),a=null}}}getIframe(e){this.getVideo(e)}getVideo(e){const o=this;o.$video?e(o.$video):o.onAPIready((()=>{let i;if(o.$video||(i=document.createElement("div"),i.style.display="none"),"youtube"===o.type){let e,a;o.playerOptions={host:"https://www.youtube-nocookie.com",videoId:o.videoID,playerVars:{autohide:1,rel:0,autoplay:0,playsinline:1}},o.options.showControls||(o.playerOptions.playerVars.iv_load_policy=3,o.playerOptions.playerVars.modestbranding=1,o.playerOptions.playerVars.controls=0,o.playerOptions.playerVars.showinfo=0,o.playerOptions.playerVars.disablekb=1),o.playerOptions.events={onReady(e){if(o.options.mute?e.target.mute():"number"==typeof o.options.volume&&e.target.setVolume(o.options.volume),o.options.autoplay&&o.play(o.options.startTime),o.fire("ready",e),o.options.loop&&!o.options.endTime){const e=.1;o.options.endTime=o.player.getDuration()-e}setInterval((()=>{o.getVolume((t=>{o.options.volume!==t&&(o.options.volume=t,o.fire("volumechange",e))}))}),150)},onStateChange(i){o.options.loop&&i.data===t.YT.PlayerState.ENDED&&o.play(o.options.startTime),e||i.data!==t.YT.PlayerState.PLAYING||(e=1,o.fire("started",i)),i.data===t.YT.PlayerState.PLAYING&&o.fire("play",i),i.data===t.YT.PlayerState.PAUSED&&o.fire("pause",i),i.data===t.YT.PlayerState.ENDED&&o.fire("ended",i),i.data===t.YT.PlayerState.PLAYING?a=setInterval((()=>{o.fire("timeupdate",i),o.options.endTime&&o.player.getCurrentTime()>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())}),150):clearInterval(a)},onError(e){o.fire("error",e)}};const s=!o.$video;if(s){const e=document.createElement("div");e.setAttribute("id",o.playerID),i.appendChild(e),document.body.appendChild(i)}o.player=o.player||new t.YT.Player(o.playerID,o.playerOptions),s&&(o.$video=document.getElementById(o.playerID),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),o.videoWidth=parseInt(o.$video.getAttribute("width"),10)||1280,o.videoHeight=parseInt(o.$video.getAttribute("height"),10)||720)}if("vimeo"===o.type){if(o.playerOptions={dnt:1,id:o.videoID,autopause:0,transparent:0,autoplay:o.options.autoplay?1:0,loop:o.options.loop?1:0,muted:o.options.mute||0===o.options.volume?1:0},o.options.showControls||(o.playerOptions.controls=0),!o.options.showControls&&o.options.loop&&o.options.autoplay&&(o.playerOptions.background=1),!o.$video){let e="";Object.keys(o.playerOptions).forEach((t=>{""!==e&&(e+="&"),e+=`${t}=${encodeURIComponent(o.playerOptions[t])}`})),o.$video=document.createElement("iframe"),o.$video.setAttribute("id",o.playerID),o.$video.setAttribute("src",`https://player.vimeo.com/video/${o.videoID}?${e}`),o.$video.setAttribute("frameborder","0"),o.$video.setAttribute("mozallowfullscreen",""),o.$video.setAttribute("allowfullscreen",""),o.$video.setAttribute("title","Vimeo video player"),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),i.appendChild(o.$video),document.body.appendChild(i)}let e;o.player=o.player||new t.Vimeo.Player(o.$video,o.playerOptions),o.options.mute||"number"!=typeof o.options.volume||o.setVolume(o.options.volume),o.options.startTime&&o.options.autoplay&&o.player.setCurrentTime(o.options.startTime),o.player.getVideoWidth().then((e=>{o.videoWidth=e||1280})),o.player.getVideoHeight().then((e=>{o.videoHeight=e||720})),o.player.on("timeupdate",(t=>{e||(o.fire("started",t),e=1),o.fire("timeupdate",t),o.options.endTime&&o.options.endTime&&t.seconds>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())})),o.player.on("play",(e=>{o.fire("play",e),o.options.startTime&&0===e.seconds&&o.play(o.options.startTime)})),o.player.on("pause",(e=>{o.fire("pause",e)})),o.player.on("ended",(e=>{o.fire("ended",e)})),o.player.on("loaded",(e=>{o.fire("ready",e)})),o.player.on("volumechange",(e=>{o.getVolume((e=>{o.options.volume=e})),o.fire("volumechange",e)})),o.player.on("error",(e=>{o.fire("error",e)}))}if("local"===o.type){let e;o.$video||(o.$video=document.createElement("video"),o.options.showControls&&(o.$video.controls=!0),o.options.mute?o.$video.muted=!0:o.setVolume(o.options.volume),o.options.loop&&(o.$video.loop=!0),o.$video.setAttribute("playsinline",""),o.$video.setAttribute("webkit-playsinline",""),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),o.$video.setAttribute("id",o.playerID),i.appendChild(o.$video),document.body.appendChild(i),Object.keys(o.videoID).forEach((e=>{!function(e,t,o){const i=document.createElement("source");i.src=t,i.type=o,e.appendChild(i)}(o.$video,o.videoID[e],`video/${e}`)}))),o.player=o.player||o.$video,o.player.addEventListener("playing",(t=>{e||o.fire("started",t),e=1})),o.player.addEventListener("timeupdate",(function(e){o.fire("timeupdate",e),o.options.endTime&&o.options.endTime&&this.currentTime>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())})),o.player.addEventListener("play",(e=>{o.fire("play",e)})),o.player.addEventListener("pause",(e=>{o.fire("pause",e)})),o.player.addEventListener("ended",(e=>{o.fire("ended",e)})),o.player.addEventListener("loadedmetadata",(function(){o.videoWidth=this.videoWidth||1280,o.videoHeight=this.videoHeight||720,o.fire("ready"),o.options.autoplay&&o.play(o.options.startTime)})),o.player.addEventListener("volumechange",(e=>{o.getVolume((e=>{o.options.volume=e})),o.fire("volumechange",e)})),o.player.addEventListener("error",(e=>{o.fire("error",e)}))}e(o.$video)}))}init(){this.playerID=`VideoWorker-${this.ID}`}loadAPI(){if(s&&l)return;let e="";if("youtube"!==this.type||s||(s=1,e="https://www.youtube.com/iframe_api"),"vimeo"===this.type&&!l){if(l=1,void 0!==t.Vimeo)return;e="https://player.vimeo.com/api/player.js"}if(!e)return;let o=document.createElement("script"),i=document.getElementsByTagName("head")[0];o.src=e,i.appendChild(o),i=null,o=null}onAPIready(e){const o=this;if("youtube"===o.type&&(void 0!==t.YT&&0!==t.YT.loaded||n?"object"==typeof t.YT&&1===t.YT.loaded?e():p.done((()=>{e()})):(n=1,t.onYouTubeIframeAPIReady=function(){t.onYouTubeIframeAPIReady=null,p.resolve("done"),e()})),"vimeo"===o.type)if(void 0!==t.Vimeo||r)void 0!==t.Vimeo?e():d.done((()=>{e()}));else{r=1;const o=setInterval((()=>{void 0!==t.Vimeo&&(clearInterval(o),d.resolve("done"),e())}),20)}"local"===o.type&&e()}}}));//# sourceMappingURL=video-worker.min.js.map
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VideoWorker=t()}(this,(function(){"use strict";let e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=e;function o(){this.doneCallbacks=[],this.failCallbacks=[]}o.prototype={execute(e,t){let o=e.length;for(t=Array.prototype.slice.call(t);o;)o-=1,e[o].apply(null,t)},resolve(...e){this.execute(this.doneCallbacks,e)},reject(...e){this.execute(this.failCallbacks,e)},done(e){this.doneCallbacks.push(e)},fail(e){this.failCallbacks.push(e)}};var i={autoplay:!1,loop:!1,mute:!1,volume:100,showControls:!0,accessibilityHidden:!1,startTime:0,endTime:0};let a=0,s=0,l=0,n=0,r=0;const p=new o,d=new o;return class{constructor(e,t){const o=this;o.url=e,o.options_default={...i},o.options=function(e,...t){return e=e||{},Object.keys(t).forEach((o=>{t[o]&&Object.keys(t[o]).forEach((i=>{e[i]=t[o][i]}))})),e}({},o.options_default,t),o.videoID=o.parseURL(e),o.videoID&&(o.ID=a,a+=1,o.loadAPI(),o.init())}parseURL(e){const t=function(e){const t=e.match(/.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|shorts\/|watch\?v=)([^#\&\?]*).*/);return!(!t||11!==t[1].length)&&t[1]}(e),o=function(e){const t=e.match(/https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/);return!(!t||!t[3])&&t[3]}(e),i=function(e){const t=e.split(/,(?=mp4\:|webm\:|ogv\:|ogg\:)/),o={};let i=0;return t.forEach((e=>{const t=e.match(/^(mp4|webm|ogv|ogg)\:(.*)/);t&&t[1]&&t[2]&&(o["ogv"===t[1]?"ogg":t[1]]=t[2],i=1)})),!!i&&o}(e);return t?(this.type="youtube",t):o?(this.type="vimeo",o):!!i&&(this.type="local",i)}isValid(){return!!this.videoID}on(e,t){this.userEventsList=this.userEventsList||[],(this.userEventsList[e]||(this.userEventsList[e]=[])).push(t)}off(e,t){this.userEventsList&&this.userEventsList[e]&&(t?this.userEventsList[e].forEach(((o,i)=>{o===t&&(this.userEventsList[e][i]=!1)})):delete this.userEventsList[e])}fire(e,...t){this.userEventsList&&void 0!==this.userEventsList[e]&&this.userEventsList[e].forEach((e=>{e&&e.apply(this,t)}))}play(e){const o=this;o.player&&("youtube"===o.type&&o.player.playVideo&&(void 0!==e&&o.player.seekTo(e||0),t.YT.PlayerState.PLAYING!==o.player.getPlayerState()&&o.player.playVideo()),"vimeo"===o.type&&(void 0!==e&&o.player.setCurrentTime(e),o.player.getPaused().then((e=>{e&&o.player.play()}))),"local"===o.type&&(void 0!==e&&(o.player.currentTime=e),o.player.paused&&o.player.play()))}pause(){const e=this;e.player&&("youtube"===e.type&&e.player.pauseVideo&&t.YT.PlayerState.PLAYING===e.player.getPlayerState()&&e.player.pauseVideo(),"vimeo"===e.type&&e.player.getPaused().then((t=>{t||e.player.pause()})),"local"===e.type&&(e.player.paused||e.player.pause()))}mute(){const e=this;e.player&&("youtube"===e.type&&e.player.mute&&e.player.mute(),"vimeo"===e.type&&e.player.setVolume&&e.setVolume(0),"local"===e.type&&(e.$video.muted=!0))}unmute(){const e=this;e.player&&("youtube"===e.type&&e.player.mute&&e.player.unMute(),"vimeo"===e.type&&e.player.setVolume&&e.setVolume(e.options.volume||100),"local"===e.type&&(e.$video.muted=!1))}setVolume(e=!1){const t=this;t.player&&"number"==typeof e&&("youtube"===t.type&&t.player.setVolume&&t.player.setVolume(e),"vimeo"===t.type&&t.player.setVolume&&t.player.setVolume(e/100),"local"===t.type&&(t.$video.volume=e/100))}getVolume(e){const t=this;t.player?("youtube"===t.type&&t.player.getVolume&&e(t.player.getVolume()),"vimeo"===t.type&&t.player.getVolume&&t.player.getVolume().then((t=>{e(100*t)})),"local"===t.type&&e(100*t.$video.volume)):e(!1)}getMuted(e){const t=this;t.player?("youtube"===t.type&&t.player.isMuted&&e(t.player.isMuted()),"vimeo"===t.type&&t.player.getVolume&&t.player.getVolume().then((t=>{e(!!t)})),"local"===t.type&&e(t.$video.muted)):e(null)}getImageURL(e){const o=this;if(o.videoImage)e(o.videoImage);else{if("youtube"===o.type){const t=["maxresdefault","sddefault","hqdefault","0"];let i=0;const a=new Image;a.onload=function(){120!==(this.naturalWidth||this.width)||i===t.length-1?(o.videoImage=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`,e(o.videoImage)):(i+=1,this.src=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`)},a.src=`https://img.youtube.com/vi/${o.videoID}/${t[i]}.jpg`}if("vimeo"===o.type){let i=t.innerWidth||1920;t.devicePixelRatio&&(i*=t.devicePixelRatio),i=Math.min(i,1920);let a=new XMLHttpRequest;a.open("GET",`https://vimeo.com/api/oembed.json?url=${o.url}&width=${i}`,!0),a.onreadystatechange=function(){if(4===this.readyState&&this.status>=200&&this.status<400){const t=JSON.parse(this.responseText);t.thumbnail_url&&(o.videoImage=t.thumbnail_url,e(o.videoImage))}},a.send(),a=null}}}getIframe(e){this.getVideo(e)}getVideo(e){const o=this;o.$video?e(o.$video):o.onAPIready((()=>{let i;if(o.$video||(i=document.createElement("div"),i.style.display="none"),"youtube"===o.type){let e,a;o.playerOptions={host:"https://www.youtube-nocookie.com",videoId:o.videoID,playerVars:{autohide:1,rel:0,autoplay:0,playsinline:1}},o.options.showControls||(o.playerOptions.playerVars.iv_load_policy=3,o.playerOptions.playerVars.modestbranding=1,o.playerOptions.playerVars.controls=0,o.playerOptions.playerVars.showinfo=0,o.playerOptions.playerVars.disablekb=1),o.playerOptions.events={onReady(e){if(o.options.mute?e.target.mute():"number"==typeof o.options.volume&&e.target.setVolume(o.options.volume),o.options.autoplay&&o.play(o.options.startTime),o.fire("ready",e),o.options.loop&&!o.options.endTime){const e=.1;o.options.endTime=o.player.getDuration()-e}setInterval((()=>{o.getVolume((t=>{o.options.volume!==t&&(o.options.volume=t,o.fire("volumechange",e))}))}),150)},onStateChange(i){o.options.loop&&i.data===t.YT.PlayerState.ENDED&&o.play(o.options.startTime),e||i.data!==t.YT.PlayerState.PLAYING||(e=1,o.fire("started",i)),i.data===t.YT.PlayerState.PLAYING&&o.fire("play",i),i.data===t.YT.PlayerState.PAUSED&&o.fire("pause",i),i.data===t.YT.PlayerState.ENDED&&o.fire("ended",i),i.data===t.YT.PlayerState.PLAYING?a=setInterval((()=>{o.fire("timeupdate",i),o.options.endTime&&o.player.getCurrentTime()>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())}),150):clearInterval(a)},onError(e){o.fire("error",e)}};const s=!o.$video;if(s){const e=document.createElement("div");e.setAttribute("id",o.playerID),i.appendChild(e),document.body.appendChild(i)}o.player=o.player||new t.YT.Player(o.playerID,o.playerOptions),s&&(o.$video=document.getElementById(o.playerID),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),o.videoWidth=parseInt(o.$video.getAttribute("width"),10)||1280,o.videoHeight=parseInt(o.$video.getAttribute("height"),10)||720)}if("vimeo"===o.type){if(o.playerOptions={dnt:1,id:o.videoID,autopause:0,transparent:0,autoplay:o.options.autoplay?1:0,loop:o.options.loop?1:0,muted:o.options.mute||0===o.options.volume?1:0},o.options.showControls||(o.playerOptions.controls=0),!o.options.showControls&&o.options.loop&&o.options.autoplay&&(o.playerOptions.background=1),!o.$video){let e="";Object.keys(o.playerOptions).forEach((t=>{""!==e&&(e+="&"),e+=`${t}=${encodeURIComponent(o.playerOptions[t])}`})),o.$video=document.createElement("iframe"),o.$video.setAttribute("id",o.playerID),o.$video.setAttribute("src",`https://player.vimeo.com/video/${o.videoID}?${e}`),o.$video.setAttribute("frameborder","0"),o.$video.setAttribute("mozallowfullscreen",""),o.$video.setAttribute("allowfullscreen",""),o.$video.setAttribute("title","Vimeo video player"),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),i.appendChild(o.$video),document.body.appendChild(i)}let e;o.player=o.player||new t.Vimeo.Player(o.$video,o.playerOptions),o.options.mute||"number"!=typeof o.options.volume||o.setVolume(o.options.volume),o.options.startTime&&o.options.autoplay&&o.player.setCurrentTime(o.options.startTime),o.player.getVideoWidth().then((e=>{o.videoWidth=e||1280})),o.player.getVideoHeight().then((e=>{o.videoHeight=e||720})),o.player.on("timeupdate",(t=>{e||(o.fire("started",t),e=1),o.fire("timeupdate",t),o.options.endTime&&o.options.endTime&&t.seconds>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())})),o.player.on("play",(e=>{o.fire("play",e),o.options.startTime&&0===e.seconds&&o.play(o.options.startTime)})),o.player.on("pause",(e=>{o.fire("pause",e)})),o.player.on("ended",(e=>{o.fire("ended",e)})),o.player.on("loaded",(e=>{o.fire("ready",e)})),o.player.on("volumechange",(e=>{o.getVolume((e=>{o.options.volume=e})),o.fire("volumechange",e)})),o.player.on("error",(e=>{o.fire("error",e)}))}if("local"===o.type){let e;o.$video||(o.$video=document.createElement("video"),o.options.showControls&&(o.$video.controls=!0),"number"==typeof o.options.volume&&o.setVolume(o.options.volume),o.options.mute&&o.mute(),o.options.loop&&(o.$video.loop=!0),o.$video.setAttribute("playsinline",""),o.$video.setAttribute("webkit-playsinline",""),o.options.accessibilityHidden&&(o.$video.setAttribute("tabindex","-1"),o.$video.setAttribute("aria-hidden","true")),o.$video.setAttribute("id",o.playerID),i.appendChild(o.$video),document.body.appendChild(i),Object.keys(o.videoID).forEach((e=>{!function(e,t,o){const i=document.createElement("source");i.src=t,i.type=o,e.appendChild(i)}(o.$video,o.videoID[e],`video/${e}`)}))),o.player=o.player||o.$video,o.player.addEventListener("playing",(t=>{e||o.fire("started",t),e=1})),o.player.addEventListener("timeupdate",(function(e){o.fire("timeupdate",e),o.options.endTime&&o.options.endTime&&this.currentTime>=o.options.endTime&&(o.options.loop?o.play(o.options.startTime):o.pause())})),o.player.addEventListener("play",(e=>{o.fire("play",e)})),o.player.addEventListener("pause",(e=>{o.fire("pause",e)})),o.player.addEventListener("ended",(e=>{o.fire("ended",e)})),o.player.addEventListener("loadedmetadata",(function(){o.videoWidth=this.videoWidth||1280,o.videoHeight=this.videoHeight||720,o.fire("ready"),o.options.autoplay&&o.play(o.options.startTime)})),o.player.addEventListener("volumechange",(e=>{o.getVolume((e=>{o.options.volume=e})),o.fire("volumechange",e)})),o.player.addEventListener("error",(e=>{o.fire("error",e)}))}e(o.$video)}))}init(){this.playerID=`VideoWorker-${this.ID}`}loadAPI(){if(s&&l)return;let e="";if("youtube"!==this.type||s||(s=1,e="https://www.youtube.com/iframe_api"),"vimeo"===this.type&&!l){if(l=1,void 0!==t.Vimeo)return;e="https://player.vimeo.com/api/player.js"}if(!e)return;let o=document.createElement("script"),i=document.getElementsByTagName("head")[0];o.src=e,i.appendChild(o),i=null,o=null}onAPIready(e){const o=this;if("youtube"===o.type&&(void 0!==t.YT&&0!==t.YT.loaded||n?"object"==typeof t.YT&&1===t.YT.loaded?e():p.done((()=>{e()})):(n=1,t.onYouTubeIframeAPIReady=function(){t.onYouTubeIframeAPIReady=null,p.resolve("done"),e()})),"vimeo"===o.type)if(void 0!==t.Vimeo||r)void 0!==t.Vimeo?e():d.done((()=>{e()}));else{r=1;const o=setInterval((()=>{void 0!==t.Vimeo&&(clearInterval(o),d.resolve("done"),e())}),20)}"local"===o.type&&e()}}}));//# sourceMappingURL=video-worker.min.js.map
{
"name": "video-worker",
"version": "2.1.3",
"version": "2.1.4",
"description": "API wrapper for Youtube, Vimeo and Self-Hosted videos",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -642,9 +642,12 @@ import global from './utils/global';

// mute
if (self.options.mute) {
self.$video.muted = true;
} else {
// set volume
if (typeof self.options.volume === 'number') {
self.setVolume(self.options.volume);
}
// mute (it is required to mute after the volume set)
if (self.options.mute) {
self.mute();
}
// loop

@@ -651,0 +654,0 @@ if (self.options.loop) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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