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

videojs-contrib-dash

Package Overview
Dependencies
Maintainers
7
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

videojs-contrib-dash - npm Package Compare versions

Comparing version 2.10.1 to 2.11.0

src/js/.setup-audio-tracks.js.swp

5

CHANGELOG.md
CHANGELOG
=========
## 2.11.0 (2019-03-08)
* Fix bug where VTT captions wouldn't show
* Support for human-readable track labels
## 2.10.1 (2018-12-18)

@@ -76,2 +80,1 @@ * Change main to be `dist/videojs-dash.cjs.js`

* Update project to be compatible with video.js 5.0

56

dist/videojs-dash.cjs.js

@@ -1,2 +0,2 @@

/*! @name videojs-contrib-dash @version 2.10.1 @license Apache-2.0 */
/*! @name videojs-contrib-dash @version 2.11.0 @license Apache-2.0 */
'use strict';

@@ -45,6 +45,25 @@

dashAudioTracks.forEach(function (dashTrack) {
var label = dashTrack.lang;
var localizedLabel;
if (dashTrack.roles && dashTrack.roles.length) {
label += " (" + dashTrack.roles.join(', ') + ")";
if (Array.isArray(dashTrack.labels)) {
for (var i = 0; i < dashTrack.labels.length; i++) {
if (dashTrack.labels[i].lang && player.language().indexOf(dashTrack.labels[i].lang.toLowerCase()) !== -1) {
localizedLabel = dashTrack.labels[i];
break;
}
}
}
var label;
if (localizedLabel) {
label = localizedLabel.text;
} else if (Array.isArray(dashTrack.labels) && dashTrack.labels.length === 1) {
label = dashTrack.labels[0].text;
} else {
label = dashTrack.lang;
if (dashTrack.roles && dashTrack.roles.length) {
label += ' (' + dashTrack.roles.join(', ') + ')';
}
} // Add the track to the player's audio track list.

@@ -116,6 +135,27 @@

.map(function (track) {
var localizedLabel;
if (Array.isArray(track.labels)) {
for (var i = 0; i < track.labels.length; i++) {
if (track.labels[i].lang && player.language().indexOf(track.labels[i].lang.toLowerCase()) !== -1) {
localizedLabel = track.labels[i];
break;
}
}
}
var label;
if (localizedLabel) {
label = localizedLabel.text;
} else if (Array.isArray(track.labels) && track.labels.length === 1) {
label = track.labels[0].text;
} else {
label = track.lang || track.label;
}
return {
dashTrack: track,
trackConfig: {
label: track.lang,
label: label,
language: track.lang,

@@ -294,4 +334,8 @@ srclang: track.lang,

this.player.dash.mediaPlayer = dashjs.MediaPlayer().create();
this.mediaPlayer_ = this.player.dash.mediaPlayer; // Log MedaPlayer messages through video.js
this.mediaPlayer_ = this.player.dash.mediaPlayer; // For whatever reason, we need to call setTextDefaultEnabled(false) to get
// VTT captions to show, even though we're doing virtually the same thing
// in setup-text-tracks.js
this.mediaPlayer_.setTextDefaultEnabled(false); // Log MedaPlayer messages through video.js
if (Html5DashJS.useVideoJSDebug) {

@@ -298,0 +342,0 @@ videojs.log.warn('useVideoJSDebug has been deprecated.' + ' Please switch to using hook("beforeinitialize", callback).');

@@ -1,2 +0,2 @@

/*! @name videojs-contrib-dash @version 2.10.1 @license Apache-2.0 */
/*! @name videojs-contrib-dash @version 2.11.0 @license Apache-2.0 */
import dashjs from 'dashjs';

@@ -41,6 +41,25 @@ import videojs from 'video.js';

dashAudioTracks.forEach(function (dashTrack) {
var label = dashTrack.lang;
var localizedLabel;
if (dashTrack.roles && dashTrack.roles.length) {
label += " (" + dashTrack.roles.join(', ') + ")";
if (Array.isArray(dashTrack.labels)) {
for (var i = 0; i < dashTrack.labels.length; i++) {
if (dashTrack.labels[i].lang && player.language().indexOf(dashTrack.labels[i].lang.toLowerCase()) !== -1) {
localizedLabel = dashTrack.labels[i];
break;
}
}
}
var label;
if (localizedLabel) {
label = localizedLabel.text;
} else if (Array.isArray(dashTrack.labels) && dashTrack.labels.length === 1) {
label = dashTrack.labels[0].text;
} else {
label = dashTrack.lang;
if (dashTrack.roles && dashTrack.roles.length) {
label += ' (' + dashTrack.roles.join(', ') + ')';
}
} // Add the track to the player's audio track list.

@@ -112,6 +131,27 @@

.map(function (track) {
var localizedLabel;
if (Array.isArray(track.labels)) {
for (var i = 0; i < track.labels.length; i++) {
if (track.labels[i].lang && player.language().indexOf(track.labels[i].lang.toLowerCase()) !== -1) {
localizedLabel = track.labels[i];
break;
}
}
}
var label;
if (localizedLabel) {
label = localizedLabel.text;
} else if (Array.isArray(track.labels) && track.labels.length === 1) {
label = track.labels[0].text;
} else {
label = track.lang || track.label;
}
return {
dashTrack: track,
trackConfig: {
label: track.lang,
label: label,
language: track.lang,

@@ -290,4 +330,8 @@ srclang: track.lang,

this.player.dash.mediaPlayer = dashjs.MediaPlayer().create();
this.mediaPlayer_ = this.player.dash.mediaPlayer; // Log MedaPlayer messages through video.js
this.mediaPlayer_ = this.player.dash.mediaPlayer; // For whatever reason, we need to call setTextDefaultEnabled(false) to get
// VTT captions to show, even though we're doing virtually the same thing
// in setup-text-tracks.js
this.mediaPlayer_.setTextDefaultEnabled(false); // Log MedaPlayer messages through video.js
if (Html5DashJS.useVideoJSDebug) {

@@ -294,0 +338,0 @@ videojs.log.warn('useVideoJSDebug has been deprecated.' + ' Please switch to using hook("beforeinitialize", callback).');

@@ -1,2 +0,2 @@

/*! @name videojs-contrib-dash @version 2.10.1 @license Apache-2.0 */
/*! @name videojs-contrib-dash @version 2.11.0 @license Apache-2.0 */
(function (global, factory) {

@@ -47,6 +47,25 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('dashjs'), require('video.js'), require('global/window'), require('global/document')) :

dashAudioTracks.forEach(function (dashTrack) {
var label = dashTrack.lang;
var localizedLabel;
if (dashTrack.roles && dashTrack.roles.length) {
label += " (" + dashTrack.roles.join(', ') + ")";
if (Array.isArray(dashTrack.labels)) {
for (var i = 0; i < dashTrack.labels.length; i++) {
if (dashTrack.labels[i].lang && player.language().indexOf(dashTrack.labels[i].lang.toLowerCase()) !== -1) {
localizedLabel = dashTrack.labels[i];
break;
}
}
}
var label;
if (localizedLabel) {
label = localizedLabel.text;
} else if (Array.isArray(dashTrack.labels) && dashTrack.labels.length === 1) {
label = dashTrack.labels[0].text;
} else {
label = dashTrack.lang;
if (dashTrack.roles && dashTrack.roles.length) {
label += ' (' + dashTrack.roles.join(', ') + ')';
}
} // Add the track to the player's audio track list.

@@ -118,6 +137,27 @@

.map(function (track) {
var localizedLabel;
if (Array.isArray(track.labels)) {
for (var i = 0; i < track.labels.length; i++) {
if (track.labels[i].lang && player.language().indexOf(track.labels[i].lang.toLowerCase()) !== -1) {
localizedLabel = track.labels[i];
break;
}
}
}
var label;
if (localizedLabel) {
label = localizedLabel.text;
} else if (Array.isArray(track.labels) && track.labels.length === 1) {
label = track.labels[0].text;
} else {
label = track.lang || track.label;
}
return {
dashTrack: track,
trackConfig: {
label: track.lang,
label: label,
language: track.lang,

@@ -296,4 +336,8 @@ srclang: track.lang,

this.player.dash.mediaPlayer = dashjs.MediaPlayer().create();
this.mediaPlayer_ = this.player.dash.mediaPlayer; // Log MedaPlayer messages through video.js
this.mediaPlayer_ = this.player.dash.mediaPlayer; // For whatever reason, we need to call setTextDefaultEnabled(false) to get
// VTT captions to show, even though we're doing virtually the same thing
// in setup-text-tracks.js
this.mediaPlayer_.setTextDefaultEnabled(false); // Log MedaPlayer messages through video.js
if (Html5DashJS.useVideoJSDebug) {

@@ -300,0 +344,0 @@ videojs.log.warn('useVideoJSDebug has been deprecated.' + ' Please switch to using hook("beforeinitialize", callback).');

@@ -1,2 +0,2 @@

/*! @name videojs-contrib-dash @version 2.10.1 @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 d(e,a){return e.find(function(e){return s(e.index)===a.id})}o.length&&t.clearTracks(["audio"]);var l=i.getCurrentTrackFor("audio");n.forEach(function(e){var r=e.lang;e.roles&&e.roles.length&&(r+=" ("+e.roles.join(", ")+")"),o.addTrack(new a.AudioTrack({enabled:e===l,id:s(e.index),kind:e.kind||"main",label:r,language:e.lang}))});var c=function(){for(var e=0;e<o.length;e++){var a=o[e];if(a.enabled){var r=d(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,d),s.on(e.MediaPlayer.events.CAN_PLAY,function(){s.off(e.MediaPlayer.events.TEXT_TRACKS_ADDED,d)})}function d(a){a.index;var r=a.tracks;s.off(e.MediaPlayer.events.TEXT_TRACKS_ADDED,d),o.forEach(t.removeRemoteTextTrack.bind(t)),o=[],r.length&&(o=function(a,r,t){var i=[],n=t.map(function(e){return{dashTrack:e,trackConfig:{label:e.lang,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 d=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 l=t.src;this.keySystemOptions_=r.buildDashJSProtData(t.keySystemOptions),this.player.dash.mediaPlayer=e.MediaPlayer().create(),this.mediaPlayer_=this.player.dash.mediaPlayer,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 been deprecated. Please switch to using hook("beforeinitialize", callback).'),r.beforeInitialize(this.player,this.mediaPlayer_)),r.hooks("beforeinitialize").forEach(function(e){e(d.player,d.mediaPlayer_)}),this.mediaPlayer_.initialize(),this.retriggerError_=function(e){if("capability"===e.error&&"mediasource"===e.event)d.player.error({code:4,message:"The media cannot be played because it requires a feature that your browser does not support."});else if("manifestError"!==e.error||"createParser"!==e.event.id&&"codec"!==e.event.id&&"nostreams"!==e.event.id&&"nostreamscomposed"!==e.event.id&&"parse"!==e.event.id&&"multiplexedrep"!==e.event.id)if("mediasource"===e.error)e.event.match("MEDIA_ERR_ABORTED")?d.player.error({code:1,message:e.event}):e.event.match("MEDIA_ERR_NETWORK")?d.player.error({code:2,message:e.event}):e.event.match("MEDIA_ERR_DECODE")?d.player.error({code:3,message:e.event}):e.event.match("MEDIA_ERR_SRC_NOT_SUPPORTED")?d.player.error({code:4,message:e.event}):e.event.match("MEDIA_ERR_ENCRYPTED")?d.player.error({code:5,message:e.event}):(e.event.match("UNKNOWN"),d.player.error({code:4,message:e.event}));else if("capability"===e.error&&"encryptedmedia"===e.event)d.player.error({code:5,message:"The media cannot be played because it requires encryption features that your browser does not support."});else if("key_session"===e.error)d.player.error({code:5,message:e.event});else if("download"===e.error)d.player.error({code:2,message:"The media playback was aborted because too many consecutive download errors occurred."});else{if("mssError"!==e.error)return;d.player.error({code:3,message:e.event})}else d.player.error({code:4,message:e.event.message});setTimeout(function(){d.mediaPlayer_.reset()},10)},this.mediaPlayer_.on(e.MediaPlayer.events.ERROR,this.retriggerError_),this.getDuration_=function(e){var a=e.data.Period_asArray,r=d.hasFiniteDuration_;e.data.mediaPresentationDuration||a[a.length-1].duration?d.hasFiniteDuration_=!0:d.hasFiniteDuration_=!1,d.hasFiniteDuration_!==r&&d.player.trigger("durationchange")},this.mediaPlayer_.on(e.MediaPlayer.events.MANIFEST_LOADED,this.getDuration_),s.dash&&Object.keys(s.dash).forEach(function(e){var r,t="set"+e.charAt(0).toUpperCase()+e.slice(1),i=s.dash[e];d.mediaPlayer_.hasOwnProperty(t)&&(a.log.warn("Using dash options in videojs-contrib-dash without the set prefix has been deprecated. Change '"+e+"' to '"+t+"'"),e=t),d.mediaPlayer_.hasOwnProperty(e)?(Array.isArray(i)||(i=[i]),(r=d.mediaPlayer_)[e].apply(r,i)):a.log.warn("Warning: dash configuration option unrecognized: "+e)}),this.mediaPlayer_.attachView(this.el_),this.mediaPlayer_.setAutoPlay(!1),i.call(null,this.player,o),n.call(null,this.player,o,s),this.mediaPlayer_.setProtectionData(this.keySystemOptions_),this.mediaPlayer_.attachSource(l),this.tech_.triggerReady()}}r.buildDashJSProtData=function(e){var r={};if(!e||!Array.isArray(e))return null;for(var t=0;t<e.length;t++){var i=e[t],n=a.mergeOptions({},i.options);n.licenseUrl&&(n.serverURL=n.licenseUrl,delete n.licenseUrl),r[i.name]=n}return r};var t=r.prototype;return t.dispose=function(){this.mediaPlayer_&&(this.mediaPlayer_.off(e.MediaPlayer.events.ERROR,this.retriggerError_),this.mediaPlayer_.off(e.MediaPlayer.events.MANIFEST_LOADED,this.getDuration_),this.mediaPlayer_.reset()),this.player.dash&&delete this.player.dash},t.duration=function(){return this.mediaPlayer_.isDynamic()&&!this.hasFiniteDuration_?1/0:this.mediaPlayer_.duration()},r.hooks=function(e,a){return r.hooks_[e]=r.hooks_[e]||[],a&&(r.hooks_[e]=r.hooks_[e].concat(a)),r.hooks_[e]},r.hook=function(e,a){r.hooks(e,a)},r.removeHook=function(e,a){var t=r.hooks(e).indexOf(a);return-1!==t&&(r.hooks_[e]=r.hooks_[e].slice(),r.hooks_[e].splice(t,1),!0)},r}();o.hooks_={};return a.DashSourceHandler=function(){return{canHandleSource:function(e){return function(e){e=JSON.parse(JSON.stringify(e)),o.updateSourceData&&(a.log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),e=o.updateSourceData(e)),o.hooks("updatesource").forEach(function(a){e=a(e)});var i=t.createElement("video");return!(e.keySystemOptions&&!r.navigator.requestMediaKeySystemAccess&&!i.msSetMediaKeys)}(e)?a.DashSourceHandler.canPlayType(e.type)?"probably":/\.mpd/i.test(e.src)?"maybe":"":""},handleSource:function(e,a,r){return new o(e,a,r)},canPlayType:function(e){return a.DashSourceHandler.canPlayType(e)}}},a.DashSourceHandler.canPlayType=function(e){return/^application\/dash\+xml/i.test(e)?"probably":""},r.MediaSource&&a.getTech("Html5").registerSourceHandler(a.DashSourceHandler(),0),a.Html5DashJS=o,o});
/*! @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 been deprecated. Please switch to using hook("beforeinitialize", callback).'),r.beforeInitialize(this.player,this.mediaPlayer_)),r.hooks("beforeinitialize").forEach(function(e){e(l.player,l.mediaPlayer_)}),this.mediaPlayer_.initialize(),this.retriggerError_=function(e){if("capability"===e.error&&"mediasource"===e.event)l.player.error({code:4,message:"The media cannot be played because it requires a feature that your browser does not support."});else if("manifestError"!==e.error||"createParser"!==e.event.id&&"codec"!==e.event.id&&"nostreams"!==e.event.id&&"nostreamscomposed"!==e.event.id&&"parse"!==e.event.id&&"multiplexedrep"!==e.event.id)if("mediasource"===e.error)e.event.match("MEDIA_ERR_ABORTED")?l.player.error({code:1,message:e.event}):e.event.match("MEDIA_ERR_NETWORK")?l.player.error({code:2,message:e.event}):e.event.match("MEDIA_ERR_DECODE")?l.player.error({code:3,message:e.event}):e.event.match("MEDIA_ERR_SRC_NOT_SUPPORTED")?l.player.error({code:4,message:e.event}):e.event.match("MEDIA_ERR_ENCRYPTED")?l.player.error({code:5,message:e.event}):(e.event.match("UNKNOWN"),l.player.error({code:4,message:e.event}));else if("capability"===e.error&&"encryptedmedia"===e.event)l.player.error({code:5,message:"The media cannot be played because it requires encryption features that your browser does not support."});else if("key_session"===e.error)l.player.error({code:5,message:e.event});else if("download"===e.error)l.player.error({code:2,message:"The media playback was aborted because too many consecutive download errors occurred."});else{if("mssError"!==e.error)return;l.player.error({code:3,message:e.event})}else l.player.error({code:4,message:e.event.message});setTimeout(function(){l.mediaPlayer_.reset()},10)},this.mediaPlayer_.on(e.MediaPlayer.events.ERROR,this.retriggerError_),this.getDuration_=function(e){var a=e.data.Period_asArray,r=l.hasFiniteDuration_;e.data.mediaPresentationDuration||a[a.length-1].duration?l.hasFiniteDuration_=!0:l.hasFiniteDuration_=!1,l.hasFiniteDuration_!==r&&l.player.trigger("durationchange")},this.mediaPlayer_.on(e.MediaPlayer.events.MANIFEST_LOADED,this.getDuration_),s.dash&&Object.keys(s.dash).forEach(function(e){var r,t="set"+e.charAt(0).toUpperCase()+e.slice(1),i=s.dash[e];l.mediaPlayer_.hasOwnProperty(t)&&(a.log.warn("Using dash options in videojs-contrib-dash without the set prefix has been deprecated. Change '"+e+"' to '"+t+"'"),e=t),l.mediaPlayer_.hasOwnProperty(e)?(Array.isArray(i)||(i=[i]),(r=l.mediaPlayer_)[e].apply(r,i)):a.log.warn("Warning: dash configuration option unrecognized: "+e)}),this.mediaPlayer_.attachView(this.el_),this.mediaPlayer_.setAutoPlay(!1),i.call(null,this.player,o),n.call(null,this.player,o,s),this.mediaPlayer_.setProtectionData(this.keySystemOptions_),this.mediaPlayer_.attachSource(d),this.tech_.triggerReady()}}r.buildDashJSProtData=function(e){var r={};if(!e||!Array.isArray(e))return null;for(var t=0;t<e.length;t++){var i=e[t],n=a.mergeOptions({},i.options);n.licenseUrl&&(n.serverURL=n.licenseUrl,delete n.licenseUrl),r[i.name]=n}return r};var t=r.prototype;return t.dispose=function(){this.mediaPlayer_&&(this.mediaPlayer_.off(e.MediaPlayer.events.ERROR,this.retriggerError_),this.mediaPlayer_.off(e.MediaPlayer.events.MANIFEST_LOADED,this.getDuration_),this.mediaPlayer_.reset()),this.player.dash&&delete this.player.dash},t.duration=function(){return this.mediaPlayer_.isDynamic()&&!this.hasFiniteDuration_?1/0:this.mediaPlayer_.duration()},r.hooks=function(e,a){return r.hooks_[e]=r.hooks_[e]||[],a&&(r.hooks_[e]=r.hooks_[e].concat(a)),r.hooks_[e]},r.hook=function(e,a){r.hooks(e,a)},r.removeHook=function(e,a){var t=r.hooks(e).indexOf(a);return-1!==t&&(r.hooks_[e]=r.hooks_[e].slice(),r.hooks_[e].splice(t,1),!0)},r}();o.hooks_={};return a.DashSourceHandler=function(){return{canHandleSource:function(e){return function(e){e=JSON.parse(JSON.stringify(e)),o.updateSourceData&&(a.log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),e=o.updateSourceData(e)),o.hooks("updatesource").forEach(function(a){e=a(e)});var i=t.createElement("video");return!(e.keySystemOptions&&!r.navigator.requestMediaKeySystemAccess&&!i.msSetMediaKeys)}(e)?a.DashSourceHandler.canPlayType(e.type)?"probably":/\.mpd/i.test(e.src)?"maybe":"":""},handleSource:function(e,a,r){return new o(e,a,r)},canPlayType:function(e){return a.DashSourceHandler.canPlayType(e)}}},a.DashSourceHandler.canPlayType=function(e){return/^application\/dash\+xml/i.test(e)?"probably":""},r.MediaSource&&a.getTech("Html5").registerSourceHandler(a.DashSourceHandler(),0),a.Html5DashJS=o,o});

@@ -9,3 +9,3 @@ {

},
"version": "2.10.1",
"version": "2.11.0",
"author": "Brightcove, Inc",

@@ -60,3 +60,3 @@ "license": "Apache-2.0",

"dependencies": {
"dashjs": "^2.2.0",
"dashjs": "2.9.3",
"global": "^4.3.2",

@@ -80,3 +80,3 @@ "video.js": "^5.18.0 || ^6 || ^7"

"sinon": "^6.1.5",
"videojs-generate-karma-config": "^4.0.2",
"videojs-generate-karma-config": "^5.0.1",
"videojs-generate-rollup-config": "~2.3.0",

@@ -83,0 +83,0 @@ "videojs-generator-verify": "~1.1.0",

@@ -11,2 +11,4 @@ # video.js MPEG-DASH Source Handler

__Supported Dash.js version: 2.x__
Maintenance Status: Stable

@@ -23,2 +25,3 @@

- [Captions](#captions)
- [Multi-Language Labels](#multi-language-labels)
- [Passing options to Dash.js](#passing-options-to-dashjs)

@@ -113,2 +116,6 @@ - [Deprecation Warning](#deprecation-warning)

## Multi-Language Labels
When labels in a playlist file are in multiple languages, the 2-character language code should be used if it exists; this allows the player to auto-select the appropriate label.
## Passing options to Dash.js

@@ -115,0 +122,0 @@

@@ -38,8 +38,31 @@ import dashjs from 'dashjs';

dashAudioTracks.forEach((dashTrack) => {
let label = dashTrack.lang;
let localizedLabel;
if (dashTrack.roles && dashTrack.roles.length) {
label += ` (${dashTrack.roles.join(', ')})`;
if (Array.isArray(dashTrack.labels)) {
for (let i = 0; i < dashTrack.labels.length; i++) {
if (
dashTrack.labels[i].lang &&
player.language().indexOf(dashTrack.labels[i].lang.toLowerCase()) !== -1
) {
localizedLabel = dashTrack.labels[i];
break;
}
}
}
let label;
if (localizedLabel) {
label = localizedLabel.text;
} else if (Array.isArray(dashTrack.labels) && dashTrack.labels.length === 1) {
label = dashTrack.labels[0].text;
} else {
label = dashTrack.lang;
if (dashTrack.roles && dashTrack.roles.length) {
label += ' (' + dashTrack.roles.join(', ') + ')';
}
}
// Add the track to the player's audio track list.

@@ -46,0 +69,0 @@ videojsAudioTracks.addTrack(

@@ -28,12 +28,39 @@ import dashjs from 'dashjs';

// https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement
.map((track) => ({
dashTrack: track,
trackConfig: {
label: track.lang,
language: track.lang,
srclang: track.lang,
kind: track.kind
.map((track) => {
let localizedLabel;
if (Array.isArray(track.labels)) {
for (let i = 0; i < track.labels.length; i++) {
if (
track.labels[i].lang &&
player.language().indexOf(track.labels[i].lang.toLowerCase()) !== -1
) {
localizedLabel = track.labels[i];
break;
}
}
}
}))
let label;
if (localizedLabel) {
label = localizedLabel.text;
} else if (Array.isArray(track.labels) && track.labels.length === 1) {
label = track.labels[0].text;
} else {
label = track.lang || track.label;
}
return {
dashTrack: track,
trackConfig: {
label,
language: track.lang,
srclang: track.lang,
kind: track.kind
}
};
})
// Add track to videojs track list

@@ -40,0 +67,0 @@ .map(({trackConfig, dashTrack}) => {

@@ -55,2 +55,7 @@ import window from 'global/window';

// For whatever reason, we need to call setTextDefaultEnabled(false) to get
// VTT captions to show, even though we're doing virtually the same thing
// in setup-text-tracks.js
this.mediaPlayer_.setTextDefaultEnabled(false);
// Log MedaPlayer messages through video.js

@@ -57,0 +62,0 @@ if (Html5DashJS.useVideoJSDebug) {

@@ -34,2 +34,4 @@ import videojs from 'video.js';

let setLimitBitrateByPortalValue = null;
let setTextDefaultEnabledCalled = false;
let setTextDefaultEnabledValue = null;
const el = document.createElement('div');

@@ -44,3 +46,3 @@ const fixture = document.querySelector('#qunit-fixture');

assert.expect(7);
assert.expect(9);

@@ -94,2 +96,6 @@ // Default limitBitrateByPortal to false

'MediaPlayer.setLimitBitrateByPortal was called with the correct value');
assert.strictEqual(setTextDefaultEnabledCalled, true,
'MediaPlayer.setTextDefaultEnabled was called');
assert.strictEqual(setTextDefaultEnabledValue, false,
'MediaPlayer.setTextDefaultEnabled was called with the correct value');
assert.strictEqual(startupCalled, true, 'MediaPlayer.startup was called');

@@ -126,2 +132,7 @@ assert.strictEqual(attachViewCalled, true, 'MediaPlayer.attachView was called');

});
},
setTextDefaultEnabled(value) {
setTextDefaultEnabledCalled = true;
setTextDefaultEnabledValue = value;
}

@@ -278,3 +289,3 @@

assert.expect(9);
assert.expect(11);

@@ -331,3 +342,3 @@ assert.equal(cb1Count, 2,

assert.expect(18);
assert.expect(20);

@@ -346,3 +357,3 @@ assert.equal(cb1Count, 1, 'called cb1');

assert.expect(8);
assert.expect(10);
assert.equal(eventHandlers[dashjs.MediaPlayer.events.ERROR][0],

@@ -449,3 +460,3 @@ sourceHandler.retriggerError_);

assert.expect(7 + (errors.length * 2));
assert.expect(9 + (errors.length * 2));

@@ -485,4 +496,4 @@ let i;

}, 20);
assert.expect(9);
assert.expect(11);
});

Sorry, the diff of this file is too big to display

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