videojs-contrib-dash
Advanced tools
Comparing version 2.9.0 to 2.9.1
@@ -8,2 +8,5 @@ CHANGELOG | ||
-------------------- | ||
## 2.9.1 (2017-06-15) | ||
* Fix text tracks in IE | ||
## 2.9.0 (2017-05-11) | ||
@@ -10,0 +13,0 @@ * Load text tracks from dashjs into video.js |
@@ -1,11 +0,13 @@ | ||
/*! videojs-contrib-dash - v2.9.0 - 2017-05-11 | ||
* Copyright (c) 2017 Brightcove */ | ||
(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){ | ||
/** | ||
* videojs-contrib-dash | ||
* @version 2.9.1 | ||
* @copyright 2017 Brightcove, Inc | ||
* @license Apache-2.0 | ||
*/ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.videojsDash = f()}})(function(){var define,module,exports;return (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){ | ||
(function (global){ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = setupAudioTracks; | ||
exports.__esModule = true; | ||
exports['default'] = setupAudioTracks; | ||
@@ -20,5 +22,5 @@ var _dashjs = (typeof window !== "undefined" ? window['dashjs'] : typeof global !== "undefined" ? global['dashjs'] : null); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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 | ||
@@ -65,3 +67,3 @@ * videojs changes tracks and apply that to the dash player because videojs doesn't do this | ||
// Add the track to the player's audio track list. | ||
videojsAudioTracks.addTrack(new _video2.default.AudioTrack({ | ||
videojsAudioTracks.addTrack(new _video2['default'].AudioTrack({ | ||
enabled: dashTrack === currentAudioTrack, | ||
@@ -99,5 +101,4 @@ id: generateIdFromTrackIndex(dashTrack.index), | ||
// 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)); | ||
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 : {}) | ||
@@ -108,6 +109,4 @@ },{}],2:[function(require,module,exports){ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = setupTextTracks; | ||
exports.__esModule = true; | ||
exports['default'] = setupTextTracks; | ||
@@ -122,4 +121,12 @@ var _dashjs = (typeof window !== "undefined" ? window['dashjs'] : typeof global !== "undefined" ? global['dashjs'] : null); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function find(l, f) { | ||
for (var i = 0; i < l.length; i++) { | ||
if (f(l[i])) { | ||
return l[i]; | ||
} | ||
} | ||
} | ||
/* | ||
@@ -144,4 +151,2 @@ * Attach text tracks from dash.js to videojs | ||
trackConfig: { | ||
default: track.defaultTrack, | ||
kind: track.kind, | ||
label: track.lang, | ||
@@ -152,6 +157,6 @@ language: track.lang, | ||
}; | ||
}) | ||
} | ||
// Add track to videojs track list | ||
.map(function (_ref) { | ||
).map(function (_ref) { | ||
var trackConfig = _ref.trackConfig, | ||
@@ -189,10 +194,7 @@ dashTrack = _ref.dashTrack; | ||
var dictionaryLookupResult = trackDictionary.find( | ||
/* jshint loopfunc: true */ | ||
function (_ref2) { | ||
var dictionaryTextTrack = _ref2.textTrack; | ||
return dictionaryTextTrack === textTrack; | ||
} | ||
var dictionaryLookupResult = find(trackDictionary, function (track) { | ||
return track.textTrack === textTrack; | ||
}); | ||
/* jshint loopfunc: false */ | ||
); | ||
@@ -226,19 +228,2 @@ var dashTrackToActivate = dictionaryLookupResult ? dictionaryLookupResult.dashTrack : null; | ||
/* | ||
* Now that all the text tracks are created, iterate through them and set the default to | ||
* `showing`. Note that more than one track can be listed as a default because this will create | ||
* subtitles and captions which can independently have their own defaults. This will ignore all | ||
* tracks that are not `subtitles` or `captions`, otherwise we'll be showing text data for | ||
* `metadata` and `descriptions` tracks. | ||
*/ | ||
var textTracks = player.textTracks(); | ||
for (var i = 0; i < textTracks.length; i += 1) { | ||
var _textTrack = textTracks[i]; | ||
if (_textTrack.kind === 'subtitles' || _textTrack.kind === 'captions') { | ||
_textTrack.mode = _textTrack.default ? 'showing' : 'hidden'; | ||
} | ||
} | ||
// Initialize the text track on our first run-through | ||
@@ -258,2 +243,9 @@ updateActiveDashTextTrack(); | ||
function setupTextTracks(player, tech, options) { | ||
// Clear VTTCue if it was shimmed by vttjs and let dash.js use TextTrackCue. | ||
// This is necessary because dash.js creates text tracks | ||
// using addTextTrack which is incompatible with vttjs.VTTCue in IE11 | ||
if (window.VTTCue && !/\[native code\]/.test(window.VTTCue.toString())) { | ||
window.VTTCue = false; | ||
} | ||
// Store the tracks that we've added so we can remove them later. | ||
@@ -264,3 +256,3 @@ var dashTracksAttachedToVideoJs = []; | ||
if (tech.featuresNativeTextTracks) { | ||
_video2.default.log.error('You must pass {html: {nativeCaptions: false}} in the videojs constructor ' + 'to use text tracks in videojs-contrib-dash'); | ||
_video2['default'].log.error('You must pass {html: {nativeCaptions: false}} in the videojs constructor ' + 'to use text tracks in videojs-contrib-dash'); | ||
return; | ||
@@ -278,8 +270,8 @@ } | ||
function handleTextTracksAdded(_ref3) { | ||
var index = _ref3.index, | ||
tracks = _ref3.tracks; | ||
function handleTextTracksAdded(_ref2) { | ||
var index = _ref2.index, | ||
tracks = _ref2.tracks; | ||
// Stop listening for this event. We only want to hear it once. | ||
mediaPlayer.off(_dashjs2.default.MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
mediaPlayer.off(_dashjs2['default'].MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
@@ -299,6 +291,6 @@ // Cleanup old tracks | ||
// Attach dash text tracks whenever we dash emits `TEXT_TRACKS_ADDED`. | ||
mediaPlayer.on(_dashjs2.default.MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
mediaPlayer.on(_dashjs2['default'].MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
function cleanup() { | ||
mediaPlayer.off(_dashjs2.default.MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
mediaPlayer.off(_dashjs2['default'].MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
@@ -312,16 +304,28 @@ player.one('loadstart', clearDashTracks); | ||
// mediaPlayers. | ||
mediaPlayer.on(_dashjs2.default.MediaPlayer.events.CAN_PLAY, cleanup); | ||
mediaPlayer.on(_dashjs2['default'].MediaPlayer.events.CAN_PLAY, cleanup); | ||
} | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],3:[function(require,module,exports){ | ||
(function (global){ | ||
var win; | ||
if (typeof window !== "undefined") { | ||
win = window; | ||
} else if (typeof global !== "undefined") { | ||
win = global; | ||
} else if (typeof self !== "undefined"){ | ||
win = self; | ||
} else { | ||
win = {}; | ||
} | ||
module.exports = win; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],4:[function(require,module,exports){ | ||
(function (global){ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.__esModule = 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; }; }(); | ||
var _window = require('global/window'); | ||
@@ -347,12 +351,6 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var isArray = function isArray(a) { | ||
return Object.prototype.toString.call(a) === '[object Array]'; | ||
}; | ||
/** | ||
@@ -363,3 +361,2 @@ * videojs-contrib-dash | ||
*/ | ||
var Html5DashJS = function () { | ||
@@ -374,3 +371,3 @@ function Html5DashJS(source, tech, options) { | ||
this.player = (0, _video2.default)(options.playerId); | ||
this.player = (0, _video2['default'])(options.playerId); | ||
this.player.dash = this.player.dash || {}; | ||
@@ -393,3 +390,3 @@ | ||
if (Html5DashJS.updateSourceData) { | ||
_video2.default.log.warn('updateSourceData has been deprecated.' + ' Please switch to using hook("updatesource", callback).'); | ||
_video2['default'].log.warn('updateSourceData has been deprecated.' + ' Please switch to using hook("updatesource", callback).'); | ||
source = Html5DashJS.updateSourceData(source); | ||
@@ -406,3 +403,3 @@ } | ||
this.player.dash.mediaPlayer = _dashjs2.default.MediaPlayer().create(); | ||
this.player.dash.mediaPlayer = _dashjs2['default'].MediaPlayer().create(); | ||
@@ -413,3 +410,3 @@ this.mediaPlayer_ = this.player.dash.mediaPlayer; | ||
if (Html5DashJS.useVideoJSDebug) { | ||
_video2.default.log.warn('useVideoJSDebug has been deprecated.' + ' Please switch to using hook("beforeinitialize", callback).'); | ||
_video2['default'].log.warn('useVideoJSDebug has been deprecated.' + ' Please switch to using hook("beforeinitialize", callback).'); | ||
Html5DashJS.useVideoJSDebug(this.mediaPlayer_); | ||
@@ -419,3 +416,3 @@ } | ||
if (Html5DashJS.beforeInitialize) { | ||
_video2.default.log.warn('beforeInitialize has been deprecated.' + ' Please switch to using hook("beforeinitialize", callback).'); | ||
_video2['default'].log.warn('beforeInitialize has been deprecated.' + ' Please switch to using hook("beforeinitialize", callback).'); | ||
Html5DashJS.beforeInitialize(this.player, this.mediaPlayer_); | ||
@@ -442,3 +439,3 @@ } | ||
// Providing a key without `set` prefix is now deprecated. | ||
_video2.default.log.warn('Using dash options in videojs-contrib-dash without the set prefix ' + ('has been deprecated. Change \'' + key + '\' to \'' + dashOptionsKey + '\'')); | ||
_video2['default'].log.warn('Using dash options in videojs-contrib-dash without the set prefix ' + ('has been deprecated. Change \'' + key + '\' to \'' + dashOptionsKey + '\'')); | ||
@@ -450,3 +447,3 @@ // Set key so it will still work | ||
if (!_this.mediaPlayer_.hasOwnProperty(key)) { | ||
_video2.default.log.warn('Warning: dash configuration option unrecognized: ' + key); | ||
_video2['default'].log.warn('Warning: dash configuration option unrecognized: ' + key); | ||
@@ -457,7 +454,7 @@ return; | ||
// Guarantee `value` is an array | ||
if (!isArray(value)) { | ||
if (!Array.isArray(value)) { | ||
value = [value]; | ||
} | ||
(_mediaPlayer_ = _this.mediaPlayer_)[key].apply(_mediaPlayer_, _toConsumableArray(value)); | ||
(_mediaPlayer_ = _this.mediaPlayer_)[key].apply(_mediaPlayer_, value); | ||
}); | ||
@@ -472,6 +469,6 @@ } | ||
// Setup audio tracks | ||
_setupAudioTracks2.default.call(null, this.player, tech); | ||
_setupAudioTracks2['default'].call(null, this.player, tech); | ||
// Setup text tracks | ||
_setupTextTracks2.default.call(null, this.player, tech, options); | ||
_setupTextTracks2['default'].call(null, this.player, tech, options); | ||
@@ -493,106 +490,98 @@ // Attach the source with any protection data | ||
_createClass(Html5DashJS, [{ | ||
key: 'dispose', | ||
value: function dispose() { | ||
if (this.mediaPlayer_) { | ||
this.mediaPlayer_.reset(); | ||
} | ||
Html5DashJS.buildDashJSProtData = function buildDashJSProtData(keySystemOptions) { | ||
var output = {}; | ||
if (this.player.dash) { | ||
delete this.player.dash; | ||
} | ||
if (!keySystemOptions || !Array.isArray(keySystemOptions)) { | ||
return null; | ||
} | ||
}, { | ||
key: 'duration', | ||
value: function duration() { | ||
var duration = this.el_.duration; | ||
if (duration === Number.MAX_VALUE) { | ||
return Infinity; | ||
for (var i = 0; i < keySystemOptions.length; i++) { | ||
var keySystem = keySystemOptions[i]; | ||
var options = _video2['default'].mergeOptions({}, keySystem.options); | ||
if (options.licenseUrl) { | ||
options.serverURL = options.licenseUrl; | ||
delete options.licenseUrl; | ||
} | ||
return duration; | ||
output[keySystem.name] = options; | ||
} | ||
/** | ||
* Get a list of hooks for a specific lifecycle | ||
* | ||
* @param {string} type the lifecycle to get hooks from | ||
* @param {Function=|Function[]=} hook Optionally add a hook tothe lifecycle | ||
* @return {Array} an array of hooks or epty if none | ||
* @method hooks | ||
*/ | ||
return output; | ||
}; | ||
}], [{ | ||
key: 'buildDashJSProtData', | ||
value: function buildDashJSProtData(keySystemOptions) { | ||
var output = {}; | ||
Html5DashJS.prototype.dispose = function dispose() { | ||
if (this.mediaPlayer_) { | ||
this.mediaPlayer_.reset(); | ||
} | ||
if (!keySystemOptions || !isArray(keySystemOptions)) { | ||
return null; | ||
} | ||
if (this.player.dash) { | ||
delete this.player.dash; | ||
} | ||
}; | ||
for (var i = 0; i < keySystemOptions.length; i++) { | ||
var keySystem = keySystemOptions[i]; | ||
var options = _video2.default.mergeOptions({}, keySystem.options); | ||
Html5DashJS.prototype.duration = function duration() { | ||
var duration = this.el_.duration; | ||
if (duration === Number.MAX_VALUE) { | ||
return Infinity; | ||
} | ||
return duration; | ||
}; | ||
if (options.licenseUrl) { | ||
options.serverURL = options.licenseUrl; | ||
delete options.licenseUrl; | ||
} | ||
/** | ||
* Get a list of hooks for a specific lifecycle | ||
* | ||
* @param {string} type the lifecycle to get hooks from | ||
* @param {Function=|Function[]=} hook Optionally add a hook tothe lifecycle | ||
* @return {Array} an array of hooks or epty if none | ||
* @method hooks | ||
*/ | ||
output[keySystem.name] = options; | ||
} | ||
return output; | ||
Html5DashJS.hooks = function hooks(type, hook) { | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type] || []; | ||
if (hook) { | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type].concat(hook); | ||
} | ||
}, { | ||
key: 'hooks', | ||
value: function hooks(type, hook) { | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type] || []; | ||
if (hook) { | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type].concat(hook); | ||
} | ||
return Html5DashJS.hooks_[type]; | ||
}; | ||
return Html5DashJS.hooks_[type]; | ||
} | ||
/** | ||
* Add a function hook to a specific dash lifecycle | ||
* | ||
* @param {string} type the lifecycle to hook the function to | ||
* @param {Function|Function[]} hook the function or array of functions to attach | ||
* @method hook | ||
*/ | ||
/** | ||
* Add a function hook to a specific dash lifecycle | ||
* | ||
* @param {string} type the lifecycle to hook the function to | ||
* @param {Function|Function[]} hook the function or array of functions to attach | ||
* @method hook | ||
*/ | ||
}, { | ||
key: 'hook', | ||
value: function hook(type, _hook) { | ||
Html5DashJS.hooks(type, _hook); | ||
} | ||
Html5DashJS.hook = function hook(type, _hook) { | ||
Html5DashJS.hooks(type, _hook); | ||
}; | ||
/** | ||
* Remove a hook from a specific dash lifecycle. | ||
* | ||
* @param {string} type the lifecycle that the function hooked to | ||
* @param {Function} hook The hooked function to remove | ||
* @return {boolean} True if the function was removed, false if not found | ||
* @method removeHook | ||
*/ | ||
/** | ||
* Remove a hook from a specific dash lifecycle. | ||
* | ||
* @param {string} type the lifecycle that the function hooked to | ||
* @param {Function} hook The hooked function to remove | ||
* @return {boolean} True if the function was removed, false if not found | ||
* @method removeHook | ||
*/ | ||
}, { | ||
key: 'removeHook', | ||
value: function removeHook(type, hook) { | ||
var index = Html5DashJS.hooks(type).indexOf(hook); | ||
if (index === -1) { | ||
return false; | ||
} | ||
Html5DashJS.removeHook = function removeHook(type, hook) { | ||
var index = Html5DashJS.hooks(type).indexOf(hook); | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type].slice(); | ||
Html5DashJS.hooks_[type].splice(index, 1); | ||
return true; | ||
if (index === -1) { | ||
return false; | ||
} | ||
}]); | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type].slice(); | ||
Html5DashJS.hooks_[type].splice(index, 1); | ||
return true; | ||
}; | ||
return Html5DashJS; | ||
@@ -608,3 +597,3 @@ }(); | ||
if (Html5DashJS.updateSourceData) { | ||
_video2.default.log.warn('updateSourceData has been deprecated.' + ' Please switch to using hook("updatesource", callback).'); | ||
_video2['default'].log.warn('updateSourceData has been deprecated.' + ' Please switch to using hook("updatesource", callback).'); | ||
source = Html5DashJS.updateSourceData(source); | ||
@@ -628,3 +617,3 @@ } | ||
_video2.default.DashSourceHandler = function () { | ||
_video2['default'].DashSourceHandler = function () { | ||
return { | ||
@@ -638,3 +627,3 @@ canHandleSource: function canHandleSource(source) { | ||
if (_video2.default.DashSourceHandler.canPlayType(source.type)) { | ||
if (_video2['default'].DashSourceHandler.canPlayType(source.type)) { | ||
return 'probably'; | ||
@@ -653,3 +642,3 @@ } else if (dashExtRE.test(source.src)) { | ||
canPlayType: function canPlayType(type) { | ||
return _video2.default.DashSourceHandler.canPlayType(type); | ||
return _video2['default'].DashSourceHandler.canPlayType(type); | ||
} | ||
@@ -659,3 +648,3 @@ }; | ||
_video2.default.DashSourceHandler.canPlayType = function (type) { | ||
_video2['default'].DashSourceHandler.canPlayType = function (type) { | ||
var dashTypeRE = /^application\/dash\+xml/i; | ||
@@ -670,27 +659,10 @@ if (dashTypeRE.test(type)) { | ||
// Only add the SourceHandler if the browser supports MediaSourceExtensions | ||
if (!!_window2.default.MediaSource) { | ||
_video2.default.getTech('Html5').registerSourceHandler(_video2.default.DashSourceHandler(), 0); | ||
if (!!_window2['default'].MediaSource) { | ||
_video2['default'].getTech('Html5').registerSourceHandler(_video2['default'].DashSourceHandler(), 0); | ||
} | ||
_video2.default.Html5DashJS = Html5DashJS; | ||
exports.default = Html5DashJS; | ||
_video2['default'].Html5DashJS = Html5DashJS; | ||
exports['default'] = Html5DashJS; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"./setup-audio-tracks":1,"./setup-text-tracks":2,"global/window":4}],4:[function(require,module,exports){ | ||
(function (global){ | ||
var win; | ||
if (typeof window !== "undefined") { | ||
win = window; | ||
} else if (typeof global !== "undefined") { | ||
win = global; | ||
} else if (typeof self !== "undefined"){ | ||
win = self; | ||
} else { | ||
win = {}; | ||
} | ||
module.exports = win; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}]},{},[3]); | ||
},{"./setup-audio-tracks":1,"./setup-text-tracks":2,"global/window":3}]},{},[4])(4) | ||
}); |
@@ -1,3 +0,7 @@ | ||
/*! videojs-contrib-dash - v2.9.0 - 2017-05-11 | ||
* 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(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){var b=a.lang;a.roles&&a.roles.length&&(b+=" ("+a.roles.join(", ")+")"),g.addTrack(new i.default.AudioTrack({enabled:a===h,id:c(a.index),kind:a.kind||"main",label:b,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(a){"use strict";function b(a){return a&&a.__esModule?a:{default:a}}function d(a,b,c){function d(){for(var b=a.dash.mediaPlayer,d=a.textTracks(),f=-1,g=function(a){var b=d[a];if("showing"===b.mode){var g=e.find(function(a){var c=a.textTrack;return c===b}),h=g?g.dashTrack:null;h&&(f=c.indexOf(h))}},h=0;h<d.length;h+=1)g(h);f!==b.getCurrentTextTrackIndex()&&b.setTextTrack(f)}var e=[],f=c.map(function(a){return{dashTrack:a,trackConfig:{default:a.defaultTrack,kind:a.kind,label:a.lang,language:a.lang,srclang:a.lang}}}).map(function(b){var c=b.trackConfig,d=b.dashTrack,f=a.addRemoteTextTrack(c,!0);return e.push({textTrack:f.track,dashTrack:d}),f});a.textTracks().on("change",d),a.one("loadstart",function(){a.textTracks().off("change",d)});for(var g=a.textTracks(),h=0;h<g.length;h+=1){var i=g[h];"subtitles"!==i.kind&&"captions"!==i.kind||(i.mode=i.default?"showing":"hidden")}return d(),f}function e(a,b,c){function e(){j.forEach(a.removeRemoteTextTrack.bind(a)),j=[]}function f(h){var i=(h.index,h.tracks);k.off(g.default.MediaPlayer.events.TEXT_TRACKS_ADDED,f),e(),i.length&&(j=d(a,b,i,c))}function h(){k.off(g.default.MediaPlayer.events.TEXT_TRACKS_ADDED,f),a.one("loadstart",e)}var j=[];if(b.featuresNativeTextTracks)return void i.default.log.error("You must pass {html: {nativeCaptions: false}} in the videojs constructor to use text tracks in videojs-contrib-dash");var k=a.dash.mediaPlayer;k.on(g.default.MediaPlayer.events.TEXT_TRACKS_ADDED,f),k.on(g.default.MediaPlayer.events.CAN_PLAY,h)}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:{})},{}],3:[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=a("./setup-text-tracks"),q=d(p),r=function(a){return"[object Array]"===Object.prototype.toString.call(a)},s=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)?(r(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),q.default.call(null,this.player,c,d),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||!r(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}();s.hooks_={};var t=function(a){a=JSON.parse(JSON.stringify(a)),s.updateSourceData&&(k.default.log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),a=s.updateSourceData(a)),s.hooks("updatesource").forEach(function(b){a=b(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 t(a)?k.default.DashSourceHandler.canPlayType(a.type)?"probably":b.test(a.src)?"maybe":"":""},handleSource:function(a,b,c){return new s(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=s,c.default=s}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./setup-audio-tracks":1,"./setup-text-tracks":2,"global/window":4}],4:[function(a,b,c){(function(a){var c;c="undefined"!=typeof window?window:"undefined"!=typeof a?a:"undefined"!=typeof self?self:{},b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[3]); | ||
/** | ||
* videojs-contrib-dash | ||
* @version 2.9.1 | ||
* @copyright 2017 Brightcove, Inc | ||
* @license Apache-2.0 | ||
*/ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var a;a="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,a.videojsDash=e()}}(function(){return function e(a,t,n){function o(r,d){if(!t[r]){if(!a[r]){var s="function"==typeof require&&require;if(!d&&s)return s(r,!0);if(i)return i(r,!0);var l=new Error("Cannot find module '"+r+"'");throw l.code="MODULE_NOT_FOUND",l}var u=t[r]={exports:{}};a[r][0].call(u.exports,function(e){var t=a[r][1][e];return o(t||e)},u,u.exports,e,a,t,n)}return t[r].exports}for(var i="function"==typeof require&&require,r=0;r<n.length;r++)o(n[r]);return o}({1:[function(e,a,t){(function(e){"use strict";function a(e){return e&&e.__esModule?e:{"default":e}}function n(e,a){function t(e){return"dash-audio-"+e}function n(e,a){return e.find(function(e){return t(e.index)===a.id})}var o=e.dash.mediaPlayer,i=o.getTracksFor("audio"),r=e.audioTracks();r.length&&a.clearTracks(["audio"]);var d=o.getCurrentTrackFor("audio");i.forEach(function(e){var a=e.lang;e.roles&&e.roles.length&&(a+=" ("+e.roles.join(", ")+")"),r.addTrack(new s["default"].AudioTrack({enabled:e===d,id:t(e.index),kind:e.kind||"main",label:a,language:e.lang}))}),r.addEventListener("change",function(){for(var e=0;e<r.length;e++){var a=r[e];if(a.enabled){var t=n(i,a);o.setCurrentTrack(t)}else;}})}function o(e,a){e.dash.mediaPlayer.on(r["default"].MediaPlayer.events.PLAYBACK_METADATA_LOADED,n.bind(null,e,a))}t.__esModule=!0,t["default"]=o;var i="undefined"!=typeof window?window.dashjs:void 0!==e?e.dashjs:null,r=a(i),d="undefined"!=typeof window?window.videojs:void 0!==e?e.videojs:null,s=a(d)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,a,t){(function(e){"use strict";function a(e){return e&&e.__esModule?e:{"default":e}}function n(e,a){for(var t=0;t<e.length;t++)if(a(e[t]))return e[t]}function o(e,a,t){function o(){for(var a=e.dash.mediaPlayer,o=e.textTracks(),r=-1,d=0;d<o.length;d+=1)!function(e){var a=o[e];if("showing"===a.mode){var d=n(i,function(e){return e.textTrack===a}),s=d?d.dashTrack:null;s&&(r=t.indexOf(s))}}(d);r!==a.getCurrentTextTrackIndex()&&a.setTextTrack(r)}var i=[],r=t.map(function(e){return{dashTrack:e,trackConfig:{label:e.lang,language:e.lang,srclang:e.lang}}}).map(function(a){var t=a.trackConfig,n=a.dashTrack,o=e.addRemoteTextTrack(t,!0);return i.push({textTrack:o.track,dashTrack:n}),o});return e.textTracks().on("change",o),e.one("loadstart",function(){e.textTracks().off("change",o)}),o(),r}function i(e,a,t){function n(){s.forEach(e.removeRemoteTextTrack.bind(e)),s=[]}function i(r){var l=(r.index,r.tracks);u.off(d["default"].MediaPlayer.events.TEXT_TRACKS_ADDED,i),n(),l.length&&(s=o(e,a,l,t))}function r(){u.off(d["default"].MediaPlayer.events.TEXT_TRACKS_ADDED,i),e.one("loadstart",n)}window.VTTCue&&!/\[native code\]/.test(window.VTTCue.toString())&&(window.VTTCue=!1);var s=[];if(a.featuresNativeTextTracks)return void l["default"].log.error("You must pass {html: {nativeCaptions: false}} in the videojs constructor to use text tracks in videojs-contrib-dash");var u=e.dash.mediaPlayer;u.on(d["default"].MediaPlayer.events.TEXT_TRACKS_ADDED,i),u.on(d["default"].MediaPlayer.events.CAN_PLAY,r)}t.__esModule=!0,t["default"]=i;var r="undefined"!=typeof window?window.dashjs:void 0!==e?e.dashjs:null,d=a(r),s="undefined"!=typeof window?window.videojs:void 0!==e?e.videojs:null,l=a(s)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,a,t){(function(e){var t;t="undefined"!=typeof window?window:void 0!==e?e:"undefined"!=typeof self?self:{},a.exports=t}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,a,t){(function(a){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,a){if(!(e instanceof a))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=e("global/window"),r=n(i),d="undefined"!=typeof window?window.videojs:void 0!==a?a.videojs:null,s=n(d),l="undefined"!=typeof window?window.dashjs:void 0!==a?a.dashjs:null,u=n(l),f=e("./setup-audio-tracks"),c=n(f),h=e("./setup-text-tracks"),p=n(h),y=function(){function e(a,t,n){var i=this;if(o(this,e),n=n||t.options_,this.player=(0,s["default"])(n.playerId),this.player.dash=this.player.dash||{},this.tech_=t,this.el_=t.el(),this.elParent_=this.el_.parentNode,a.src){t.isReady_=!1,e.updateSourceData&&(s["default"].log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),a=e.updateSourceData(a)),e.hooks("updatesource").forEach(function(e){a=e(a)});var r=a.src;this.keySystemOptions_=e.buildDashJSProtData(a.keySystemOptions),this.player.dash.mediaPlayer=u["default"].MediaPlayer().create(),this.mediaPlayer_=this.player.dash.mediaPlayer,e.useVideoJSDebug&&(s["default"].log.warn('useVideoJSDebug has been deprecated. Please switch to using hook("beforeinitialize", callback).'),e.useVideoJSDebug(this.mediaPlayer_)),e.beforeInitialize&&(s["default"].log.warn('beforeInitialize has been deprecated. Please switch to using hook("beforeinitialize", callback).'),e.beforeInitialize(this.player,this.mediaPlayer_)),e.hooks("beforeinitialize").forEach(function(e){e(i.player,i.mediaPlayer_)}),this.mediaPlayer_.initialize(),n.dash&&Object.keys(n.dash).forEach(function(e){var a,t="set"+e.charAt(0).toUpperCase()+e.slice(1),o=n.dash[e];if(i.mediaPlayer_.hasOwnProperty(t)&&(s["default"].log.warn("Using dash options in videojs-contrib-dash without the set prefix has been deprecated. Change '"+e+"' to '"+t+"'"),e=t),!i.mediaPlayer_.hasOwnProperty(e))return void s["default"].log.warn("Warning: dash configuration option unrecognized: "+e);Array.isArray(o)||(o=[o]),(a=i.mediaPlayer_)[e].apply(a,o)}),this.mediaPlayer_.attachView(this.el_),this.mediaPlayer_.setAutoPlay(!1),c["default"].call(null,this.player,t),p["default"].call(null,this.player,t,n),this.mediaPlayer_.setProtectionData(this.keySystemOptions_),this.mediaPlayer_.attachSource(r),this.tech_.triggerReady()}}return e.buildDashJSProtData=function(e){var a={};if(!e||!Array.isArray(e))return null;for(var t=0;t<e.length;t++){var n=e[t],o=s["default"].mergeOptions({},n.options);o.licenseUrl&&(o.serverURL=o.licenseUrl,delete o.licenseUrl),a[n.name]=o}return a},e.prototype.dispose=function(){this.mediaPlayer_&&this.mediaPlayer_.reset(),this.player.dash&&delete this.player.dash},e.prototype.duration=function(){var e=this.el_.duration;return e===Number.MAX_VALUE?Infinity:e},e.hooks=function(a,t){return e.hooks_[a]=e.hooks_[a]||[],t&&(e.hooks_[a]=e.hooks_[a].concat(t)),e.hooks_[a]},e.hook=function(a,t){e.hooks(a,t)},e.removeHook=function(a,t){var n=e.hooks(a).indexOf(t);return-1!==n&&(e.hooks_[a]=e.hooks_[a].slice(),e.hooks_[a].splice(n,1),!0)},e}();y.hooks_={};var w=function(e){e=JSON.parse(JSON.stringify(e)),y.updateSourceData&&(s["default"].log.warn('updateSourceData has been deprecated. Please switch to using hook("updatesource", callback).'),e=y.updateSourceData(e)),y.hooks("updatesource").forEach(function(a){e=a(e)});var a=document.createElement("video");return!(e.keySystemOptions&&!navigator.requestMediaKeySystemAccess&&!a.msSetMediaKeys)};s["default"].DashSourceHandler=function(){return{canHandleSource:function(e){var a=/\.mpd/i;return w(e)?s["default"].DashSourceHandler.canPlayType(e.type)?"probably":a.test(e.src)?"maybe":"":""},handleSource:function(e,a,t){return new y(e,a,t)},canPlayType:function(e){return s["default"].DashSourceHandler.canPlayType(e)}}},s["default"].DashSourceHandler.canPlayType=function(e){return/^application\/dash\+xml/i.test(e)?"probably":""},r["default"].MediaSource&&s["default"].getTech("Html5").registerSourceHandler(s["default"].DashSourceHandler(),0),s["default"].Html5DashJS=y,t["default"]=y}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./setup-audio-tracks":1,"./setup-text-tracks":2,"global/window":3}]},{},[4])(4)}); |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = setupAudioTracks; | ||
exports.__esModule = true; | ||
exports['default'] = setupAudioTracks; | ||
@@ -16,5 +14,5 @@ var _dashjs = require('dashjs'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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 | ||
@@ -61,3 +59,3 @@ * videojs changes tracks and apply that to the dash player because videojs doesn't do this | ||
// Add the track to the player's audio track list. | ||
videojsAudioTracks.addTrack(new _video2.default.AudioTrack({ | ||
videojsAudioTracks.addTrack(new _video2['default'].AudioTrack({ | ||
enabled: dashTrack === currentAudioTrack, | ||
@@ -95,3 +93,3 @@ id: generateIdFromTrackIndex(dashTrack.index), | ||
// 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)); | ||
} | ||
player.dash.mediaPlayer.on(_dashjs2['default'].MediaPlayer.events.PLAYBACK_METADATA_LOADED, handlePlaybackMetadataLoaded.bind(null, player, tech)); | ||
} |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = setupTextTracks; | ||
exports.__esModule = true; | ||
exports['default'] = setupTextTracks; | ||
@@ -16,4 +14,12 @@ var _dashjs = require('dashjs'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function find(l, f) { | ||
for (var i = 0; i < l.length; i++) { | ||
if (f(l[i])) { | ||
return l[i]; | ||
} | ||
} | ||
} | ||
/* | ||
@@ -38,4 +44,2 @@ * Attach text tracks from dash.js to videojs | ||
trackConfig: { | ||
default: track.defaultTrack, | ||
kind: track.kind, | ||
label: track.lang, | ||
@@ -46,6 +50,6 @@ language: track.lang, | ||
}; | ||
}) | ||
} | ||
// Add track to videojs track list | ||
.map(function (_ref) { | ||
).map(function (_ref) { | ||
var trackConfig = _ref.trackConfig, | ||
@@ -83,10 +87,7 @@ dashTrack = _ref.dashTrack; | ||
var dictionaryLookupResult = trackDictionary.find( | ||
/* jshint loopfunc: true */ | ||
function (_ref2) { | ||
var dictionaryTextTrack = _ref2.textTrack; | ||
return dictionaryTextTrack === textTrack; | ||
} | ||
var dictionaryLookupResult = find(trackDictionary, function (track) { | ||
return track.textTrack === textTrack; | ||
}); | ||
/* jshint loopfunc: false */ | ||
); | ||
@@ -120,19 +121,2 @@ var dashTrackToActivate = dictionaryLookupResult ? dictionaryLookupResult.dashTrack : null; | ||
/* | ||
* Now that all the text tracks are created, iterate through them and set the default to | ||
* `showing`. Note that more than one track can be listed as a default because this will create | ||
* subtitles and captions which can independently have their own defaults. This will ignore all | ||
* tracks that are not `subtitles` or `captions`, otherwise we'll be showing text data for | ||
* `metadata` and `descriptions` tracks. | ||
*/ | ||
var textTracks = player.textTracks(); | ||
for (var i = 0; i < textTracks.length; i += 1) { | ||
var _textTrack = textTracks[i]; | ||
if (_textTrack.kind === 'subtitles' || _textTrack.kind === 'captions') { | ||
_textTrack.mode = _textTrack.default ? 'showing' : 'hidden'; | ||
} | ||
} | ||
// Initialize the text track on our first run-through | ||
@@ -152,2 +136,9 @@ updateActiveDashTextTrack(); | ||
function setupTextTracks(player, tech, options) { | ||
// Clear VTTCue if it was shimmed by vttjs and let dash.js use TextTrackCue. | ||
// This is necessary because dash.js creates text tracks | ||
// using addTextTrack which is incompatible with vttjs.VTTCue in IE11 | ||
if (window.VTTCue && !/\[native code\]/.test(window.VTTCue.toString())) { | ||
window.VTTCue = false; | ||
} | ||
// Store the tracks that we've added so we can remove them later. | ||
@@ -158,3 +149,3 @@ var dashTracksAttachedToVideoJs = []; | ||
if (tech.featuresNativeTextTracks) { | ||
_video2.default.log.error('You must pass {html: {nativeCaptions: false}} in the videojs constructor ' + 'to use text tracks in videojs-contrib-dash'); | ||
_video2['default'].log.error('You must pass {html: {nativeCaptions: false}} in the videojs constructor ' + 'to use text tracks in videojs-contrib-dash'); | ||
return; | ||
@@ -172,8 +163,8 @@ } | ||
function handleTextTracksAdded(_ref3) { | ||
var index = _ref3.index, | ||
tracks = _ref3.tracks; | ||
function handleTextTracksAdded(_ref2) { | ||
var index = _ref2.index, | ||
tracks = _ref2.tracks; | ||
// Stop listening for this event. We only want to hear it once. | ||
mediaPlayer.off(_dashjs2.default.MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
mediaPlayer.off(_dashjs2['default'].MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
@@ -193,6 +184,6 @@ // Cleanup old tracks | ||
// Attach dash text tracks whenever we dash emits `TEXT_TRACKS_ADDED`. | ||
mediaPlayer.on(_dashjs2.default.MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
mediaPlayer.on(_dashjs2['default'].MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
function cleanup() { | ||
mediaPlayer.off(_dashjs2.default.MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
mediaPlayer.off(_dashjs2['default'].MediaPlayer.events.TEXT_TRACKS_ADDED, handleTextTracksAdded); | ||
@@ -206,3 +197,3 @@ player.one('loadstart', clearDashTracks); | ||
// mediaPlayers. | ||
mediaPlayer.on(_dashjs2.default.MediaPlayer.events.CAN_PLAY, cleanup); | ||
} | ||
mediaPlayer.on(_dashjs2['default'].MediaPlayer.events.CAN_PLAY, cleanup); | ||
} |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.__esModule = 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; }; }(); | ||
var _window = require('global/window'); | ||
@@ -29,12 +25,6 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var isArray = function isArray(a) { | ||
return Object.prototype.toString.call(a) === '[object Array]'; | ||
}; | ||
/** | ||
@@ -45,3 +35,2 @@ * videojs-contrib-dash | ||
*/ | ||
var Html5DashJS = function () { | ||
@@ -56,3 +45,3 @@ function Html5DashJS(source, tech, options) { | ||
this.player = (0, _video2.default)(options.playerId); | ||
this.player = (0, _video2['default'])(options.playerId); | ||
this.player.dash = this.player.dash || {}; | ||
@@ -75,3 +64,3 @@ | ||
if (Html5DashJS.updateSourceData) { | ||
_video2.default.log.warn('updateSourceData has been deprecated.' + ' Please switch to using hook("updatesource", callback).'); | ||
_video2['default'].log.warn('updateSourceData has been deprecated.' + ' Please switch to using hook("updatesource", callback).'); | ||
source = Html5DashJS.updateSourceData(source); | ||
@@ -88,3 +77,3 @@ } | ||
this.player.dash.mediaPlayer = _dashjs2.default.MediaPlayer().create(); | ||
this.player.dash.mediaPlayer = _dashjs2['default'].MediaPlayer().create(); | ||
@@ -95,3 +84,3 @@ this.mediaPlayer_ = this.player.dash.mediaPlayer; | ||
if (Html5DashJS.useVideoJSDebug) { | ||
_video2.default.log.warn('useVideoJSDebug has been deprecated.' + ' Please switch to using hook("beforeinitialize", callback).'); | ||
_video2['default'].log.warn('useVideoJSDebug has been deprecated.' + ' Please switch to using hook("beforeinitialize", callback).'); | ||
Html5DashJS.useVideoJSDebug(this.mediaPlayer_); | ||
@@ -101,3 +90,3 @@ } | ||
if (Html5DashJS.beforeInitialize) { | ||
_video2.default.log.warn('beforeInitialize has been deprecated.' + ' Please switch to using hook("beforeinitialize", callback).'); | ||
_video2['default'].log.warn('beforeInitialize has been deprecated.' + ' Please switch to using hook("beforeinitialize", callback).'); | ||
Html5DashJS.beforeInitialize(this.player, this.mediaPlayer_); | ||
@@ -124,3 +113,3 @@ } | ||
// Providing a key without `set` prefix is now deprecated. | ||
_video2.default.log.warn('Using dash options in videojs-contrib-dash without the set prefix ' + ('has been deprecated. Change \'' + key + '\' to \'' + dashOptionsKey + '\'')); | ||
_video2['default'].log.warn('Using dash options in videojs-contrib-dash without the set prefix ' + ('has been deprecated. Change \'' + key + '\' to \'' + dashOptionsKey + '\'')); | ||
@@ -132,3 +121,3 @@ // Set key so it will still work | ||
if (!_this.mediaPlayer_.hasOwnProperty(key)) { | ||
_video2.default.log.warn('Warning: dash configuration option unrecognized: ' + key); | ||
_video2['default'].log.warn('Warning: dash configuration option unrecognized: ' + key); | ||
@@ -139,7 +128,7 @@ return; | ||
// Guarantee `value` is an array | ||
if (!isArray(value)) { | ||
if (!Array.isArray(value)) { | ||
value = [value]; | ||
} | ||
(_mediaPlayer_ = _this.mediaPlayer_)[key].apply(_mediaPlayer_, _toConsumableArray(value)); | ||
(_mediaPlayer_ = _this.mediaPlayer_)[key].apply(_mediaPlayer_, value); | ||
}); | ||
@@ -154,6 +143,6 @@ } | ||
// Setup audio tracks | ||
_setupAudioTracks2.default.call(null, this.player, tech); | ||
_setupAudioTracks2['default'].call(null, this.player, tech); | ||
// Setup text tracks | ||
_setupTextTracks2.default.call(null, this.player, tech, options); | ||
_setupTextTracks2['default'].call(null, this.player, tech, options); | ||
@@ -175,106 +164,98 @@ // Attach the source with any protection data | ||
_createClass(Html5DashJS, [{ | ||
key: 'dispose', | ||
value: function dispose() { | ||
if (this.mediaPlayer_) { | ||
this.mediaPlayer_.reset(); | ||
} | ||
Html5DashJS.buildDashJSProtData = function buildDashJSProtData(keySystemOptions) { | ||
var output = {}; | ||
if (this.player.dash) { | ||
delete this.player.dash; | ||
} | ||
if (!keySystemOptions || !Array.isArray(keySystemOptions)) { | ||
return null; | ||
} | ||
}, { | ||
key: 'duration', | ||
value: function duration() { | ||
var duration = this.el_.duration; | ||
if (duration === Number.MAX_VALUE) { | ||
return Infinity; | ||
for (var i = 0; i < keySystemOptions.length; i++) { | ||
var keySystem = keySystemOptions[i]; | ||
var options = _video2['default'].mergeOptions({}, keySystem.options); | ||
if (options.licenseUrl) { | ||
options.serverURL = options.licenseUrl; | ||
delete options.licenseUrl; | ||
} | ||
return duration; | ||
output[keySystem.name] = options; | ||
} | ||
/** | ||
* Get a list of hooks for a specific lifecycle | ||
* | ||
* @param {string} type the lifecycle to get hooks from | ||
* @param {Function=|Function[]=} hook Optionally add a hook tothe lifecycle | ||
* @return {Array} an array of hooks or epty if none | ||
* @method hooks | ||
*/ | ||
return output; | ||
}; | ||
}], [{ | ||
key: 'buildDashJSProtData', | ||
value: function buildDashJSProtData(keySystemOptions) { | ||
var output = {}; | ||
Html5DashJS.prototype.dispose = function dispose() { | ||
if (this.mediaPlayer_) { | ||
this.mediaPlayer_.reset(); | ||
} | ||
if (!keySystemOptions || !isArray(keySystemOptions)) { | ||
return null; | ||
} | ||
if (this.player.dash) { | ||
delete this.player.dash; | ||
} | ||
}; | ||
for (var i = 0; i < keySystemOptions.length; i++) { | ||
var keySystem = keySystemOptions[i]; | ||
var options = _video2.default.mergeOptions({}, keySystem.options); | ||
Html5DashJS.prototype.duration = function duration() { | ||
var duration = this.el_.duration; | ||
if (duration === Number.MAX_VALUE) { | ||
return Infinity; | ||
} | ||
return duration; | ||
}; | ||
if (options.licenseUrl) { | ||
options.serverURL = options.licenseUrl; | ||
delete options.licenseUrl; | ||
} | ||
/** | ||
* Get a list of hooks for a specific lifecycle | ||
* | ||
* @param {string} type the lifecycle to get hooks from | ||
* @param {Function=|Function[]=} hook Optionally add a hook tothe lifecycle | ||
* @return {Array} an array of hooks or epty if none | ||
* @method hooks | ||
*/ | ||
output[keySystem.name] = options; | ||
} | ||
return output; | ||
Html5DashJS.hooks = function hooks(type, hook) { | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type] || []; | ||
if (hook) { | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type].concat(hook); | ||
} | ||
}, { | ||
key: 'hooks', | ||
value: function hooks(type, hook) { | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type] || []; | ||
if (hook) { | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type].concat(hook); | ||
} | ||
return Html5DashJS.hooks_[type]; | ||
}; | ||
return Html5DashJS.hooks_[type]; | ||
} | ||
/** | ||
* Add a function hook to a specific dash lifecycle | ||
* | ||
* @param {string} type the lifecycle to hook the function to | ||
* @param {Function|Function[]} hook the function or array of functions to attach | ||
* @method hook | ||
*/ | ||
/** | ||
* Add a function hook to a specific dash lifecycle | ||
* | ||
* @param {string} type the lifecycle to hook the function to | ||
* @param {Function|Function[]} hook the function or array of functions to attach | ||
* @method hook | ||
*/ | ||
}, { | ||
key: 'hook', | ||
value: function hook(type, _hook) { | ||
Html5DashJS.hooks(type, _hook); | ||
} | ||
Html5DashJS.hook = function hook(type, _hook) { | ||
Html5DashJS.hooks(type, _hook); | ||
}; | ||
/** | ||
* Remove a hook from a specific dash lifecycle. | ||
* | ||
* @param {string} type the lifecycle that the function hooked to | ||
* @param {Function} hook The hooked function to remove | ||
* @return {boolean} True if the function was removed, false if not found | ||
* @method removeHook | ||
*/ | ||
/** | ||
* Remove a hook from a specific dash lifecycle. | ||
* | ||
* @param {string} type the lifecycle that the function hooked to | ||
* @param {Function} hook The hooked function to remove | ||
* @return {boolean} True if the function was removed, false if not found | ||
* @method removeHook | ||
*/ | ||
}, { | ||
key: 'removeHook', | ||
value: function removeHook(type, hook) { | ||
var index = Html5DashJS.hooks(type).indexOf(hook); | ||
if (index === -1) { | ||
return false; | ||
} | ||
Html5DashJS.removeHook = function removeHook(type, hook) { | ||
var index = Html5DashJS.hooks(type).indexOf(hook); | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type].slice(); | ||
Html5DashJS.hooks_[type].splice(index, 1); | ||
return true; | ||
if (index === -1) { | ||
return false; | ||
} | ||
}]); | ||
Html5DashJS.hooks_[type] = Html5DashJS.hooks_[type].slice(); | ||
Html5DashJS.hooks_[type].splice(index, 1); | ||
return true; | ||
}; | ||
return Html5DashJS; | ||
@@ -290,3 +271,3 @@ }(); | ||
if (Html5DashJS.updateSourceData) { | ||
_video2.default.log.warn('updateSourceData has been deprecated.' + ' Please switch to using hook("updatesource", callback).'); | ||
_video2['default'].log.warn('updateSourceData has been deprecated.' + ' Please switch to using hook("updatesource", callback).'); | ||
source = Html5DashJS.updateSourceData(source); | ||
@@ -310,3 +291,3 @@ } | ||
_video2.default.DashSourceHandler = function () { | ||
_video2['default'].DashSourceHandler = function () { | ||
return { | ||
@@ -320,3 +301,3 @@ canHandleSource: function canHandleSource(source) { | ||
if (_video2.default.DashSourceHandler.canPlayType(source.type)) { | ||
if (_video2['default'].DashSourceHandler.canPlayType(source.type)) { | ||
return 'probably'; | ||
@@ -335,3 +316,3 @@ } else if (dashExtRE.test(source.src)) { | ||
canPlayType: function canPlayType(type) { | ||
return _video2.default.DashSourceHandler.canPlayType(type); | ||
return _video2['default'].DashSourceHandler.canPlayType(type); | ||
} | ||
@@ -341,3 +322,3 @@ }; | ||
_video2.default.DashSourceHandler.canPlayType = function (type) { | ||
_video2['default'].DashSourceHandler.canPlayType = function (type) { | ||
var dashTypeRE = /^application\/dash\+xml/i; | ||
@@ -352,7 +333,7 @@ if (dashTypeRE.test(type)) { | ||
// Only add the SourceHandler if the browser supports MediaSourceExtensions | ||
if (!!_window2.default.MediaSource) { | ||
_video2.default.getTech('Html5').registerSourceHandler(_video2.default.DashSourceHandler(), 0); | ||
if (!!_window2['default'].MediaSource) { | ||
_video2['default'].getTech('Html5').registerSourceHandler(_video2['default'].DashSourceHandler(), 0); | ||
} | ||
_video2.default.Html5DashJS = Html5DashJS; | ||
exports.default = Html5DashJS; | ||
_video2['default'].Html5DashJS = Html5DashJS; | ||
exports['default'] = Html5DashJS; |
@@ -9,10 +9,24 @@ { | ||
}, | ||
"version": "2.9.0", | ||
"author": { | ||
"name": "Brightcove" | ||
}, | ||
"version": "2.9.1", | ||
"author": "Brightcove, Inc", | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
"test": "grunt", | ||
"build": "grunt build", | ||
"prepublish": "grunt build" | ||
"prebuild": "npm run clean", | ||
"build": "npm-run-all build:*", | ||
"build:js": "npm-run-all build:js:babel build:js:browserify build:js:bannerize build:js:uglify", | ||
"build:js:babel": "babel src/js -d es5", | ||
"build:js:bannerize": "bannerize dist/videojs-dash.js --banner=scripts/banner.ejs", | ||
"build:js:browserify": "browserify . -s videojs-dash -g browserify-shim -o dist/videojs-dash.js", | ||
"build:js:uglify": "uglifyjs dist/videojs-dash.js --support-ie8 --comments -m -c -o dist/videojs-dash.min.js", | ||
"build:test:browserify": "browserify test/build.test.js -o dist-test/browserify.test.js", | ||
"build:test:webpack": "webpack test/build.test.js dist-test/webpack.test.js", | ||
"build:test": "npm-run-all build:test:browserify build:test:webpack", | ||
"clean": "npm-run-all -p clean:*", | ||
"clean:build": "rm -rf dist dist-test es5 && mkdir -p dist dist-test es5", | ||
"lint": "jshint src/**/*.js", | ||
"pretest": "npm-run-all lint build", | ||
"test": "karma start test/karma.config.js", | ||
"preversion": "npm test", | ||
"version": "npm run build", | ||
"prepublish": "npm run build" | ||
}, | ||
@@ -33,2 +47,12 @@ "keywords": [ | ||
}, | ||
"files": [ | ||
"CONTRIBUTING.md", | ||
"dist/", | ||
"docs/", | ||
"es5/", | ||
"index.html", | ||
"scripts/", | ||
"src/", | ||
"test/" | ||
], | ||
"dependencies": { | ||
@@ -40,24 +64,20 @@ "dashjs": "^2.2.0", | ||
"devDependencies": { | ||
"babel-preset-es2015": "^6.6.0", | ||
"browserify-shim": "^3.8.12", | ||
"grunt": "~1.0.1", | ||
"grunt-babel": "^6.0.0", | ||
"grunt-browserify": "^5.0.0", | ||
"grunt-cli": "^1.2.0", | ||
"grunt-contrib-clean": "~1.0.0", | ||
"grunt-contrib-concat": "~1.0.1", | ||
"grunt-contrib-jshint": "~1.1.0", | ||
"grunt-contrib-uglify": "~2.0.0", | ||
"grunt-contrib-watch": "~1.0.0", | ||
"grunt-karma": "^2.0.0", | ||
"grunt-webpack": "^1.0.14", | ||
"karma": "^1.1.2", | ||
"karma-chrome-launcher": "^2.0.0", | ||
"karma-firefox-launcher": "^1.0.0", | ||
"karma-qunit": "^1.2.0", | ||
"load-grunt-tasks": "^3.1.0", | ||
"babel-cli": "^6.24.1", | ||
"babel-preset-es2015": "^6.24.1", | ||
"babel-preset-es3": "^1.0.1", | ||
"babelify": "^7.3.0", | ||
"bannerize": "^1.0.0", | ||
"browserify": "^11.0.0", | ||
"browserify-shim": "^3.0.0", | ||
"jshint": "^2.9.4", | ||
"karma": "^1.7.0", | ||
"karma-chrome-launcher": "^2.1.1", | ||
"karma-firefox-launcher": "^1.0.1", | ||
"karma-qunit": "^1.2.1", | ||
"karma-spec-reporter": "0.0.31", | ||
"npm-run-all": "^1.2.0", | ||
"qunitjs": "^2.0.1", | ||
"webpack": "^1.13.2", | ||
"webpack-dev-server": "^1.15.0" | ||
"uglify-js": "^2.5.0", | ||
"webpack": "^1.13.2" | ||
} | ||
} |
import dashjs from 'dashjs'; | ||
import videojs from 'video.js'; | ||
/* | ||
/** | ||
* Setup audio tracks. Take the tracks from dash and add the tracks to videojs. Listen for when | ||
@@ -6,0 +6,0 @@ * videojs changes tracks and apply that to the dash player because videojs doesn't do this |
import dashjs from 'dashjs'; | ||
import videojs from 'video.js'; | ||
function find(l, f) { | ||
for(let i = 0; i < l.length; i++) { | ||
if (f(l[i])) { | ||
return l[i]; | ||
} | ||
} | ||
} | ||
/* | ||
@@ -22,4 +30,2 @@ * Attach text tracks from dash.js to videojs | ||
trackConfig: { | ||
default: track.defaultTrack, | ||
kind: track.kind, | ||
label: track.lang, | ||
@@ -62,7 +68,6 @@ language: track.lang, | ||
const dictionaryLookupResult = trackDictionary.find( | ||
/* jshint loopfunc: true */ | ||
({textTrack: dictionaryTextTrack}) => dictionaryTextTrack === textTrack | ||
/* jshint loopfunc: false */ | ||
); | ||
/* jshint loopfunc: true */ | ||
const dictionaryLookupResult = find(trackDictionary, | ||
(track) => track.textTrack === textTrack); | ||
/* jshint loopfunc: false */ | ||
@@ -94,19 +99,2 @@ const dashTrackToActivate = dictionaryLookupResult ? | ||
/* | ||
* Now that all the text tracks are created, iterate through them and set the default to | ||
* `showing`. Note that more than one track can be listed as a default because this will create | ||
* subtitles and captions which can independently have their own defaults. This will ignore all | ||
* tracks that are not `subtitles` or `captions`, otherwise we'll be showing text data for | ||
* `metadata` and `descriptions` tracks. | ||
*/ | ||
const textTracks = player.textTracks(); | ||
for (let i = 0; i < textTracks.length; i += 1) { | ||
const textTrack = textTracks[i]; | ||
if (textTrack.kind === 'subtitles' || textTrack.kind === 'captions') { | ||
textTrack.mode = textTrack.default ? 'showing' : 'hidden'; | ||
} | ||
} | ||
// Initialize the text track on our first run-through | ||
@@ -126,2 +114,9 @@ updateActiveDashTextTrack(); | ||
export default function setupTextTracks(player, tech, options) { | ||
// Clear VTTCue if it was shimmed by vttjs and let dash.js use TextTrackCue. | ||
// This is necessary because dash.js creates text tracks | ||
// using addTextTrack which is incompatible with vttjs.VTTCue in IE11 | ||
if (window.VTTCue && !(/\[native code\]/).test(window.VTTCue.toString())) { | ||
window.VTTCue = false; | ||
} | ||
// Store the tracks that we've added so we can remove them later. | ||
@@ -128,0 +123,0 @@ let dashTracksAttachedToVideoJs = []; |
@@ -7,7 +7,2 @@ import window from 'global/window'; | ||
let | ||
isArray = function(a) { | ||
return Object.prototype.toString.call(a) === '[object Array]'; | ||
}; | ||
/** | ||
@@ -103,3 +98,3 @@ * videojs-contrib-dash | ||
// Guarantee `value` is an array | ||
if (!isArray(value)) { | ||
if (!Array.isArray(value)) { | ||
value = [value]; | ||
@@ -139,3 +134,3 @@ } | ||
if (!keySystemOptions || !isArray(keySystemOptions)) { | ||
if (!keySystemOptions || !Array.isArray(keySystemOptions)) { | ||
return null; | ||
@@ -142,0 +137,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
102432
17
22
1808