This repository has been archived on 2021-01-16. You can view files and clone it, but cannot push or open issues/pull-requests.
satyr/site/videojs/videojs-dash.min.js

3 lines
8.6 KiB
JavaScript
Raw Normal View History

/*! @name videojs-contrib-dash @version 2.11.0 @license Apache-2.0 */
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a(require("dashjs"),require("video.js"),require("global/window"),require("global/document")):"function"==typeof define&&define.amd?define(["dashjs","video.js","global/window","global/document"],a):e.videojsDash=a(e.dashjs,e.videojs,e.window,e.document)}(this,function(e,a,r,t){"use strict";function i(r,t){r.dash.mediaPlayer.on(e.MediaPlayer.events.PLAYBACK_METADATA_LOADED,function(r,t){var i=r.dash.mediaPlayer,n=i.getTracksFor("audio"),o=r.audioTracks();function s(e){return"dash-audio-"+e}function l(e,a){return e.find(function(e){return s(e.index)===a.id})}o.length&&t.clearTracks(["audio"]);var d=i.getCurrentTrackFor("audio");n.forEach(function(e){var t,i;if(Array.isArray(e.labels))for(var n=0;n<e.labels.length;n++)if(e.labels[n].lang&&-1!==r.language().indexOf(e.labels[n].lang.toLowerCase())){t=e.labels[n];break}t?i=t.text:Array.isArray(e.labels)&&1===e.labels.length?i=e.labels[0].text:(i=e.lang,e.roles&&e.roles.length&&(i+=" ("+e.roles.join(", ")+")")),o.addTrack(new a.AudioTrack({enabled:e===d,id:s(e.index),kind:e.kind||"main",label:i,language:e.lang}))});var c=function(){for(var e=0;e<o.length;e++){var a=o[e];if(a.enabled){var r=l(n,a);i.setCurrentTrack(r)}}};o.addEventListener("change",c),r.dash.mediaPlayer.on(e.MediaPlayer.events.STREAM_TEARDOWN_COMPLETE,function(){o.removeEventListener("change",c)})}.bind(null,r,t))}function n(t,i,n){r.VTTCue&&!/\[native code\]/.test(r.VTTCue.toString())&&(r.VTTCue=!1);var o=[];if(i.featuresNativeTextTracks)a.log.error("You must pass {html: {nativeCaptions: false}} in the videojs constructor to use text tracks in videojs-contrib-dash");else{var s=t.dash.mediaPlayer;s.on(e.MediaPlayer.events.TEXT_TRACKS_ADDED,l),s.on(e.MediaPlayer.events.CAN_PLAY,function(){s.off(e.MediaPlayer.events.TEXT_TRACKS_ADDED,l)})}function l(a){a.index;var r=a.tracks;s.off(e.MediaPlayer.events.TEXT_TRACKS_ADDED,l),o.forEach(t.removeRemoteTextTrack.bind(t)),o=[],r.length&&(o=function(a,r,t){var i=[],n=t.map(function(e){var r;if(Array.isArray(e.labels))for(var t=0;t<e.labels.length;t++)if(e.labels[t].lang&&-1!==a.language().indexOf(e.labels[t].lang.toLowerCase())){r=e.labels[t];break}return{dashTrack:e,trackConfig:{label:r?r.text:Array.isArray(e.labels)&&1===e.labels.length?e.labels[0].text:e.lang||e.label,language:e.lang,srclang:e.lang,kind:e.kind}}}).map(function(e){var r=e.trackConfig,t=e.dashTrack,n=a.addRemoteTextTrack(r,!1);return i.push({textTrack:n.track,dashTrack:t}),n});function o(){for(var e=a.dash.mediaPlayer,r=a.textTracks(),n=-1,o=function(e){var a=r[e];if("showing"===a.mode){var o=function(e,a){for(var r=0;r<e.length;r++)if(a(e[r]))return e[r]}(i,function(e){return e.textTrack===a}),s=o?o.dashTrack:null;s&&(n=t.indexOf(s))}},s=0;s<r.length;s+=1)o(s);n!==e.getCurrentTextTrackIndex()&&e.setTextTrack(n)}return a.textTracks().on("change",o),a.dash.mediaPlayer.on(e.MediaPlayer.events.STREAM_TEARDOWN_COMPLETE,function(){a.textTracks().off("change",o)}),o(),n}(t,0,r))}}e=e&&e.hasOwnProperty("default")?e.default:e,a=a&&a.hasOwnProperty("default")?a.default:a,r=r&&r.hasOwnProperty("default")?r.default:r,t=t&&t.hasOwnProperty("default")?t.default:t;var o=function(){function r(t,o,s){var l=this;if(s=s||o.options_,this.player=a(s.playerId),this.player.dash=this.player.dash||{},this.tech_=o,this.el_=o.el(),this.elParent_=this.el_.parentNode,this.hasFiniteDuration_=!1,t.src){o.isReady_=!1,r.updateSourceData&&(a.log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),t=r.updateSourceData(t)),r.hooks("updatesource").forEach(function(e){t=e(t)});var d=t.src;this.keySystemOptions_=r.buildDashJSProtData(t.keySystemOptions),this.player.dash.mediaPlayer=e.MediaPlayer().create(),this.mediaPlayer_=this.player.dash.mediaPlayer,this.mediaPlayer_.setTextDefaultEnabled(!1),r.useVideoJSDebug&&(a.log.warn('useVideoJSDebug has been deprecated. Please switch to using hook("beforeinitialize", callback).'),r.useVideoJSDebug(this.mediaPlayer_)),r.beforeInitialize&&(a.log.warn('beforeInitialize has