@odopod/odo-video
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -1,2 +0,2 @@ | ||
!function(A,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("screenfull")):"function"==typeof define&&define.amd?define(["screenfull"],e):A.OdoVideo=e(A.screenfull)}(this,function(A){"use strict";A=A&&A.hasOwnProperty("default")?A.default:A;var e={Classes:{BASE:"odo-video",IS_PLAYING:"odo-video--playing",IS_FULLSCREEN:"odo-video--fullscreen",IS_MUTED:"odo-video--muted",IS_BUFFERING:"odo-video--buffering",IS_IDLE:"odo-video--idle",NO_FLEXBOX:"odo-video--no-flexbox",CONTROLS_STACKED:"odo-video__controls--stacked",CONTROLS_HIDDEN:"odo-video__controls--hidden",CONTROLS:"odo-video__controls",PLAY_TOGGLE:"odo-video__play-toggle",PLAY_CONTROL:"odo-video__play-control",PAUSE_CONTROL:"odo-video__pause-control",PROGRESS_CONTAINER:"odo-video__progress-container",PROGRESS_HOLDER:"odo-video__progress-holder",BUFFER:"odo-video__buffer",PROGRESS:"odo-video__progress",CURRENT_TIME:"odo-video__current-time",VOLUME:"odo-video__volume",MUTE_CONTROL:"odo-video__mute-control",UNMUTE_CONTROL:"odo-video__unmute-control",FULLSCREEN:"odo-video__fullscreen",FULLSCREEN_CONTROL:"odo-video__fullscreen-control",EXIT_FULLSCREEN_CONTROL:"odo-video__exit-fullscreen-control",FLEXIBLE_SPACE:"odo-video__flexible-space"},Icons:{FULLSCREEN:'<svg viewBox="0 0 16 16" enable-background="new 0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 2H8v2h2.586L8 6.587 9.414 8 12 5.415V8h2V2zM8 9.414L6.586 8 4 10.586V8H2v6h6v-2H5.415z"/></svg>',EXIT_FULLSCREEN:'<svg viewBox="0 0 16 16" enable-background="new 0 0 16 16"><path d="M15 2.4L13.6 1 11 3.6V1H9v6h6V5h-2.6L15 2.4zM5 9H1v2h2.6L1 13.6 2.4 15 5 12.4V15h2V9H5z"/></svg>',AUDIO_ON:'<svg viewBox="0 0 16 16" enable-background="new 0 0 16 16"><path d="M1 5.366v5.294c0 .177.142.32.317.32h2.89c.093 0 .18.034.254.093l4.505 3.743c.16.135.4.018.402-.19l.002-13.25c0-.21-.243-.325-.403-.193L4.47 4.923c-.077.064-.173.098-.27.098H1.33c-.235 0-.33.17-.33.346zm10.292-1.03c-.295-.296-.76-.296-1.057 0-.292.296-.292.775.002 1.07v-.002c.642.652 1.04 1.55 1.04 2.54 0 .992-.396 1.884-1.04 2.535-.294.295-.294.774 0 1.07.143.148.334.222.526.222.19 0 .388-.074.528-.22.91-.922 1.476-2.202 1.476-3.606 0-1.41-.567-2.69-1.476-3.61h.002zm1.71-1.732c-.294-.296-.76-.296-1.053 0-.294.296-.293.772 0 1.066 1.08 1.096 1.754 2.602 1.754 4.273s-.667 3.176-1.753 4.273c-.294.294-.294.77 0 1.067.142.146.337.222.53.222.19 0 .386-.076.526-.222 1.35-1.366 2.19-3.257 2.19-5.34-.008-2.08-.843-3.975-2.194-5.34z"/></svg>',AUDIO_OFF:'<svg viewBox="0 0 16 16" enable-background="new 0 0 16 16"><path d="M1 5.366v5.294c0 .177.142.32.317.32h2.89c.093 0 .18.034.254.093l4.505 3.743c.16.135.4.018.402-.19l.002-13.25c0-.21-.243-.325-.403-.193L4.47 4.923c-.077.064-.173.098-.27.098H1.33c-.235 0-.33.17-.33.346z"/></svg>'},IDLE_TIMEOUT:2e3,Defaults:{controls:1,layoutControls:null,updateControls:null,pauseOnClick:!0},Controls:{NONE:0,INLINE_PROGRESS:1,STACKED_PROGRESS:2,CUSTOM:3},VideoEvents:{LOADED_METADATA:{name:"loadedmetadata",readyState:1},LOADED_DATA:{name:"loadeddata",readyState:2},CAN_PLAY:{name:"canplay",readyState:3},CAN_PLAYTHROUGH:{name:"canplaythrough",readyState:4}}};function t(A){if(t.HAS_LOCAL_STORAGE&&"true"===window.localStorage.getItem("odovideoautoplay"))return Promise.resolve(!0);var e=t.HAS_LOCAL_STORAGE&&parseInt(window.localStorage.getItem("odovideoautoplaytries"),10)||0;return e>2?Promise.resolve(!1):new Promise(function(s){var o=void 0,i=document.createElement("video"),n=i.style,l=function(A){t.HAS_LOCAL_STORAGE&&(window.localStorage.setItem("odovideoautoplay",A),window.localStorage.setItem("odovideoautoplaytries",e+1)),s(A)},r=function A(e){clearTimeout(o),i.removeEventListener("playing",A),l(e&&"playing"===e.type||0!==i.currentTime),i.parentNode.removeChild(i)};A&&"autoplay"in i?(n.position="absolute",n.display="none",n.height=0,n.width=0,i.src="data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAezbW9vdgAAAGxtdmhkAAAAAM89KuDPPSrgAAAD6AAABCsAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAA790cmFrAAAAXHRraGQAAAAPzz0q4M89KuAAAAABAAAAAAAAA+gAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAABAAAAAQAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAAPoAAAAAgABAAAAAAM3bWRpYQAAACBtZGhkAAAAAM89KuDPPSrgAAAAGAAAABgVxwAAAAAALWhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIAAAAC4m1pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAqJzdGJsAAAAlnN0c2QAAAAAAAAAAQAAAIZhdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAABAAEABIAAAASAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGP//AAAAMGF2Y0MBZAAK/+EAF2dkAAqs2Z7ARAAAAwAEAA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AAAAgBnukpEV/lgCEQBGCMHCEQBGCMHAAAAAgBnutuRX/lgCEQBGCMHCEQBGCMHAAAAA1BmvA1CC2pMpgEV6uBIRAEYIwcIRAEYIwcAAAACkGfDiSURFxX5YEhEARgjBwhEARgjBwAAAAIAZ8tKRFf5YEhEARgjBwhEARgjBwAAAAIAZ8vbkV/5YAhEARgjBwhEARgjBwAAAANQZs0NQgtqTKYBFergCEQBGCMHCEQBGCMHAAAAApBn1IklERcV+WBIRAEYIwcIRAEYIwcAAAACAGfcSkRX+WAIRAEYIwcIRAEYIwcAAAACAGfc25Ff+WAIRAEYIwcIRAEYIwcAAAADUGbdzUILakymARXq4EhEARgjBwhEARgjBwAAAAIQZ+WJIiv5YAhEARgjBwhEARgjBwAAAAIAZ+1LRFf5YEhEARgjBwhEARgjBwhEARgjBwhEARgjBwhEARgjBwhEARgjBwhEARgjBw=",i.setAttribute("autoplay",""),i.setAttribute("muted",""),i.setAttribute("playsinline",""),document.documentElement.appendChild(i),setTimeout(function(){i.addEventListener("playing",r),o=setTimeout(r,1e3)},0)):l(!1)})}t.HAS_LOCAL_STORAGE=function(){try{var A="test";return window.localStorage.setItem(A,"1"),window.localStorage.removeItem(A),!0}catch(A){return!1}}();var s=function(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")},o=function(){function A(){s(this,A)}return A.prototype.createElement=function(A,e){var t=document.createElement(A);return Object.keys(e).forEach(function(A){t[A]=e[A]}),t},A.prototype.createElements=function(){return{controls:this.createElement("div",{className:e.Classes.CONTROLS}),playToggle:this.createElement("button",{className:e.Classes.PLAY_TOGGLE,title:A.LABEL.PLAY_TOGGLE}),playControl:this.createElement("span",{className:e.Classes.PLAY_CONTROL}),pauseControl:this.createElement("span",{className:e.Classes.PAUSE_CONTROL}),progressContainer:this.createElement("div",{className:e.Classes.PROGRESS_CONTAINER}),progressHolder:this.createElement("div",{className:e.Classes.PROGRESS_HOLDER}),buffer:this.createElement("div",{className:e.Classes.BUFFER}),progress:this.createElement("div",{className:e.Classes.PROGRESS}),currentTime:this.createElement("div",{className:e.Classes.CURRENT_TIME}),volumeToggle:this.createElement("button",{className:e.Classes.VOLUME,title:A.LABEL.VOLUME}),muteControl:this.createElement("span",{className:e.Classes.MUTE_CONTROL,innerHTML:e.Icons.AUDIO_ON}),unmuteControl:this.createElement("span",{className:e.Classes.UNMUTE_CONTROL,innerHTML:e.Icons.AUDIO_OFF}),fullScreenToggle:this.createElement("button",{className:e.Classes.FULLSCREEN,title:A.LABEL.FULLSCREEN}),enterFullscreen:this.createElement("span",{className:e.Classes.FULLSCREEN_CONTROL,innerHTML:e.Icons.FULLSCREEN}),exitFullscreen:this.createElement("span",{className:e.Classes.EXIT_FULLSCREEN_CONTROL,innerHTML:e.Icons.EXIT_FULLSCREEN}),flexibleSpace:this.createElement("div",{className:e.Classes.FLEXIBLE_SPACE})}},A.prototype.create=function(A,t){var s=this.createElements();switch(s.playToggle.appendChild(s.playControl),s.playToggle.appendChild(s.pauseControl),s.volumeToggle.appendChild(s.muteControl),s.volumeToggle.appendChild(s.unmuteControl),s.fullScreenToggle.appendChild(s.enterFullscreen),s.fullScreenToggle.appendChild(s.exitFullscreen),s.progressHolder.appendChild(s.buffer),s.progressHolder.appendChild(s.progress),s.progressContainer.appendChild(s.progressHolder),A){case e.Controls.INLINE_PROGRESS:this._createInline(s);break;case e.Controls.NONE:this._createInline(s),s.controls.classList.add(e.Classes.CONTROLS_HIDDEN);break;case e.Controls.STACKED_PROGRESS:this._createStacked(s);break;case e.Controls.CUSTOM:t(s)}return s.controls},A.prototype._createInline=function(A){A.controls.appendChild(A.playToggle),A.controls.appendChild(A.progressContainer),A.controls.appendChild(A.currentTime),A.controls.appendChild(A.volumeToggle),A.controls.appendChild(A.fullScreenToggle)},A.prototype._createStacked=function(A){A.controls.appendChild(A.progressContainer),A.controls.appendChild(A.playToggle),A.controls.appendChild(A.flexibleSpace),A.controls.appendChild(A.currentTime),A.controls.appendChild(A.volumeToggle),A.controls.appendChild(A.fullScreenToggle),A.controls.classList.add(e.Classes.CONTROLS_STACKED)},A}();o.LABEL={PLAY_TOGGLE:"toggle video playback.",VOLUME:"toggle mute for video.",FULLSCREEN:"toggle video fullscreen mode."};var i,n,l=function(){function A(e,t){s(this,A),this.element=e,this.videoEl=this._findVideoElement(),this.id=Math.random().toString(36).substring(7),this.options=Object.assign({},A.Defaults,t),this.isPlaying=this._isPlaying(),this.isFullscreen=!1,this._idleTimeout=null,this._noFullscreen=!1,this.element.classList.toggle(A.Classes.NO_FLEXBOX,A.NO_FLEXBOX),this._setSourceIds(),this._createControls(),this._saveElements(),this.bindEvents(),this._isMetadataLoaded()&&(this._setProgressDisplay(),this._setBufferDisplay()),this.autoplay=Promise.resolve(A.autoplay)}return A.prototype._bindListeners=function(){this._onMetadataLoaded=this._handleMetadataLoaded.bind(this),this._onClick=this._handleClick.bind(this),this._onPlay=this._handlePlaying.bind(this),this._onPause=this._handlePaused.bind(this),this._onTimeUpdate=this._handleTimeUpdate.bind(this),this._onProgress=this._handleProgress.bind(this),this._onFullscreenToggle=this.toggleFullscreen.bind(this),this._onFullscreenChange=this._fullscreenChanged.bind(this),this._onVolumeToggle=this.toggleVolume.bind(this),this._onProgressClick=this._handleProgressClick.bind(this),this._onSeeking=this._handleSeeking.bind(this),this._onSeeked=this._handleSeeked.bind(this),this._onMouseMove=this._returnFromIdle.bind(this),this._onIdleTimeout=this._wentIdle.bind(this),this._onKeyboardPlaybackToggle=this._handleKeyboardPlaybackToggle.bind(this)},A.prototype.bindEvents=function(){this._bindListeners(),this._waitForMetadata(),this.options.pauseOnClick&&this.videoEl.addEventListener("click",this._onClick),this.videoEl.addEventListener("pause",this._onPause),this.videoEl.addEventListener("playing",this._onPlay),this.videoEl.addEventListener("timeupdate",this._onTimeUpdate),this.videoEl.addEventListener("progress",this._onProgress),this.videoEl.addEventListener("volumechange",this._onVolumeChange),this.videoEl.addEventListener("seeking",this._onSeeking),this.videoEl.addEventListener("seeked",this._onSeeked),this.getElementByClass(A.Classes.PLAY_TOGGLE).addEventListener("click",this._onClick),this.getElementByClass(A.Classes.VOLUME).addEventListener("click",this._onVolumeToggle),this.getElementByClass(A.Classes.PROGRESS_HOLDER).addEventListener("click",this._onProgressClick),this.getElementByClass(A.Classes.FULLSCREEN).addEventListener("click",this._onFullscreenToggle),A.screenfull.enabled?(document.addEventListener(A.screenfull.raw.fullscreenchange,this._onFullscreenChange),document.addEventListener(A.screenfull.raw.fullscreenerror,this._onFullscreenChange)):this.videoEl.webkitSupportsFullscreen?(this.videoEl.addEventListener("webkitbeginfullscreen",this._onFullscreenChange),this.videoEl.addEventListener("webkitendfullscreen",this._onFullscreenChange)):this._noFullscreen=!0},A.prototype._isMetadataLoaded=function(){return this.videoEl.readyState>0},A.prototype._waitForMetadata=function(){this._isMetadataLoaded()?this._handleMetadataLoaded():this.videoEl.addEventListener("loadedmetadata",this._onMetadataLoaded)},A.prototype._saveElements=function(){this.currentTimeEl=this.getElementByClass(A.Classes.CURRENT_TIME),this.progressEl=this.getElementByClass(A.Classes.PROGRESS),this.bufferEl=this.getElementByClass(A.Classes.BUFFER)},A.prototype._findVideoElement=function(){return this.element.getElementsByTagName("video")[0]},A.prototype._isPlaying=function(){return!this.videoEl.ended&&!this.videoEl.paused},A.prototype._setSourceIds=function(){var A=this;this.getSourceElements().forEach(function(e){e.id=A.id+e.type.split("/")[1]})},A.prototype.getSourceElements=function(){return Array.from(this.videoEl.getElementsByTagName("source"))},A.prototype.getElement=function(){return this.element},A.prototype.getVideoElement=function(){return this.videoEl},A.prototype.getElementByClass=function(A){return this.element.getElementsByClassName(A)[0]},A.prototype.play=function(){return this.videoEl.play()},A.prototype.pause=function(){this.videoEl.pause()},A.prototype.togglePlayback=function(){this.isPlaying?this.pause():this.play()},A.prototype.getCurrentTime=function(){return this.videoEl.currentTime},A.prototype.setCurrentTime=function(A){this.videoEl.currentTime=A},A.prototype.mute=function(){this.videoEl.volume=0,this.element.classList.add(A.Classes.IS_MUTED)},A.prototype.unmute=function(){this.videoEl.volume=1,this.element.classList.remove(A.Classes.IS_MUTED)},A.prototype.isMuted=function(){return 0===this.videoEl.volume},A.prototype.toggleVolume=function(){this.isMuted()?this.unmute():this.mute()},A.prototype.updateSource=function(e){var t=this,s=A.getVideoType().extension,o=this.getSourceElements().filter(function(A){return A.id===t.id+s})[0],i=e+"."+s;o.setAttribute("src",i),this.videoEl.load(),this._setProgressDisplay(),this._setBufferDisplay(),this._waitForMetadata()},A.prototype.showBuffering=function(){this.element.classList.add(A.Classes.IS_BUFFERING)},A.prototype.hideBuffering=function(){this.element.classList.remove(A.Classes.IS_BUFFERING)},A.getPrettyTime=function(A){var e=Math.floor(A/3600),t=Math.floor((A-3600*e)/60),s=A-3600*e-60*t;s<10&&(s="0"+s);var o=t+":"+s;return e>0&&(t<10&&(o="0"+o),o=e+":"+o),o},A.prototype._createControls=function(){var e=(new A.ControlsCreator).create(this.options.controls,this.options.layoutControls);this.element.appendChild(e)},A.prototype._updateControls=function(){var A=this.getCurrentTime();this._setCurrentTimeDisplay(A),this._setProgressDisplay(),this.options.updateControls&&this.options.updateControls(A)},A.prototype._setCurrentTimeDisplay=function(e){this.currentTimeEl.textContent=A.getPrettyTime(Math.round(e))},A.prototype._setProgressDisplay=function(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.videoEl.currentTime/this.videoEl.duration;this.progressEl.style.width=100*A+"%"},A.prototype._setBufferDisplay=function(){var A=this.videoEl.buffered.length>0?this.videoEl.buffered.end(0)/this.videoEl.duration:0;this.bufferEl.style.width=100*A+"%"},A.prototype.toggleFullscreen=function(){A.screenfull?A.screenfull.toggle(this.element):this._noFullscreen?this._fullscreenChanged():this.videoEl.webkitEnterFullscreen()},A.prototype._fullscreenChanged=function(){this.isFullscreen=!this.isFullscreen,this._toggleFullscreenState()},A.prototype._toggleFullscreenState=function(){this.element.classList.toggle(A.Classes.IS_FULLSCREEN,this.isFullscreen),this.isFullscreen?(this._startIdleTimer(),document.activeElement.blur(),this.element.focus(),this.element.addEventListener("mousemove",this._onMouseMove),document.addEventListener("keyup",this._onKeyboardPlaybackToggle)):(this._returnFromIdle(),clearTimeout(this._idleTimeout),this.element.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("keyup",this._onKeyboardPlaybackToggle))},A.prototype._wentIdle=function(){this.element.classList.add(A.Classes.IS_IDLE)},A.prototype._returnFromIdle=function(){clearTimeout(this._idleTimeout),this._startIdleTimer(),this.element.classList.remove(A.Classes.IS_IDLE)},A.prototype._startIdleTimer=function(){this._idleTimeout=setTimeout(this._onIdleTimeout,A.IDLE_TIMEOUT)},A._getClickOffset=function(A){if("offsetX"in A)return{x:A.offsetX,y:A.offsetY};var e=A.currentTarget.getBoundingClientRect();return{x:A.clientX-e.left,y:A.clientY-e.top}},A.prototype._handleMetadataLoaded=function(){this.videoEl.removeEventListener("loadedmetadata",this._onMetadataLoaded),this._setCurrentTimeDisplay(this.videoEl.duration)},A.prototype._handleClick=function(){this.togglePlayback()},A.prototype._handlePlaying=function(){this.isPlaying=!0,this.element.classList.toggle(A.Classes.IS_PLAYING,this.isPlaying)},A.prototype._handlePaused=function(){this.isPlaying=!1,this.element.classList.toggle(A.Classes.IS_PLAYING,this.isPlaying)},A.prototype._handleTimeUpdate=function(){this._updateControls()},A.prototype._handleProgress=function(){this._setBufferDisplay()},A.prototype._handleProgressClick=function(e){var t=A._getClickOffset(e),s=e.currentTarget.offsetWidth,o=t.x/s;this._setProgressDisplay(o),this.setCurrentTime(o*this.videoEl.duration)},A.prototype._handleSeeking=function(){(0===this.videoEl.buffered.length||this.videoEl.buffered.end(0)<this.videoEl.currentTime)&&this.showBuffering()},A.prototype._handleSeeked=function(){this.hideBuffering()},A.prototype._handleKeyboardPlaybackToggle=function(e){this._returnFromIdle(),32===A._getWhichKey(e)&&(this.togglePlayback(),e.preventDefault())},A._getWhichKey=function(A){return A.which?A.which:A.charCode||A.keyCode},A.prototype.listenOnData=function(A,e){var t=this,s=void 0;this.videoEl.readyState>A.readyState?e.call():this.videoEl.addEventListener(A.name,s=function(){t.videoEl.removeEventListener(A.name,s),e.call()})},A.prototype.dispose=function(){this.videoEl.removeEventListener("click",this._onClick),this.videoEl.removeEventListener("pause",this._onPause),this.videoEl.removeEventListener("playing",this._onPlay),this.videoEl.removeEventListener("timeupdate",this._onTimeUpdate),this.videoEl.removeEventListener("progress",this._onProgress),this.videoEl.removeEventListener("seeking",this._onSeeking),this.videoEl.removeEventListener("seeked",this._onSeeked),this.videoEl.removeEventListener("loadedmetadata",this._onMetadataLoaded),this.getElementByClass(A.Classes.PLAY_TOGGLE).removeEventListener("click",this._onClick),this.getElementByClass(A.Classes.VOLUME).removeEventListener("click",this._onVolumeToggle),this.getElementByClass(A.Classes.PROGRESS_HOLDER).removeEventListener("click",this._onProgressClick),this.getElementByClass(A.Classes.FULLSCREEN).removeEventListener("click",this._onFullscreenToggle);var e=this._onFullscreenChange;A.screenfull.enabled?(document.removeEventListener(A.screenfull.raw.fullscreenchange,e),document.removeEventListener(A.screenfull.raw.fullscreenerror,e)):this.videoEl.webkitSupportsFullscreen&&(this.videoEl.removeEventListener("webkitbeginfullscreen",e),this.videoEl.removeEventListener("webkitendfullscreen",e)),this.element.removeChild(this.getElementByClass(A.Classes.CONTROLS)),this.currentTimeEl=null,this.progressEl=null,this.bufferEl=null,this.element=null,this.videoEl=null},A.getVideoType=function(){return A.support.webm?{extension:"webm",type:"video/webm"}:{extension:"mp4",type:"video/mp4"}},A}();return Object.assign(l,e),l.support=(i=document.createElement("video"),(n=!!i.canPlayType)&&((n=new Boolean(n)).ogg=i.canPlayType('video/ogg; codecs="theora"'),n.h264=i.canPlayType('video/mp4; codecs="avc1.42E01E"'),n.webm=i.canPlayType('video/webm; codecs="vp8, vorbis"'),n.vp9=i.canPlayType('video/webm; codecs="vp9"'),n.hls=i.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"')),n),l.autoplay=t(l.support),l._autoplayTest=t,l.ControlsCreator=o,l.NO_FLEXBOX=document.all&&document.addEventListener&&!window.atob,l.screenfull=A,l}); | ||
!function(A,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("screenfull")):"function"==typeof define&&define.amd?define(["screenfull"],e):A.OdoVideo=e(A.screenfull)}(this,function(A){"use strict";A=A&&A.hasOwnProperty("default")?A.default:A;var e={Classes:{BASE:"odo-video",IS_PLAYING:"odo-video--playing",IS_FULLSCREEN:"odo-video--fullscreen",IS_MUTED:"odo-video--muted",IS_BUFFERING:"odo-video--buffering",IS_IDLE:"odo-video--idle",NO_FLEXBOX:"odo-video--no-flexbox",CONTROLS_STACKED:"odo-video__controls--stacked",CONTROLS_HIDDEN:"odo-video__controls--hidden",CONTROLS:"odo-video__controls",PLAY_TOGGLE:"odo-video__play-toggle",PLAY_CONTROL:"odo-video__play-control",PAUSE_CONTROL:"odo-video__pause-control",PROGRESS_CONTAINER:"odo-video__progress-container",PROGRESS_HOLDER:"odo-video__progress-holder",BUFFER:"odo-video__buffer",PROGRESS:"odo-video__progress",CURRENT_TIME:"odo-video__current-time",VOLUME:"odo-video__volume",MUTE_CONTROL:"odo-video__mute-control",UNMUTE_CONTROL:"odo-video__unmute-control",FULLSCREEN:"odo-video__fullscreen",FULLSCREEN_CONTROL:"odo-video__fullscreen-control",EXIT_FULLSCREEN_CONTROL:"odo-video__exit-fullscreen-control",FLEXIBLE_SPACE:"odo-video__flexible-space"},Icons:{FULLSCREEN:'<svg viewBox="0 0 16 16" enable-background="new 0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 2H8v2h2.586L8 6.587 9.414 8 12 5.415V8h2V2zM8 9.414L6.586 8 4 10.586V8H2v6h6v-2H5.415z"/></svg>',EXIT_FULLSCREEN:'<svg viewBox="0 0 16 16" enable-background="new 0 0 16 16"><path d="M15 2.4L13.6 1 11 3.6V1H9v6h6V5h-2.6L15 2.4zM5 9H1v2h2.6L1 13.6 2.4 15 5 12.4V15h2V9H5z"/></svg>',AUDIO_ON:'<svg viewBox="0 0 16 16" enable-background="new 0 0 16 16"><path d="M1 5.366v5.294c0 .177.142.32.317.32h2.89c.093 0 .18.034.254.093l4.505 3.743c.16.135.4.018.402-.19l.002-13.25c0-.21-.243-.325-.403-.193L4.47 4.923c-.077.064-.173.098-.27.098H1.33c-.235 0-.33.17-.33.346zm10.292-1.03c-.295-.296-.76-.296-1.057 0-.292.296-.292.775.002 1.07v-.002c.642.652 1.04 1.55 1.04 2.54 0 .992-.396 1.884-1.04 2.535-.294.295-.294.774 0 1.07.143.148.334.222.526.222.19 0 .388-.074.528-.22.91-.922 1.476-2.202 1.476-3.606 0-1.41-.567-2.69-1.476-3.61h.002zm1.71-1.732c-.294-.296-.76-.296-1.053 0-.294.296-.293.772 0 1.066 1.08 1.096 1.754 2.602 1.754 4.273s-.667 3.176-1.753 4.273c-.294.294-.294.77 0 1.067.142.146.337.222.53.222.19 0 .386-.076.526-.222 1.35-1.366 2.19-3.257 2.19-5.34-.008-2.08-.843-3.975-2.194-5.34z"/></svg>',AUDIO_OFF:'<svg viewBox="0 0 16 16" enable-background="new 0 0 16 16"><path d="M1 5.366v5.294c0 .177.142.32.317.32h2.89c.093 0 .18.034.254.093l4.505 3.743c.16.135.4.018.402-.19l.002-13.25c0-.21-.243-.325-.403-.193L4.47 4.923c-.077.064-.173.098-.27.098H1.33c-.235 0-.33.17-.33.346z"/></svg>'},IDLE_TIMEOUT:2e3,Defaults:{controls:1,layoutControls:null,updateControls:null,pauseOnClick:!0},Controls:{NONE:0,INLINE_PROGRESS:1,STACKED_PROGRESS:2,CUSTOM:3},VideoEvents:{LOADED_METADATA:{name:"loadedmetadata",readyState:1},LOADED_DATA:{name:"loadeddata",readyState:2},CAN_PLAY:{name:"canplay",readyState:3},CAN_PLAYTHROUGH:{name:"canplaythrough",readyState:4}}};function t(A){if(t.HAS_LOCAL_STORAGE&&"true"===window.localStorage.getItem("odovideoautoplay"))return Promise.resolve(!0);var e=t.HAS_LOCAL_STORAGE&&parseInt(window.localStorage.getItem("odovideoautoplaytries"),10)||0;return e>2?Promise.resolve(!1):new Promise(function(s){var o=void 0,i=document.createElement("video"),n=i.style,l=function(A){t.HAS_LOCAL_STORAGE&&(window.localStorage.setItem("odovideoautoplay",A),window.localStorage.setItem("odovideoautoplaytries",e+1)),s(A)},r=function A(e){clearTimeout(o),i.removeEventListener("playing",A),l(e&&"playing"===e.type||0!==i.currentTime),i.parentNode.removeChild(i)};A&&"autoplay"in i?(n.position="absolute",n.display="none",n.height=0,n.width=0,i.src="data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAezbW9vdgAAAGxtdmhkAAAAAM89KuDPPSrgAAAD6AAABCsAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAA790cmFrAAAAXHRraGQAAAAPzz0q4M89KuAAAAABAAAAAAAAA+gAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAABAAAAAQAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAAPoAAAAAgABAAAAAAM3bWRpYQAAACBtZGhkAAAAAM89KuDPPSrgAAAAGAAAABgVxwAAAAAALWhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIAAAAC4m1pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAqJzdGJsAAAAlnN0c2QAAAAAAAAAAQAAAIZhdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAABAAEABIAAAASAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGP//AAAAMGF2Y0MBZAAK/+EAF2dkAAqs2Z7ARAAAAwAEAAADAMA8SJZoAQAGaOl4TLIsAAAAGHN0dHMA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AAgBnutuRX/lgCEQBGCMHCEQBGCMHAAAAA1BmvA1CC2pMpgEV6uBIRAEYIwcIRAEYIwcAAAACkGfDiSURFxX5YEhEARgjBwhEARgjBwAAAAIAZ8tKRFf5YEhEARgjBwhEARgjBwAAAAIAZ8vbkV/5YAhEARgjBwhEARgjBwAAAANQZs0NQgtqTKYBFergCEQBGCMHCEQBGCMHAAAAApBn1IklERcV+WBIRAEYIwcIRAEYIwcAAAACAGfcSkRX+WAIRAEYIwcIRAEYIwcAAAACAGfc25Ff+WAIRAEYIwcIRAEYIwcAAAADUGbdzUILakymARXq4EhEARgjBwhEARgjBwAAAAIQZ+WJIiv5YAhEARgjBwhEARgjBwAAAAIAZ+1LRFf5YEhEARgjBwhEARgjBwhEARgjBwhEARgjBwhEARgjBwhEARgjBwhEARgjBw=",i.setAttribute("autoplay",""),i.setAttribute("muted",""),i.setAttribute("playsinline",""),document.documentElement.appendChild(i),setTimeout(function(){i.addEventListener("playing",r),o=setTimeout(r,1e3)},0)):l(!1)})}t.HAS_LOCAL_STORAGE=function(){try{return window.localStorage.setItem("test","1"),window.localStorage.removeItem("test"),!0}catch(A){return!1}}();var s=function(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")},o=function(){function A(){s(this,A)}return A.prototype.createElement=function(A,e){var t=document.createElement(A);return Object.keys(e).forEach(function(A){t[A]=e[A]}),t},A.prototype.createElements=function(){return{controls:this.createElement("div",{className:e.Classes.CONTROLS}),playToggle:this.createElement("button",{className:e.Classes.PLAY_TOGGLE,title:A.LABEL.PLAY_TOGGLE}),playControl:this.createElement("span",{className:e.Classes.PLAY_CONTROL}),pauseControl:this.createElement("span",{className:e.Classes.PAUSE_CONTROL}),progressContainer:this.createElement("div",{className:e.Classes.PROGRESS_CONTAINER}),progressHolder:this.createElement("div",{className:e.Classes.PROGRESS_HOLDER}),buffer:this.createElement("div",{className:e.Classes.BUFFER}),progress:this.createElement("div",{className:e.Classes.PROGRESS}),currentTime:this.createElement("div",{className:e.Classes.CURRENT_TIME}),volumeToggle:this.createElement("button",{className:e.Classes.VOLUME,title:A.LABEL.VOLUME}),muteControl:this.createElement("span",{className:e.Classes.MUTE_CONTROL,innerHTML:e.Icons.AUDIO_ON}),unmuteControl:this.createElement("span",{className:e.Classes.UNMUTE_CONTROL,innerHTML:e.Icons.AUDIO_OFF}),fullScreenToggle:this.createElement("button",{className:e.Classes.FULLSCREEN,title:A.LABEL.FULLSCREEN}),enterFullscreen:this.createElement("span",{className:e.Classes.FULLSCREEN_CONTROL,innerHTML:e.Icons.FULLSCREEN}),exitFullscreen:this.createElement("span",{className:e.Classes.EXIT_FULLSCREEN_CONTROL,innerHTML:e.Icons.EXIT_FULLSCREEN}),flexibleSpace:this.createElement("div",{className:e.Classes.FLEXIBLE_SPACE})}},A.prototype.create=function(A,t){var s=this.createElements();switch(s.playToggle.appendChild(s.playControl),s.playToggle.appendChild(s.pauseControl),s.volumeToggle.appendChild(s.muteControl),s.volumeToggle.appendChild(s.unmuteControl),s.fullScreenToggle.appendChild(s.enterFullscreen),s.fullScreenToggle.appendChild(s.exitFullscreen),s.progressHolder.appendChild(s.buffer),s.progressHolder.appendChild(s.progress),s.progressContainer.appendChild(s.progressHolder),A){case e.Controls.INLINE_PROGRESS:this._createInline(s);break;case e.Controls.NONE:this._createInline(s),s.controls.classList.add(e.Classes.CONTROLS_HIDDEN);break;case e.Controls.STACKED_PROGRESS:this._createStacked(s);break;case e.Controls.CUSTOM:t(s)}return s.controls},A.prototype._createInline=function(A){A.controls.appendChild(A.playToggle),A.controls.appendChild(A.progressContainer),A.controls.appendChild(A.currentTime),A.controls.appendChild(A.volumeToggle),A.controls.appendChild(A.fullScreenToggle)},A.prototype._createStacked=function(A){A.controls.appendChild(A.progressContainer),A.controls.appendChild(A.playToggle),A.controls.appendChild(A.flexibleSpace),A.controls.appendChild(A.currentTime),A.controls.appendChild(A.volumeToggle),A.controls.appendChild(A.fullScreenToggle),A.controls.classList.add(e.Classes.CONTROLS_STACKED)},A}();o.LABEL={PLAY_TOGGLE:"toggle video playback.",VOLUME:"toggle mute for video.",FULLSCREEN:"toggle video fullscreen mode."};var i,n,l=function(){function A(e,t){s(this,A),this.element=e,this.videoEl=this._findVideoElement(),this.id=Math.random().toString(36).substring(7),this.options=Object.assign({},A.Defaults,t),this.isPlaying=this._isPlaying(),this.isFullscreen=!1,this._idleTimeout=null,this._noFullscreen=!1,this.element.classList.toggle(A.Classes.NO_FLEXBOX,A.NO_FLEXBOX),this._setSourceIds(),this._createControls(),this._saveElements(),this.bindEvents(),this._isMetadataLoaded()&&(this._setProgressDisplay(),this._setBufferDisplay()),this.autoplay=Promise.resolve(A.autoplay)}return A.prototype._bindListeners=function(){this._onMetadataLoaded=this._handleMetadataLoaded.bind(this),this._onClick=this._handleClick.bind(this),this._onPlay=this._handlePlaying.bind(this),this._onPause=this._handlePaused.bind(this),this._onTimeUpdate=this._handleTimeUpdate.bind(this),this._onProgress=this._handleProgress.bind(this),this._onFullscreenToggle=this.toggleFullscreen.bind(this),this._onFullscreenChange=this._fullscreenChanged.bind(this),this._onVolumeToggle=this.toggleVolume.bind(this),this._onProgressClick=this._handleProgressClick.bind(this),this._onSeeking=this._handleSeeking.bind(this),this._onSeeked=this._handleSeeked.bind(this),this._onMouseMove=this._returnFromIdle.bind(this),this._onIdleTimeout=this._wentIdle.bind(this),this._onKeyboardPlaybackToggle=this._handleKeyboardPlaybackToggle.bind(this)},A.prototype.bindEvents=function(){this._bindListeners(),this._waitForMetadata(),this.options.pauseOnClick&&this.videoEl.addEventListener("click",this._onClick),this.videoEl.addEventListener("pause",this._onPause),this.videoEl.addEventListener("playing",this._onPlay),this.videoEl.addEventListener("timeupdate",this._onTimeUpdate),this.videoEl.addEventListener("progress",this._onProgress),this.videoEl.addEventListener("volumechange",this._onVolumeChange),this.videoEl.addEventListener("seeking",this._onSeeking),this.videoEl.addEventListener("seeked",this._onSeeked),this.getElementByClass(A.Classes.PLAY_TOGGLE).addEventListener("click",this._onClick),this.getElementByClass(A.Classes.VOLUME).addEventListener("click",this._onVolumeToggle),this.getElementByClass(A.Classes.PROGRESS_HOLDER).addEventListener("click",this._onProgressClick),this.getElementByClass(A.Classes.FULLSCREEN).addEventListener("click",this._onFullscreenToggle),A.screenfull.enabled?(document.addEventListener(A.screenfull.raw.fullscreenchange,this._onFullscreenChange),document.addEventListener(A.screenfull.raw.fullscreenerror,this._onFullscreenChange)):this.videoEl.webkitSupportsFullscreen?(this.videoEl.addEventListener("webkitbeginfullscreen",this._onFullscreenChange),this.videoEl.addEventListener("webkitendfullscreen",this._onFullscreenChange)):this._noFullscreen=!0},A.prototype._isMetadataLoaded=function(){return this.videoEl.readyState>0},A.prototype._waitForMetadata=function(){this._isMetadataLoaded()?this._handleMetadataLoaded():this.videoEl.addEventListener("loadedmetadata",this._onMetadataLoaded)},A.prototype._saveElements=function(){this.currentTimeEl=this.getElementByClass(A.Classes.CURRENT_TIME),this.progressEl=this.getElementByClass(A.Classes.PROGRESS),this.bufferEl=this.getElementByClass(A.Classes.BUFFER)},A.prototype._findVideoElement=function(){return this.element.getElementsByTagName("video")[0]},A.prototype._isPlaying=function(){return!this.videoEl.ended&&!this.videoEl.paused},A.prototype._setSourceIds=function(){var A=this;this.getSourceElements().forEach(function(e){e.id=A.id+e.type.split("/")[1]})},A.prototype.getSourceElements=function(){return Array.from(this.videoEl.getElementsByTagName("source"))},A.prototype.getElement=function(){return this.element},A.prototype.getVideoElement=function(){return this.videoEl},A.prototype.getElementByClass=function(A){return this.element.getElementsByClassName(A)[0]},A.prototype.play=function(){return this.videoEl.play()},A.prototype.pause=function(){this.videoEl.pause()},A.prototype.togglePlayback=function(){this.isPlaying?this.pause():this.play()},A.prototype.getCurrentTime=function(){return this.videoEl.currentTime},A.prototype.setCurrentTime=function(A){this.videoEl.currentTime=A},A.prototype.mute=function(){this.videoEl.volume=0,this.element.classList.add(A.Classes.IS_MUTED)},A.prototype.unmute=function(){this.videoEl.volume=1,this.element.classList.remove(A.Classes.IS_MUTED)},A.prototype.isMuted=function(){return 0===this.videoEl.volume},A.prototype.toggleVolume=function(){this.isMuted()?this.unmute():this.mute()},A.prototype.updateSource=function(e){var t=this,s=A.getVideoType().extension,o=this.getSourceElements().filter(function(A){return A.id===t.id+s})[0],i=e+"."+s;o.setAttribute("src",i),this.videoEl.load(),this._setProgressDisplay(),this._setBufferDisplay(),this._waitForMetadata()},A.prototype.showBuffering=function(){this.element.classList.add(A.Classes.IS_BUFFERING)},A.prototype.hideBuffering=function(){this.element.classList.remove(A.Classes.IS_BUFFERING)},A.getPrettyTime=function(A){var e=Math.floor(A/3600),t=Math.floor((A-3600*e)/60),s=A-3600*e-60*t;s<10&&(s="0"+s);var o=t+":"+s;return e>0&&(t<10&&(o="0"+o),o=e+":"+o),o},A.prototype._createControls=function(){var e=(new A.ControlsCreator).create(this.options.controls,this.options.layoutControls);this.element.appendChild(e)},A.prototype._updateControls=function(){var A=this.getCurrentTime();this._setCurrentTimeDisplay(A),this._setProgressDisplay(),this.options.updateControls&&this.options.updateControls(A)},A.prototype._setCurrentTimeDisplay=function(e){this.currentTimeEl.textContent=A.getPrettyTime(Math.round(e))},A.prototype._setProgressDisplay=function(){var A=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.videoEl.currentTime/this.videoEl.duration;this.progressEl.style.width=100*A+"%"},A.prototype._setBufferDisplay=function(){var A=this.videoEl.buffered.length>0?this.videoEl.buffered.end(0)/this.videoEl.duration:0;this.bufferEl.style.width=100*A+"%"},A.prototype.toggleFullscreen=function(){A.screenfull?A.screenfull.toggle(this.element):this._noFullscreen?this._fullscreenChanged():this.videoEl.webkitEnterFullscreen()},A.prototype._fullscreenChanged=function(){this.isFullscreen=!this.isFullscreen,this._toggleFullscreenState()},A.prototype._toggleFullscreenState=function(){this.element.classList.toggle(A.Classes.IS_FULLSCREEN,this.isFullscreen),this.isFullscreen?(this._startIdleTimer(),document.activeElement.blur(),this.element.focus(),this.element.addEventListener("mousemove",this._onMouseMove),document.addEventListener("keyup",this._onKeyboardPlaybackToggle)):(this._returnFromIdle(),clearTimeout(this._idleTimeout),this.element.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("keyup",this._onKeyboardPlaybackToggle))},A.prototype._wentIdle=function(){this.element.classList.add(A.Classes.IS_IDLE)},A.prototype._returnFromIdle=function(){clearTimeout(this._idleTimeout),this._startIdleTimer(),this.element.classList.remove(A.Classes.IS_IDLE)},A.prototype._startIdleTimer=function(){this._idleTimeout=setTimeout(this._onIdleTimeout,A.IDLE_TIMEOUT)},A._getClickOffset=function(A){if("offsetX"in A)return{x:A.offsetX,y:A.offsetY};var e=A.currentTarget.getBoundingClientRect();return{x:A.clientX-e.left,y:A.clientY-e.top}},A.prototype._handleMetadataLoaded=function(){this.videoEl.removeEventListener("loadedmetadata",this._onMetadataLoaded),this._setCurrentTimeDisplay(this.videoEl.duration)},A.prototype._handleClick=function(){this.togglePlayback()},A.prototype._handlePlaying=function(){this.isPlaying=!0,this.element.classList.toggle(A.Classes.IS_PLAYING,this.isPlaying)},A.prototype._handlePaused=function(){this.isPlaying=!1,this.element.classList.toggle(A.Classes.IS_PLAYING,this.isPlaying)},A.prototype._handleTimeUpdate=function(){this._updateControls()},A.prototype._handleProgress=function(){this._setBufferDisplay()},A.prototype._handleProgressClick=function(e){var t=A._getClickOffset(e),s=e.currentTarget.offsetWidth,o=t.x/s;this._setProgressDisplay(o),this.setCurrentTime(o*this.videoEl.duration)},A.prototype._handleSeeking=function(){(0===this.videoEl.buffered.length||this.videoEl.buffered.end(0)<this.videoEl.currentTime)&&this.showBuffering()},A.prototype._handleSeeked=function(){this.hideBuffering()},A.prototype._handleKeyboardPlaybackToggle=function(e){this._returnFromIdle(),32===A._getWhichKey(e)&&(this.togglePlayback(),e.preventDefault())},A._getWhichKey=function(A){return A.which?A.which:A.charCode||A.keyCode},A.prototype.listenOnData=function(A,e){var t=this,s=void 0;this.videoEl.readyState>A.readyState?e.call():this.videoEl.addEventListener(A.name,s=function(){t.videoEl.removeEventListener(A.name,s),e.call()})},A.prototype.dispose=function(){this.videoEl.removeEventListener("click",this._onClick),this.videoEl.removeEventListener("pause",this._onPause),this.videoEl.removeEventListener("playing",this._onPlay),this.videoEl.removeEventListener("timeupdate",this._onTimeUpdate),this.videoEl.removeEventListener("progress",this._onProgress),this.videoEl.removeEventListener("seeking",this._onSeeking),this.videoEl.removeEventListener("seeked",this._onSeeked),this.videoEl.removeEventListener("loadedmetadata",this._onMetadataLoaded),this.getElementByClass(A.Classes.PLAY_TOGGLE).removeEventListener("click",this._onClick),this.getElementByClass(A.Classes.VOLUME).removeEventListener("click",this._onVolumeToggle),this.getElementByClass(A.Classes.PROGRESS_HOLDER).removeEventListener("click",this._onProgressClick),this.getElementByClass(A.Classes.FULLSCREEN).removeEventListener("click",this._onFullscreenToggle);var e=this._onFullscreenChange;A.screenfull.enabled?(document.removeEventListener(A.screenfull.raw.fullscreenchange,e),document.removeEventListener(A.screenfull.raw.fullscreenerror,e)):this.videoEl.webkitSupportsFullscreen&&(this.videoEl.removeEventListener("webkitbeginfullscreen",e),this.videoEl.removeEventListener("webkitendfullscreen",e)),this.element.removeChild(this.getElementByClass(A.Classes.CONTROLS)),this.currentTimeEl=null,this.progressEl=null,this.bufferEl=null,this.element=null,this.videoEl=null},A.getVideoType=function(){return A.support.webm?{extension:"webm",type:"video/webm"}:{extension:"mp4",type:"video/mp4"}},A}();return Object.assign(l,e),l.support=(i=document.createElement("video"),(n=!!i.canPlayType)&&((n=new Boolean(n)).ogg=i.canPlayType('video/ogg; codecs="theora"'),n.h264=i.canPlayType('video/mp4; codecs="avc1.42E01E"'),n.webm=i.canPlayType('video/webm; codecs="vp8, vorbis"'),n.vp9=i.canPlayType('video/webm; codecs="vp9"'),n.hls=i.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"')),n),l.autoplay=t(l.support),l._autoplayTest=t,l.ControlsCreator=o,l.NO_FLEXBOX=document.all&&document.addEventListener&&!window.atob,l.screenfull=A,l}); | ||
//# sourceMappingURL=odo-video.min.js.map |
{ | ||
"name": "@odopod/odo-video", | ||
"description": "A lightweight html5 video wrapper.", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"main": "dist/odo-video.js", | ||
"module": "dist/odo-video.esm.js", | ||
"odoModule": "src/video.js", | ||
"sideEffects": false, | ||
"author": "Odopod", | ||
@@ -21,4 +23,3 @@ "contributors": [ | ||
"dist", | ||
"src", | ||
"index.js" | ||
"src" | ||
], | ||
@@ -25,0 +26,0 @@ "odoKeywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
315725
14
3192
4