2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
/*! For license information please see ovenplayer.provider.DashProvider-0.9.0.js.LICENSE */
|
|
(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{136:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=function(e,t,r){var n=t?1e3:1024;if(Math.abs(e)<n)return e+" B";var o=r||"B",a=["k"+o,"M"+o,"G"+o,"T"+o,"P"+o,"E"+o,"Z"+o,"Y"+o],i=-1;do{e/=n,++i}while(Math.abs(e)>=n&&i<a.length-1);return e.toFixed(1)+a[i]}},310:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=l(r(316)),o=l(r(317)),a=l(r(66)),i=l(r(311)),u=r(306),s=r(1);function l(e){return e&&e.__esModule?e:{default:e}}t.default=function(e,t,r){OvenPlayerConsole.log("[Provider] loaded. ");var l={};(0,a.default)(l);var c=e.element,d=null,g=null;e.adTagUrl&&(OvenPlayerConsole.log("[Provider] Ad Client - ",t.getAdClient()),(d=t.getAdClient()===s.AD_CLIENT_VAST?(0,o.default)(c,l,t,e.adTagUrl):(0,n.default)(c,l,t,e.adTagUrl))||console.log("Can not load due to google ima for Ads.")),g=(0,i.default)(c,l,d?d.videoEndedCallback:null),c.playbackRate=c.defaultPlaybackRate=t.getPlaybackRate();var E=function(n){var o=e.sources[e.currentSource];if(e.framerate=o.framerate,l.setVolume(t.getVolume()),e.framerate||t.setTimecodeMode(!0),r)r(o,n);else{OvenPlayerConsole.log("source loaded : ",o,"lastPlayPosition : "+n);var a=c.src;o.file!==a&&(c.src=o.file,(a||""===a)&&c.load(),n&&n>0&&l.seek(n)),n>0&&(l.seek(n),t.isAutoStart()),t.isAutoStart()}};return l.getName=function(){return e.name},l.canSeek=function(){return e.canSeek},l.setCanSeek=function(t){e.canSeek=t},l.isSeeking=function(){return e.seeking},l.setSeeking=function(t){e.seeking=t},l.setMetaLoaded=function(){e.isLoaded=!0},l.metaLoaded=function(){return e.isLoaded},l.setState=function(t){if(e.state!==t){var r=e.state;if(OvenPlayerConsole.log("Provider : setState()",t),r===s.STATE_AD_PLAYING&&(t===s.STATE_ERROR||t===s.STATE_IDLE))return!1;switch(OvenPlayerConsole.log("Provider : triggerSatatus",t),t){case s.STATE_COMPLETE:l.trigger(s.PLAYER_COMPLETE);break;case s.STATE_PAUSED:l.trigger(s.PLAYER_PAUSE,{prevState:e.state,newstate:s.STATE_PAUSED});break;case s.STATE_AD_PAUSED:l.trigger(s.PLAYER_PAUSE,{prevState:e.state,newstate:s.STATE_AD_PAUSED});break;case s.STATE_PLAYING:l.trigger(s.PLAYER_PLAY,{prevState:e.state,newstate:s.STATE_PLAYING});case s.STATE_AD_PLAYING:l.trigger(s.PLAYER_PLAY,{prevState:e.state,newstate:s.STATE_AD_PLAYING})}e.state=t,l.trigger(s.PLAYER_STATE,{prevstate:r,newstate:e.state})}},l.getState=function(){return e.state},l.setBuffer=function(t){e.buffer=t},l.getBuffer=function(){return e.buffer},l.isLive=function(){return!!e.isLive||c.duration===1/0},l.getDuration=function(){return l.isLive()?1/0:c.duration},l.getPosition=function(){return c?c.currentTime:0},l.setVolume=function(e){if(!c)return!1;c.volume=e/100},l.getVolume=function(){return c?100*c.volume:0},l.setMute=function(e){return!!c&&(void 0===e?(c.muted=!c.muted,l.trigger(s.CONTENT_MUTE,{mute:c.muted})):(c.muted=e,l.trigger(s.CONTENT_MUTE,{mute:c.muted})),c.muted)},l.getMute=function(){return!!c&&c.muted},l.preload=function(r,n){return e.sources=r,e.currentSource=(0,u.pickCurrentSource)(r,e.currentSource,t),E(n||0),new Promise(function(e,r){t.isMute()&&l.setMute(!0),t.getVolume()&&l.setVolume(t.getVolume()),e()})},l.load=function(r){e.sources=r,e.currentSource=(0,u.pickCurrentSource)(r,e.currentSource,t),E(e.sources.starttime||0)},l.play=function(){if(OvenPlayerConsole.log("Provider : play()"),!c)return!1;if(l.getState()!==s.STATE_PLAYING)if(d&&d.isActive()||d&&!d.started())d.play().then(function(e){OvenPlayerConsole.log("Provider : ads play success")}).catch(function(e){OvenPlayerConsole.log("Provider : ads play fail",e)});else{var e=c.play();void 0!==e?e.then(function(){OvenPlayerConsole.log("Provider : video play success")}).catch(function(e){OvenPlayerConsole.log("Provider : video play error",e.message)}):OvenPlayerConsole.log("Provider : video play success (ie)")}},l.pause=function(){if(OvenPlayerConsole.log("Provider : pause()"),!c)return!1;l.getState()===s.STATE_PLAYING?c.pause():l.getState()===s.STATE_AD_PLAYING&&d.pause()},l.seek=function(e){if(!c)return!1;c.currentTime=e},l.setPlaybackRate=function(e){return!!c&&(l.trigger(s.PLAYBACK_RATE_CHANGED,{playbackRate:e}),c.playbackRate=c.defaultPlaybackRate=e)},l.getPlaybackRate=function(){return c?c.playbackRate:0},l.getSources=function(){return c?e.sources.map(function(e,t){var r={file:e.file,type:e.type,label:e.label,index:t,sectionStart:e.sectionStart,sectionEnd:e.sectionEnd,gridThumbnail:e.gridThumbnail};return e.lowLatency&&(r.lowLatency=e.lowLatency),r}):[]},l.getCurrentSource=function(){return e.currentSource},l.setCurrentSource=function(r,n){if(r>-1&&e.sources&&e.sources.length>r)return OvenPlayerConsole.log("source changed : "+r),e.currentSource=r,l.trigger(s.CONTENT_SOURCE_CHANGED,{currentSource:r}),t.setSourceIndex(r),l.setState(s.STATE_IDLE),n&&E(c.currentTime||0),e.currentSource},l.getQualityLevels=function(){return c?e.qualityLevels:[]},l.getCurrentQuality=function(){return c?e.currentQuality:null},l.setCurrentQuality=function(e){},l.isAutoQuality=function(){},l.setAutoQuality=function(e){},l.getFramerate=function(){return e.framerate},l.setFramerate=function(t){return e.framerate=t},l.seekFrame=function(t){var r=e.framerate,n=(c.currentTime*r+t)/r;n+=1e-5,l.pause(),l.seek(n)},l.stop=function(){if(!c)return!1;for(OvenPlayerConsole.log("CORE : stop() "),c.removeAttribute("preload"),c.removeAttribute("src");c.firstChild;)c.removeChild(c.firstChild);l.pause(),l.setState(s.STATE_IDLE)},l.destroy=function(){if(!c)return!1;l.stop(),g.destroy(),d&&(d.destroy(),d=null),l.off(),OvenPlayerConsole.log("CORE : destroy() player stop, listener, event destroied")},l.super=function(e){var t=l[e];return function(){return t.apply(l,arguments)}},l}},311:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),o=r(306);t.default=function(e,t,r){var a={};OvenPlayerConsole.log("EventListener loaded.",e,t);var i={},u=-1,s=e;return a.canplay=function(){t.setCanSeek(!0),t.trigger(n.CONTENT_BUFFER_FULL),OvenPlayerConsole.log("EventListener : on canplay")},a.durationchange=function(){a.progress(),OvenPlayerConsole.log("EventListener : on durationchange")},a.ended=function(){OvenPlayerConsole.log("EventListener : on ended"),t.getState()!==n.STATE_IDLE&&t.getState()!==n.STATE_COMPLETE&&t.getState()!==n.STATE_ERROR&&(r?r(function(){t.setState(n.STATE_COMPLETE)}):t.setState(n.STATE_COMPLETE))},a.loadeddata=function(){},a.loadedmetadata=function(){var e=t.getSources(),r=t.getCurrentSource(),o=r>-1?e[r].type:"",a={duration:t.isLive()?1/0:s.duration,type:o};t.setMetaLoaded(),OvenPlayerConsole.log("EventListener : on loadedmetadata",a),t.trigger(n.CONTENT_META,a)},a.pause=function(){return t.getState()!==n.STATE_COMPLETE&&t.getState()!==n.STATE_ERROR&&!s.ended&&!s.error&&s.currentTime!==s.duration&&(OvenPlayerConsole.log("EventListener : on pause"),void t.setState(n.STATE_PAUSED))},a.play=function(){u=-1,s.paused||t.getState()===n.STATE_PLAYING||t.setState(n.STATE_LOADING)},a.playing=function(){OvenPlayerConsole.log("EventListener : on playing"),u<0&&t.setState(n.STATE_PLAYING)},a.progress=function(){var e=s.buffered;if(!e)return!1;var r=s.duration,o=s.currentTime,a=function(e,t,r){return Math.max(Math.min(e,r),t)}((e.length>0?e.end(e.length-1):0)/r,0,1);t.setBuffer(100*a),t.trigger(n.CONTENT_BUFFER,{bufferPercent:100*a,position:o,duration:r}),OvenPlayerConsole.log("EventListener : on progress",100*a)},a.timeupdate=function(){var e=s.currentTime,r=s.duration;if(!isNaN(r)){var o=t.getSources()[t.getCurrentSource()].sectionStart;o&&e<o&&t.getState()===n.STATE_PLAYING&&t.seek(o);var a=t.getSources()[t.getCurrentSource()].sectionEnd;if(a&&e>a&&t.getState()===n.STATE_PLAYING)return t.stop(),void t.setState(n.STATE_COMPLETE);r>9e15&&(r=1/0),t.isSeeking()||s.paused||t.getState()!==n.STATE_STALLED&&t.getState()!==n.STATE_LOADING&&t.getState()!==n.STATE_AD_PLAYING||function(e,t){return e.toFixed(2)===t.toFixed(2)}(u,e)||(u=-1,t.setState(n.STATE_PLAYING)),o&&o>0&&(e-=o)<0&&(e=0),a&&(r=a),o&&(r-=o),(t.getState()===n.STATE_PLAYING||t.isSeeking())&&t.trigger(n.CONTENT_TIME,{position:e,duration:r})}},a.seeking=function(){t.setSeeking(!0),OvenPlayerConsole.log("EventListener : on seeking",s.currentTime),t.trigger(n.CONTENT_SEEK,{position:s.currentTime})},a.seeked=function(){t.isSeeking()&&(OvenPlayerConsole.log("EventListener : on seeked"),t.setSeeking(!1),t.trigger(n.CONTENT_SEEKED))},a.stalled=function(){OvenPlayerConsole.log("EventListener : on stalled")},a.waiting=function(){OvenPlayerConsole.log("EventListener : on waiting",t.getState()),t.isSeeking()?t.setState(n.STATE_LOADING):t.getState()===n.STATE_PLAYING&&(u=s.currentTime,t.setState(n.STATE_STALLED))},a.volumechange=function(){OvenPlayerConsole.log("EventListener : on volumechange",Math.round(100*s.volume)),t.trigger(n.CONTENT_VOLUME,{volume:Math.round(100*s.volume),mute:s.muted})},a.error=function(){var e=s.error&&s.error.code||0,r={0:n.PLAYER_UNKNWON_ERROR,1:n.PLAYER_UNKNWON_OPERATION_ERROR,2:n.PLAYER_UNKNWON_NETWORK_ERROR,3:n.PLAYER_UNKNWON_DECODE_ERROR,4:n.PLAYER_FILE_ERROR}[e]||0;OvenPlayerConsole.log("EventListener : on error",r),(0,o.errorTrigger)(n.ERRORS.codes[r],t)},Object.keys(a).forEach(function(e){s.removeEventListener(e,a[e]),s.addEventListener(e,a[e])}),i.destroy=function(){OvenPlayerConsole.log("EventListener : destroy()"),Object.keys(a).forEach(function(e){s.removeEventListener(e,a[e])})},i}},74:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=l(r(310)),o=r(306),a=l(r(136)),i=r(1),u=l(r(7)),s=r(1);function l(e){return e&&e.__esModule?e:{default:e}}t.default=function(e,t,r){var l={},c=null,d=null,g=null,E=0,f=!1,T=null,S=null,A="",v=!1;try{if(dashjs.Version<"2.6.5")throw i.ERRORS.codes[i.INIT_DASH_UNSUPPORT];var y=function(e){dashjs.Version>="3.0.0"?c.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:e}}}}):dashjs.Version>"2.9.0"?c.setAutoSwitchQualityFor("video",e):c.setAutoSwitchQualityFor(e)},L=function(){return dashjs.Version>="3.0.0"?c.getSettings().streaming.abr.autoSwitchBitrate.video:dashjs.Version>"2.9.0"?c.getAutoSwitchQualityFor("video"):c.getAutoSwitchQualityFor()},P=function(){if(c.duration()!==T){T=c.duration();var e=c.getDashMetrics().getCurrentDVRInfo(),r=t.getConfig().lowLatencyMpdLiveDelay;r||(r=3),c.seek(e.range.end-e.range.start-r)}};(c=dashjs.MediaPlayer().create()).initialize(e,null,!1),window.op_dash=c;var _={name:i.PROVIDER_DASH,element:e,mse:c,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:i.STATE_IDLE,buffer:0,framerate:0,currentQuality:-1,currentSource:-1,qualityLevels:[],sources:[],adTagUrl:r};l=(0,n.default)(_,t,function(e,r){OvenPlayerConsole.log("DASH : Attach File : ",e,"lastPlayPosition : "+r),y(!0),A=e.file,c.off(dashjs.MediaPlayer.events.PLAYBACK_PLAYING,P),!0===e.lowLatency?(T=null,dashjs.Version>="3.0.0"?c.updateSettings({streaming:{lowLatencyEnabled:e.lowLatency}}):c.setLowLatencyEnabled(e.lowLatency),t.getConfig().lowLatencyMpdLiveDelay&&"number"==typeof t.getConfig().lowLatencyMpdLiveDelay&&(dashjs.Version>="3.0.0"?c.updateSettings({streaming:{liveDelay:t.getConfig().lowLatencyMpdLiveDelay}}):c.setLiveDelay(t.getConfig().lowLatencyMpdLiveDelay)),c.on(dashjs.MediaPlayer.events.PLAYBACK_PLAYING,P)):dashjs.Version>="3.0.0"?c.updateSettings({streaming:{lowLatencyEnabled:!1,liveDelay:void 0}}):(c.setLowLatencyEnabled(!1),c.setLiveDelay()),dashjs.Version>="3.0.0"?c.updateSettings({debug:{logLevel:dashjs.Debug.LOG_LEVEL_NONE},streaming:{retryAttempts:{MPD:0}}}):c.getDebug().setLogToBrowserConsole(!1),c.attachSource(A),E=r}),d=l.super("play"),g=l.super("destroy"),OvenPlayerConsole.log("DASH PROVIDER LOADED.");var O=t.getConfig().loadingRetryCount;c.on(dashjs.MediaPlayer.events.ERROR,function(e){if(e&&(e.error.code===dashjs.MediaPlayer.errors.DOWNLOAD_ERROR_ID_MANIFEST_CODE||e.error.code===dashjs.MediaPlayer.errors.MANIFEST_LOADER_LOADING_FAILURE_ERROR_CODE))if(O>0)l.setState(s.STATE_LOADING),S&&(clearTimeout(S),S=null),O-=1,S=setTimeout(function(){c.attachSource(A)},1e3);else{var t=i.ERRORS.codes[i.PLAYER_UNKNWON_NETWORK_ERROR];t.error=e,(0,o.errorTrigger)(t,l)}}),c.on(dashjs.MediaPlayer.events.QUALITY_CHANGE_REQUESTED,function(e){e&&e.mediaType&&"video"===e.mediaType&&l.trigger(i.CONTENT_LEVEL_CHANGED,{isAuto:L(),currentQuality:_.currentQuality,type:"request"})}),c.on(dashjs.MediaPlayer.events.QUALITY_CHANGE_RENDERED,function(e){e&&e.mediaType&&"video"===e.mediaType&&(_.currentQuality=e.newQuality,l.trigger(i.CONTENT_LEVEL_CHANGED,{isAuto:L(),currentQuality:e.newQuality,type:"render"}))}),c.on(dashjs.MediaPlayer.events.PLAYBACK_METADATA_LOADED,function(e){dashjs.Version>="3.0.0"&&c.updateSettings({streaming:{retryAttempts:{MPD:2}}}),OvenPlayerConsole.log("DASH : PLAYBACK_METADATA_LOADED : ",c.getQualityFor("video"),c.getBitrateInfoListFor("video"),c.getBitrateInfoListFor("video")[c.getQualityFor("video")]),f=!0;var r=c.getBitrateInfoListFor("video");_.currentQuality=c.getQualityFor("video");for(var n=0;n<r.length;n++)u.default.findWhere(_.qualityLevels,{bitrate:r[n].bitrate,height:r[n].height,width:r[n].width})||_.qualityLevels.push({bitrate:r[n].bitrate,height:r[n].height,width:r[n].width,index:r[n].qualityIndex,label:r[n].width+"x"+r[n].height+", "+(0,a.default)(r[n].bitrate,!0,"bps")});E&&(c.seek(E),t.isAutoStart()),c.isDynamic()&&(_.isLive=!0),t.isAutoStart()&&!v&&(OvenPlayerConsole.log("DASH : AUTOPLAY()!"),v=!0)}),l.play=function(t){var r=0;l.getState()===i.STATE_AD_PLAYING||l.getState()===i.STATE_AD_PAUSED||(f=!1,c.attachView(e)),function e(){r++,f?d(t):r<300?setTimeout(e,100):l.play()}()},l.setCurrentQuality=function(e){return l.getState()!==i.STATE_PLAYING&&l.play(),_.currentQuality=e,L()&&y(!1),c.setQualityFor("video",e),_.currentQuality},l.isAutoQuality=function(){return L()},l.setAutoQuality=function(e){y(e)},l.destroy=function(){c.reset(),OvenPlayerConsole.log("DASH : PROVIDER DESTROYED."),g()}}catch(e){if(e&&e.code&&e.code===i.INIT_DASH_UNSUPPORT)throw e;var C=i.ERRORS.codes[i.INIT_DASH_NOTFOUND];throw C.error=e,C}return l}}}]); |