videojs-contrib-dash
Advanced tools
Comparing version 2.7.1 to 2.8.0
@@ -9,2 +9,6 @@ CHANGELOG | ||
## 2.8.0 (2017-02-02) | ||
* Add support for multiple audio tracks | ||
* Introduce videojs 6 forward compatibility while maintaining backward compatibility | ||
## 2.7.1 (2017-02-02) | ||
@@ -11,0 +15,0 @@ * Allow dash config object to accept setters with multiple args |
@@ -1,2 +0,2 @@ | ||
/*! videojs-contrib-dash - v2.7.1 - 2017-02-02 | ||
/*! videojs-contrib-dash - v2.8.0 - 2017-02-06 | ||
* Copyright (c) 2017 Brightcove */ | ||
@@ -10,3 +10,95 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
}); | ||
exports.default = setupAudioTracks; | ||
var _dashjs = (typeof window !== "undefined" ? window['dashjs'] : typeof global !== "undefined" ? global['dashjs'] : null); | ||
var _dashjs2 = _interopRequireDefault(_dashjs); | ||
var _video = (typeof window !== "undefined" ? window['videojs'] : typeof global !== "undefined" ? global['videojs'] : null); | ||
var _video2 = _interopRequireDefault(_video); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* | ||
* Setup audio tracks. Take the tracks from dash and add the tracks to videojs. Listen for when | ||
* videojs changes tracks and apply that to the dash player because videojs doesn't do this | ||
* natively. | ||
* | ||
* @private | ||
* @param {videojs} player the videojs player instance | ||
* @param {videojs.tech} tech the videojs tech being used | ||
*/ | ||
function handlePlaybackMetadataLoaded(player, tech) { | ||
var mediaPlayer = player.dash.mediaPlayer; | ||
var dashAudioTracks = mediaPlayer.getTracksFor('audio'); | ||
var videojsAudioTracks = player.audioTracks(); | ||
function generateIdFromTrackIndex(index) { | ||
return 'dash-audio-' + index; | ||
} | ||
function findDashAudioTrack(dashAudioTracks, videojsAudioTrack) { | ||
return dashAudioTracks.find(function (_ref) { | ||
var index = _ref.index; | ||
return generateIdFromTrackIndex(index) === videojsAudioTrack.id; | ||
}); | ||
} | ||
// Safari creates a single native `AudioTrack` (not `videojs.AudioTrack`) when loading. Clear all | ||
// automatically generated audio tracks so we can create them all ourself. | ||
if (videojsAudioTracks.length) { | ||
tech.clearTracks(['audio']); | ||
} | ||
var currentAudioTrack = mediaPlayer.getCurrentTrackFor('audio'); | ||
dashAudioTracks.forEach(function (dashTrack) { | ||
// Add the track to the player's audio track list. | ||
videojsAudioTracks.addTrack(new _video2.default.AudioTrack({ | ||
enabled: dashTrack === currentAudioTrack, | ||
id: generateIdFromTrackIndex(dashTrack.index), | ||
kind: dashTrack.kind || 'main', | ||
label: dashTrack.lang, | ||
language: dashTrack.lang | ||
})); | ||
}); | ||
videojsAudioTracks.addEventListener('change', function () { | ||
for (var i = 0; i < videojsAudioTracks.length; i++) { | ||
var track = videojsAudioTracks[i]; | ||
if (track.enabled) { | ||
// Find the audio track we just selected by the id | ||
var dashAudioTrack = findDashAudioTrack(dashAudioTracks, track); | ||
// Set is as the current track | ||
mediaPlayer.setCurrentTrack(dashAudioTrack); | ||
// Stop looping | ||
continue; | ||
} | ||
} | ||
}); | ||
} | ||
/* | ||
* Call `handlePlaybackMetadataLoaded` when `mediaPlayer` emits | ||
* `dashjs.MediaPlayer.events.PLAYBACK_METADATA_LOADED`. | ||
*/ | ||
function setupAudioTracks(player, tech) { | ||
// When `dashjs` finishes loading metadata, create audio tracks for `video.js`. | ||
player.dash.mediaPlayer.on(_dashjs2.default.MediaPlayer.events.PLAYBACK_METADATA_LOADED, handlePlaybackMetadataLoaded.bind(null, player, tech)); | ||
} | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],2:[function(require,module,exports){ | ||
(function (global){ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -26,2 +118,6 @@ | ||
var _setupAudioTracks = require('./setup-audio-tracks'); | ||
var _setupAudioTracks2 = _interopRequireDefault(_setupAudioTracks); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -141,2 +237,5 @@ | ||
// Setup audio tracks | ||
_setupAudioTracks2.default.call(null, this.player, tech); | ||
// Attach the source with any protection data | ||
@@ -320,3 +419,3 @@ this.mediaPlayer_.setProtectionData(this.keySystemOptions_); | ||
if (!!_window2.default.MediaSource) { | ||
_video2.default.getComponent('Html5').registerSourceHandler(_video2.default.DashSourceHandler(), 0); | ||
_video2.default.getTech('Html5').registerSourceHandler(_video2.default.DashSourceHandler(), 0); | ||
} | ||
@@ -328,3 +427,3 @@ | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"global/window":2}],2:[function(require,module,exports){ | ||
},{"./setup-audio-tracks":1,"global/window":3}],3:[function(require,module,exports){ | ||
(function (global){ | ||
@@ -342,2 +441,2 @@ if (typeof window !== "undefined") { | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}]},{},[1]); | ||
},{}]},{},[2]); |
@@ -1,3 +0,3 @@ | ||
/*! videojs-contrib-dash - v2.7.1 - 2017-02-02 | ||
/*! videojs-contrib-dash - v2.8.0 - 2017-02-06 | ||
* Copyright (c) 2017 Brightcove */ | ||
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){(function(b){"use strict";function d(a){return a&&a.__esModule?a:{default:a}}function e(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}function f(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(c,"__esModule",{value:!0});var g=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),h=a("global/window"),i=d(h),j="undefined"!=typeof window?window.videojs:"undefined"!=typeof b?b.videojs:null,k=d(j),l="undefined"!=typeof window?window.dashjs:"undefined"!=typeof b?b.dashjs:null,m=d(l),n=function(a){return"[object Array]"===Object.prototype.toString.call(a)},o=function(){function a(b,c,d){var g=this;if(f(this,a),d=d||c.options_,this.player=(0,k.default)(d.playerId),this.player.dash=this.player.dash||{},this.tech_=c,this.el_=c.el(),this.elParent_=this.el_.parentNode,b.src){c.isReady_=!1,a.updateSourceData&&(k.default.log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),b=a.updateSourceData(b)),a.hooks("updatesource").forEach(function(a){b=a(b)});var h=b.src;this.keySystemOptions_=a.buildDashJSProtData(b.keySystemOptions),this.player.dash.mediaPlayer=m.default.MediaPlayer().create(),this.mediaPlayer_=this.player.dash.mediaPlayer,a.useVideoJSDebug&&(k.default.log.warn('useVideoJSDebug has been deprecated. Please switch to using hook("beforeinitialize", callback).'),a.useVideoJSDebug(this.mediaPlayer_)),a.beforeInitialize&&(k.default.log.warn('beforeInitialize has been deprecated. Please switch to using hook("beforeinitialize", callback).'),a.beforeInitialize(this.player,this.mediaPlayer_)),a.hooks("beforeinitialize").forEach(function(a){a(g.player,g.mediaPlayer_)}),this.mediaPlayer_.initialize(),d.dash&&Object.keys(d.dash).forEach(function(a){var b,c="set"+a.charAt(0).toUpperCase()+a.slice(1),f=d.dash[a];return g.mediaPlayer_.hasOwnProperty(c)&&(k.default.log.warn("Using dash options in videojs-contrib-dash without the set prefix "+("has been deprecated. Change '"+a+"' to '"+c+"'")),a=c),g.mediaPlayer_.hasOwnProperty(a)?(n(f)||(f=[f]),void(b=g.mediaPlayer_)[a].apply(b,e(f))):void k.default.log.warn("Warning: dash configuration option unrecognized: "+a)}),this.mediaPlayer_.attachView(this.el_),this.mediaPlayer_.setAutoPlay(!1),this.mediaPlayer_.setProtectionData(this.keySystemOptions_),this.mediaPlayer_.attachSource(h),this.tech_.triggerReady()}}return g(a,[{key:"dispose",value:function(){this.mediaPlayer_&&this.mediaPlayer_.reset(),this.player.dash&&delete this.player.dash}},{key:"duration",value:function a(){var a=this.el_.duration;return a===Number.MAX_VALUE?1/0:a}}],[{key:"buildDashJSProtData",value:function(a){var b={};if(!a||!n(a))return null;for(var c=0;c<a.length;c++){var d=a[c],e=k.default.mergeOptions({},d.options);e.licenseUrl&&(e.serverURL=e.licenseUrl,delete e.licenseUrl),b[d.name]=e}return b}},{key:"hooks",value:function(b,c){return a.hooks_[b]=a.hooks_[b]||[],c&&(a.hooks_[b]=a.hooks_[b].concat(c)),a.hooks_[b]}},{key:"hook",value:function(b,c){a.hooks(b,c)}},{key:"removeHook",value:function(b,c){var d=a.hooks(b).indexOf(c);return d!==-1&&(a.hooks_[b]=a.hooks_[b].slice(),a.hooks_[b].splice(d,1),!0)}}]),a}();o.hooks_={};var p=function(a){o.updateSourceData&&(a=o.updateSourceData(a));var b=document.createElement("video");return!(a.keySystemOptions&&!navigator.requestMediaKeySystemAccess&&!b.msSetMediaKeys)};k.default.DashSourceHandler=function(){return{canHandleSource:function(a){var b=/\.mpd/i;return p(a)?k.default.DashSourceHandler.canPlayType(a.type)?"probably":b.test(a.src)?"maybe":"":""},handleSource:function(a,b,c){return new o(a,b,c)},canPlayType:function(a){return k.default.DashSourceHandler.canPlayType(a)}}},k.default.DashSourceHandler.canPlayType=function(a){var b=/^application\/dash\+xml/i;return b.test(a)?"probably":""},i.default.MediaSource&&k.default.getComponent("Html5").registerSourceHandler(k.default.DashSourceHandler(),0),k.default.Html5DashJS=o,c.default=o}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"global/window":2}],2:[function(a,b,c){(function(a){"undefined"!=typeof window?b.exports=window:"undefined"!=typeof a?b.exports=a:"undefined"!=typeof self?b.exports=self:b.exports={}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]); | ||
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){(function(a){"use strict";function b(a){return a&&a.__esModule?a:{default:a}}function d(a,b){function c(a){return"dash-audio-"+a}function d(a,b){return a.find(function(a){var d=a.index;return c(d)===b.id})}var e=a.dash.mediaPlayer,f=e.getTracksFor("audio"),g=a.audioTracks();g.length&&b.clearTracks(["audio"]);var h=e.getCurrentTrackFor("audio");f.forEach(function(a){g.addTrack(new i.default.AudioTrack({enabled:a===h,id:c(a.index),kind:a.kind||"main",label:a.lang,language:a.lang}))}),g.addEventListener("change",function(){for(var a=0;a<g.length;a++){var b=g[a];if(b.enabled){var c=d(f,b);e.setCurrentTrack(c)}else;}})}function e(a,b){a.dash.mediaPlayer.on(g.default.MediaPlayer.events.PLAYBACK_METADATA_LOADED,d.bind(null,a,b))}Object.defineProperty(c,"__esModule",{value:!0}),c.default=e;var f="undefined"!=typeof window?window.dashjs:"undefined"!=typeof a?a.dashjs:null,g=b(f),h="undefined"!=typeof window?window.videojs:"undefined"!=typeof a?a.videojs:null,i=b(h)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(a,b,c){(function(b){"use strict";function d(a){return a&&a.__esModule?a:{default:a}}function e(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}function f(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(c,"__esModule",{value:!0});var g=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),h=a("global/window"),i=d(h),j="undefined"!=typeof window?window.videojs:"undefined"!=typeof b?b.videojs:null,k=d(j),l="undefined"!=typeof window?window.dashjs:"undefined"!=typeof b?b.dashjs:null,m=d(l),n=a("./setup-audio-tracks"),o=d(n),p=function(a){return"[object Array]"===Object.prototype.toString.call(a)},q=function(){function a(b,c,d){var g=this;if(f(this,a),d=d||c.options_,this.player=(0,k.default)(d.playerId),this.player.dash=this.player.dash||{},this.tech_=c,this.el_=c.el(),this.elParent_=this.el_.parentNode,b.src){c.isReady_=!1,a.updateSourceData&&(k.default.log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),b=a.updateSourceData(b)),a.hooks("updatesource").forEach(function(a){b=a(b)});var h=b.src;this.keySystemOptions_=a.buildDashJSProtData(b.keySystemOptions),this.player.dash.mediaPlayer=m.default.MediaPlayer().create(),this.mediaPlayer_=this.player.dash.mediaPlayer,a.useVideoJSDebug&&(k.default.log.warn('useVideoJSDebug has been deprecated. Please switch to using hook("beforeinitialize", callback).'),a.useVideoJSDebug(this.mediaPlayer_)),a.beforeInitialize&&(k.default.log.warn('beforeInitialize has been deprecated. Please switch to using hook("beforeinitialize", callback).'),a.beforeInitialize(this.player,this.mediaPlayer_)),a.hooks("beforeinitialize").forEach(function(a){a(g.player,g.mediaPlayer_)}),this.mediaPlayer_.initialize(),d.dash&&Object.keys(d.dash).forEach(function(a){var b,c="set"+a.charAt(0).toUpperCase()+a.slice(1),f=d.dash[a];return g.mediaPlayer_.hasOwnProperty(c)&&(k.default.log.warn("Using dash options in videojs-contrib-dash without the set prefix "+("has been deprecated. Change '"+a+"' to '"+c+"'")),a=c),g.mediaPlayer_.hasOwnProperty(a)?(p(f)||(f=[f]),void(b=g.mediaPlayer_)[a].apply(b,e(f))):void k.default.log.warn("Warning: dash configuration option unrecognized: "+a)}),this.mediaPlayer_.attachView(this.el_),this.mediaPlayer_.setAutoPlay(!1),o.default.call(null,this.player,c),this.mediaPlayer_.setProtectionData(this.keySystemOptions_),this.mediaPlayer_.attachSource(h),this.tech_.triggerReady()}}return g(a,[{key:"dispose",value:function(){this.mediaPlayer_&&this.mediaPlayer_.reset(),this.player.dash&&delete this.player.dash}},{key:"duration",value:function a(){var a=this.el_.duration;return a===Number.MAX_VALUE?1/0:a}}],[{key:"buildDashJSProtData",value:function(a){var b={};if(!a||!p(a))return null;for(var c=0;c<a.length;c++){var d=a[c],e=k.default.mergeOptions({},d.options);e.licenseUrl&&(e.serverURL=e.licenseUrl,delete e.licenseUrl),b[d.name]=e}return b}},{key:"hooks",value:function(b,c){return a.hooks_[b]=a.hooks_[b]||[],c&&(a.hooks_[b]=a.hooks_[b].concat(c)),a.hooks_[b]}},{key:"hook",value:function(b,c){a.hooks(b,c)}},{key:"removeHook",value:function(b,c){var d=a.hooks(b).indexOf(c);return d!==-1&&(a.hooks_[b]=a.hooks_[b].slice(),a.hooks_[b].splice(d,1),!0)}}]),a}();q.hooks_={};var r=function(a){q.updateSourceData&&(a=q.updateSourceData(a));var b=document.createElement("video");return!(a.keySystemOptions&&!navigator.requestMediaKeySystemAccess&&!b.msSetMediaKeys)};k.default.DashSourceHandler=function(){return{canHandleSource:function(a){var b=/\.mpd/i;return r(a)?k.default.DashSourceHandler.canPlayType(a.type)?"probably":b.test(a.src)?"maybe":"":""},handleSource:function(a,b,c){return new q(a,b,c)},canPlayType:function(a){return k.default.DashSourceHandler.canPlayType(a)}}},k.default.DashSourceHandler.canPlayType=function(a){var b=/^application\/dash\+xml/i;return b.test(a)?"probably":""},i.default.MediaSource&&k.default.getTech("Html5").registerSourceHandler(k.default.DashSourceHandler(),0),k.default.Html5DashJS=q,c.default=q}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./setup-audio-tracks":1,"global/window":3}],3:[function(a,b,c){(function(a){"undefined"!=typeof window?b.exports=window:"undefined"!=typeof a?b.exports=a:"undefined"!=typeof self?b.exports=self:b.exports={}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[2]); |
@@ -21,2 +21,6 @@ 'use strict'; | ||
var _setupAudioTracks = require('./setup-audio-tracks'); | ||
var _setupAudioTracks2 = _interopRequireDefault(_setupAudioTracks); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -136,2 +140,5 @@ | ||
// Setup audio tracks | ||
_setupAudioTracks2.default.call(null, this.player, tech); | ||
// Attach the source with any protection data | ||
@@ -315,3 +322,3 @@ this.mediaPlayer_.setProtectionData(this.keySystemOptions_); | ||
if (!!_window2.default.MediaSource) { | ||
_video2.default.getComponent('Html5').registerSourceHandler(_video2.default.DashSourceHandler(), 0); | ||
_video2.default.getTech('Html5').registerSourceHandler(_video2.default.DashSourceHandler(), 0); | ||
} | ||
@@ -318,0 +325,0 @@ |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "2.7.1", | ||
"version": "2.8.0", | ||
"author": { | ||
@@ -12,0 +12,0 @@ "name": "Brightcove" |
@@ -92,3 +92,3 @@ # video.js MPEG-DASH Source Handler | ||
dash: { | ||
setLimitBitrateByPortal: true | ||
setLimitBitrateByPortal: true, | ||
setMaxAllowedBitrateFor: ['video', 2000] | ||
@@ -95,0 +95,0 @@ } |
import window from 'global/window'; | ||
import videojs from 'video.js'; | ||
import dashjs from 'dashjs'; | ||
import setupAudioTracks from './setup-audio-tracks'; | ||
@@ -113,2 +114,5 @@ let | ||
// Setup audio tracks | ||
setupAudioTracks.call(null, this.player, tech); | ||
// Attach the source with any protection data | ||
@@ -275,3 +279,3 @@ this.mediaPlayer_.setProtectionData(this.keySystemOptions_); | ||
if (!!window.MediaSource) { | ||
videojs.getComponent('Html5').registerSourceHandler(videojs.DashSourceHandler(), 0); | ||
videojs.getTech('Html5').registerSourceHandler(videojs.DashSourceHandler(), 0); | ||
} | ||
@@ -278,0 +282,0 @@ |
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
66836
16
1056