1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | 'use strict';
|
8 |
|
9 | 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; }; })();
|
10 |
|
11 | var _get = function get(_x4, _x5, _x6) { var _again = true; _function: while (_again) { var object = _x4, property = _x5, receiver = _x6; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x4 = parent; _x5 = property; _x6 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
|
12 |
|
13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
14 |
|
15 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
16 |
|
17 | function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
18 |
|
19 | var _globalDocument = require('global/document');
|
20 |
|
21 | var _globalDocument2 = _interopRequireDefault(_globalDocument);
|
22 |
|
23 | var _playlistLoader = require('./playlist-loader');
|
24 |
|
25 | var _playlistLoader2 = _interopRequireDefault(_playlistLoader);
|
26 |
|
27 | var _playlist = require('./playlist');
|
28 |
|
29 | var _playlist2 = _interopRequireDefault(_playlist);
|
30 |
|
31 | var _xhr = require('./xhr');
|
32 |
|
33 | var _xhr2 = _interopRequireDefault(_xhr);
|
34 |
|
35 | var _aesDecrypter = require('aes-decrypter');
|
36 |
|
37 | var _binUtils = require('./bin-utils');
|
38 |
|
39 | var _binUtils2 = _interopRequireDefault(_binUtils);
|
40 |
|
41 | var _videojsContribMediaSources = require('videojs-contrib-media-sources');
|
42 |
|
43 | var _m3u8Parser = require('m3u8-parser');
|
44 |
|
45 | var _m3u8Parser2 = _interopRequireDefault(_m3u8Parser);
|
46 |
|
47 | var _videoJs = require('video.js');
|
48 |
|
49 | var _videoJs2 = _interopRequireDefault(_videoJs);
|
50 |
|
51 | var _masterPlaylistController = require('./master-playlist-controller');
|
52 |
|
53 | var _config = require('./config');
|
54 |
|
55 | var _config2 = _interopRequireDefault(_config);
|
56 |
|
57 | var _renditionMixin = require('./rendition-mixin');
|
58 |
|
59 | var _renditionMixin2 = _interopRequireDefault(_renditionMixin);
|
60 |
|
61 | var _globalWindow = require('global/window');
|
62 |
|
63 | var _globalWindow2 = _interopRequireDefault(_globalWindow);
|
64 |
|
65 | var _playbackWatcher = require('./playback-watcher');
|
66 |
|
67 | var _playbackWatcher2 = _interopRequireDefault(_playbackWatcher);
|
68 |
|
69 | var _reloadSourceOnError = require('./reload-source-on-error');
|
70 |
|
71 | var _reloadSourceOnError2 = _interopRequireDefault(_reloadSourceOnError);
|
72 |
|
73 | var _playlistSelectorsJs = require('./playlist-selectors.js');
|
74 |
|
75 | var Hls = {
|
76 | PlaylistLoader: _playlistLoader2['default'],
|
77 | Playlist: _playlist2['default'],
|
78 | Decrypter: _aesDecrypter.Decrypter,
|
79 | AsyncStream: _aesDecrypter.AsyncStream,
|
80 | decrypt: _aesDecrypter.decrypt,
|
81 | utils: _binUtils2['default'],
|
82 |
|
83 | STANDARD_PLAYLIST_SELECTOR: _playlistSelectorsJs.lastBandwidthSelector,
|
84 | INITIAL_PLAYLIST_SELECTOR: _playlistSelectorsJs.lowestBitrateCompatibleVariantSelector,
|
85 | comparePlaylistBandwidth: _playlistSelectorsJs.comparePlaylistBandwidth,
|
86 | comparePlaylistResolution: _playlistSelectorsJs.comparePlaylistResolution,
|
87 |
|
88 | xhr: (0, _xhr2['default'])()
|
89 | };
|
90 |
|
91 |
|
92 | var INITIAL_BANDWIDTH = 4194304;
|
93 |
|
94 |
|
95 | ['GOAL_BUFFER_LENGTH', 'MAX_GOAL_BUFFER_LENGTH', 'GOAL_BUFFER_LENGTH_RATE', 'BUFFER_LOW_WATER_LINE', 'MAX_BUFFER_LOW_WATER_LINE', 'BUFFER_LOW_WATER_LINE_RATE', 'BANDWIDTH_VARIANCE'].forEach(function (prop) {
|
96 | Object.defineProperty(Hls, prop, {
|
97 | get: function get() {
|
98 | _videoJs2['default'].log.warn('using Hls.' + prop + ' is UNSAFE be sure you know what you are doing');
|
99 | return _config2['default'][prop];
|
100 | },
|
101 | set: function set(value) {
|
102 | _videoJs2['default'].log.warn('using Hls.' + prop + ' is UNSAFE be sure you know what you are doing');
|
103 |
|
104 | if (typeof value !== 'number' || value < 0) {
|
105 | _videoJs2['default'].log.warn('value of Hls.' + prop + ' must be greater than or equal to 0');
|
106 | return;
|
107 | }
|
108 |
|
109 | _config2['default'][prop] = value;
|
110 | }
|
111 | });
|
112 | });
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 | var handleHlsMediaChange = function handleHlsMediaChange(qualityLevels, playlistLoader) {
|
122 | var newPlaylist = playlistLoader.media();
|
123 | var selectedIndex = -1;
|
124 |
|
125 | for (var i = 0; i < qualityLevels.length; i++) {
|
126 | if (qualityLevels[i].id === newPlaylist.uri) {
|
127 | selectedIndex = i;
|
128 | break;
|
129 | }
|
130 | }
|
131 |
|
132 | qualityLevels.selectedIndex_ = selectedIndex;
|
133 | qualityLevels.trigger({
|
134 | selectedIndex: selectedIndex,
|
135 | type: 'change'
|
136 | });
|
137 | };
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 | var handleHlsLoadedMetadata = function handleHlsLoadedMetadata(qualityLevels, hls) {
|
147 | hls.representations().forEach(function (rep) {
|
148 | qualityLevels.addQualityLevel(rep);
|
149 | });
|
150 | handleHlsMediaChange(qualityLevels, hls.playlists);
|
151 | };
|
152 |
|
153 |
|
154 |
|
155 | Hls.canPlaySource = function () {
|
156 | return _videoJs2['default'].log.warn('HLS is no longer a tech. Please remove it from ' + 'your player\'s techOrder.');
|
157 | };
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | Hls.supportsNativeHls = (function () {
|
163 | var video = _globalDocument2['default'].createElement('video');
|
164 |
|
165 |
|
166 | if (!_videoJs2['default'].getTech('Html5').isSupported()) {
|
167 | return false;
|
168 | }
|
169 |
|
170 |
|
171 | var canPlay = [
|
172 |
|
173 | 'application/vnd.apple.mpegurl',
|
174 |
|
175 | 'audio/mpegurl',
|
176 |
|
177 | 'audio/x-mpegurl',
|
178 |
|
179 | 'application/x-mpegurl',
|
180 |
|
181 | 'video/x-mpegurl', 'video/mpegurl', 'application/mpegurl'];
|
182 |
|
183 | return canPlay.some(function (canItPlay) {
|
184 | return (/maybe|probably/i.test(video.canPlayType(canItPlay))
|
185 | );
|
186 | });
|
187 | })();
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 | Hls.isSupported = function () {
|
194 | return _videoJs2['default'].log.warn('HLS is no longer a tech. Please remove it from ' + 'your player\'s techOrder.');
|
195 | };
|
196 |
|
197 | var Component = _videoJs2['default'].getComponent('Component');
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 | var HlsHandler = (function (_Component) {
|
211 | _inherits(HlsHandler, _Component);
|
212 |
|
213 | function HlsHandler(source, tech, options) {
|
214 | var _this = this;
|
215 |
|
216 | _classCallCheck(this, HlsHandler);
|
217 |
|
218 | _get(Object.getPrototypeOf(HlsHandler.prototype), 'constructor', this).call(this, tech, options.hls);
|
219 |
|
220 |
|
221 |
|
222 | if (tech.options_ && tech.options_.playerId) {
|
223 | var _player = (0, _videoJs2['default'])(tech.options_.playerId);
|
224 |
|
225 | if (!_player.hasOwnProperty('hls')) {
|
226 | Object.defineProperty(_player, 'hls', {
|
227 | get: function get() {
|
228 | _videoJs2['default'].log.warn('player.hls is deprecated. Use player.tech_.hls instead.');
|
229 | tech.trigger({ type: 'usage', name: 'hls-player-access' });
|
230 | return _this;
|
231 | }
|
232 | });
|
233 | }
|
234 | }
|
235 |
|
236 | this.tech_ = tech;
|
237 | this.source_ = source;
|
238 | this.stats = {};
|
239 | this.ignoreNextSeekingEvent_ = false;
|
240 | this.setOptions_();
|
241 |
|
242 |
|
243 |
|
244 | if (this.options_.overrideNative && (tech.featuresNativeVideoTracks || tech.featuresNativeAudioTracks)) {
|
245 | throw new Error('Overriding native HLS requires emulated tracks. ' + 'See https://git.io/vMpjB');
|
246 | }
|
247 |
|
248 |
|
249 |
|
250 | this.on(_globalDocument2['default'], ['fullscreenchange', 'webkitfullscreenchange', 'mozfullscreenchange', 'MSFullscreenChange'], function (event) {
|
251 | var fullscreenElement = _globalDocument2['default'].fullscreenElement || _globalDocument2['default'].webkitFullscreenElement || _globalDocument2['default'].mozFullScreenElement || _globalDocument2['default'].msFullscreenElement;
|
252 |
|
253 | if (fullscreenElement && fullscreenElement.contains(_this.tech_.el())) {
|
254 | _this.masterPlaylistController_.fastQualityChange_();
|
255 | }
|
256 | });
|
257 |
|
258 | this.on(this.tech_, 'seeking', function () {
|
259 | if (this.ignoreNextSeekingEvent_) {
|
260 | this.ignoreNextSeekingEvent_ = false;
|
261 | return;
|
262 | }
|
263 |
|
264 | this.setCurrentTime(this.tech_.currentTime());
|
265 | });
|
266 | this.on(this.tech_, 'error', function () {
|
267 | if (this.masterPlaylistController_) {
|
268 | this.masterPlaylistController_.pauseLoading();
|
269 | }
|
270 | });
|
271 |
|
272 | this.on(this.tech_, 'play', this.play);
|
273 | }
|
274 |
|
275 | |
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 | _createClass(HlsHandler, [{
|
284 | key: 'setOptions_',
|
285 | value: function setOptions_() {
|
286 | var _this2 = this;
|
287 |
|
288 |
|
289 | this.options_.withCredentials = this.options_.withCredentials || false;
|
290 |
|
291 | if (typeof this.options_.blacklistDuration !== 'number') {
|
292 | this.options_.blacklistDuration = 5 * 60;
|
293 | }
|
294 |
|
295 |
|
296 |
|
297 | if (typeof this.options_.bandwidth !== 'number') {
|
298 | this.options_.bandwidth = INITIAL_BANDWIDTH;
|
299 | }
|
300 |
|
301 |
|
302 |
|
303 | this.options_.enableLowInitialPlaylist = this.options_.enableLowInitialPlaylist && this.options_.bandwidth === INITIAL_BANDWIDTH;
|
304 |
|
305 |
|
306 | ['withCredentials', 'bandwidth'].forEach(function (option) {
|
307 | if (typeof _this2.source_[option] !== 'undefined') {
|
308 | _this2.options_[option] = _this2.source_[option];
|
309 | }
|
310 | });
|
311 |
|
312 | this.bandwidth = this.options_.bandwidth;
|
313 | }
|
314 |
|
315 | |
316 |
|
317 |
|
318 |
|
319 |
|
320 | }, {
|
321 | key: 'src',
|
322 | value: function src(_src) {
|
323 | var _this3 = this;
|
324 |
|
325 |
|
326 | if (!_src) {
|
327 | return;
|
328 | }
|
329 | this.setOptions_();
|
330 |
|
331 | this.options_.url = this.source_.src;
|
332 | this.options_.tech = this.tech_;
|
333 | this.options_.externHls = Hls;
|
334 |
|
335 | this.masterPlaylistController_ = new _masterPlaylistController.MasterPlaylistController(this.options_);
|
336 | this.playbackWatcher_ = new _playbackWatcher2['default'](_videoJs2['default'].mergeOptions(this.options_, {
|
337 | seekable: function seekable() {
|
338 | return _this3.seekable();
|
339 | }
|
340 | }));
|
341 |
|
342 | this.masterPlaylistController_.on('error', function () {
|
343 | var player = _videoJs2['default'].players[_this3.tech_.options_.playerId];
|
344 |
|
345 | player.error(_this3.masterPlaylistController_.error);
|
346 | });
|
347 |
|
348 |
|
349 |
|
350 | this.masterPlaylistController_.selectPlaylist = this.selectPlaylist ? this.selectPlaylist.bind(this) : Hls.STANDARD_PLAYLIST_SELECTOR.bind(this);
|
351 |
|
352 | this.masterPlaylistController_.selectInitialPlaylist = Hls.INITIAL_PLAYLIST_SELECTOR.bind(this);
|
353 |
|
354 |
|
355 | this.playlists = this.masterPlaylistController_.masterPlaylistLoader_;
|
356 | this.mediaSource = this.masterPlaylistController_.mediaSource;
|
357 |
|
358 |
|
359 |
|
360 |
|
361 | Object.defineProperties(this, {
|
362 | selectPlaylist: {
|
363 | get: function get() {
|
364 | return this.masterPlaylistController_.selectPlaylist;
|
365 | },
|
366 | set: function set(selectPlaylist) {
|
367 | this.masterPlaylistController_.selectPlaylist = selectPlaylist.bind(this);
|
368 | }
|
369 | },
|
370 | throughput: {
|
371 | get: function get() {
|
372 | return this.masterPlaylistController_.mainSegmentLoader_.throughput.rate;
|
373 | },
|
374 | set: function set(throughput) {
|
375 | this.masterPlaylistController_.mainSegmentLoader_.throughput.rate = throughput;
|
376 |
|
377 |
|
378 | this.masterPlaylistController_.mainSegmentLoader_.throughput.count = 1;
|
379 | }
|
380 | },
|
381 | bandwidth: {
|
382 | get: function get() {
|
383 | return this.masterPlaylistController_.mainSegmentLoader_.bandwidth;
|
384 | },
|
385 | set: function set(bandwidth) {
|
386 | this.masterPlaylistController_.mainSegmentLoader_.bandwidth = bandwidth;
|
387 |
|
388 |
|
389 |
|
390 | this.masterPlaylistController_.mainSegmentLoader_.throughput = {
|
391 | rate: 0,
|
392 | count: 0
|
393 | };
|
394 | }
|
395 | },
|
396 | |
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 | systemBandwidth: {
|
406 | get: function get() {
|
407 | var invBandwidth = 1 / (this.bandwidth || 1);
|
408 | var invThroughput = undefined;
|
409 |
|
410 | if (this.throughput > 0) {
|
411 | invThroughput = 1 / this.throughput;
|
412 | } else {
|
413 | invThroughput = 0;
|
414 | }
|
415 |
|
416 | var systemBitrate = Math.floor(1 / (invBandwidth + invThroughput));
|
417 |
|
418 | return systemBitrate;
|
419 | },
|
420 | set: function set() {
|
421 | _videoJs2['default'].log.error('The "systemBandwidth" property is read-only');
|
422 | }
|
423 | }
|
424 | });
|
425 |
|
426 | Object.defineProperties(this.stats, {
|
427 | bandwidth: {
|
428 | get: function get() {
|
429 | return _this3.bandwidth || 0;
|
430 | },
|
431 | enumerable: true
|
432 | },
|
433 | mediaRequests: {
|
434 | get: function get() {
|
435 | return _this3.masterPlaylistController_.mediaRequests_() || 0;
|
436 | },
|
437 | enumerable: true
|
438 | },
|
439 | mediaRequestsAborted: {
|
440 | get: function get() {
|
441 | return _this3.masterPlaylistController_.mediaRequestsAborted_() || 0;
|
442 | },
|
443 | enumerable: true
|
444 | },
|
445 | mediaRequestsTimedout: {
|
446 | get: function get() {
|
447 | return _this3.masterPlaylistController_.mediaRequestsTimedout_() || 0;
|
448 | },
|
449 | enumerable: true
|
450 | },
|
451 | mediaRequestsErrored: {
|
452 | get: function get() {
|
453 | return _this3.masterPlaylistController_.mediaRequestsErrored_() || 0;
|
454 | },
|
455 | enumerable: true
|
456 | },
|
457 | mediaTransferDuration: {
|
458 | get: function get() {
|
459 | return _this3.masterPlaylistController_.mediaTransferDuration_() || 0;
|
460 | },
|
461 | enumerable: true
|
462 | },
|
463 | mediaBytesTransferred: {
|
464 | get: function get() {
|
465 | return _this3.masterPlaylistController_.mediaBytesTransferred_() || 0;
|
466 | },
|
467 | enumerable: true
|
468 | },
|
469 | mediaSecondsLoaded: {
|
470 | get: function get() {
|
471 | return _this3.masterPlaylistController_.mediaSecondsLoaded_() || 0;
|
472 | },
|
473 | enumerable: true
|
474 | }
|
475 | });
|
476 |
|
477 | this.tech_.one('canplay', this.masterPlaylistController_.setupFirstPlay.bind(this.masterPlaylistController_));
|
478 |
|
479 | this.masterPlaylistController_.on('selectedinitialmedia', function () {
|
480 |
|
481 | (0, _renditionMixin2['default'])(_this3);
|
482 | });
|
483 |
|
484 |
|
485 |
|
486 | this.on(this.masterPlaylistController_, 'progress', function () {
|
487 | this.tech_.trigger('progress');
|
488 | });
|
489 |
|
490 |
|
491 |
|
492 | this.on(this.masterPlaylistController_, 'firstplay', function () {
|
493 | this.ignoreNextSeekingEvent_ = true;
|
494 | });
|
495 |
|
496 | this.tech_.ready(function () {
|
497 | return _this3.setupQualityLevels_();
|
498 | });
|
499 |
|
500 |
|
501 |
|
502 | if (!this.tech_.el()) {
|
503 | return;
|
504 | }
|
505 |
|
506 | this.tech_.src(_videoJs2['default'].URL.createObjectURL(this.masterPlaylistController_.mediaSource));
|
507 | }
|
508 |
|
509 | |
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 | }, {
|
516 | key: 'setupQualityLevels_',
|
517 | value: function setupQualityLevels_() {
|
518 | var _this4 = this;
|
519 |
|
520 | var player = _videoJs2['default'].players[this.tech_.options_.playerId];
|
521 |
|
522 | if (player && player.qualityLevels) {
|
523 | this.qualityLevels_ = player.qualityLevels();
|
524 |
|
525 | this.masterPlaylistController_.on('selectedinitialmedia', function () {
|
526 | handleHlsLoadedMetadata(_this4.qualityLevels_, _this4);
|
527 | });
|
528 |
|
529 | this.playlists.on('mediachange', function () {
|
530 | handleHlsMediaChange(_this4.qualityLevels_, _this4.playlists);
|
531 | });
|
532 | }
|
533 | }
|
534 |
|
535 | |
536 |
|
537 |
|
538 | }, {
|
539 | key: 'play',
|
540 | value: function play() {
|
541 | this.masterPlaylistController_.play();
|
542 | }
|
543 |
|
544 | |
545 |
|
546 |
|
547 | }, {
|
548 | key: 'setCurrentTime',
|
549 | value: function setCurrentTime(currentTime) {
|
550 | this.masterPlaylistController_.setCurrentTime(currentTime);
|
551 | }
|
552 |
|
553 | |
554 |
|
555 |
|
556 | }, {
|
557 | key: 'duration',
|
558 | value: function duration() {
|
559 | return this.masterPlaylistController_.duration();
|
560 | }
|
561 |
|
562 | |
563 |
|
564 |
|
565 | }, {
|
566 | key: 'seekable',
|
567 | value: function seekable() {
|
568 | return this.masterPlaylistController_.seekable();
|
569 | }
|
570 |
|
571 | |
572 |
|
573 |
|
574 | }, {
|
575 | key: 'dispose',
|
576 | value: function dispose() {
|
577 | if (this.playbackWatcher_) {
|
578 | this.playbackWatcher_.dispose();
|
579 | }
|
580 | if (this.masterPlaylistController_) {
|
581 | this.masterPlaylistController_.dispose();
|
582 | }
|
583 | if (this.qualityLevels_) {
|
584 | this.qualityLevels_.dispose();
|
585 | }
|
586 | _get(Object.getPrototypeOf(HlsHandler.prototype), 'dispose', this).call(this);
|
587 | }
|
588 | }]);
|
589 |
|
590 | return HlsHandler;
|
591 | })(Component);
|
592 |
|
593 | var HlsSourceHandler = function HlsSourceHandler(mode) {
|
594 | return {
|
595 | canHandleSource: function canHandleSource(srcObj) {
|
596 | var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
|
597 |
|
598 | var localOptions = _videoJs2['default'].mergeOptions(_videoJs2['default'].options, options);
|
599 |
|
600 |
|
601 |
|
602 | if (localOptions.hls && localOptions.hls.mode && localOptions.hls.mode !== mode) {
|
603 | return false;
|
604 | }
|
605 | return HlsSourceHandler.canPlayType(srcObj.type, localOptions);
|
606 | },
|
607 | handleSource: function handleSource(source, tech) {
|
608 | var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
|
609 |
|
610 | var localOptions = _videoJs2['default'].mergeOptions(_videoJs2['default'].options, options, { hls: { mode: mode } });
|
611 |
|
612 | if (mode === 'flash') {
|
613 |
|
614 |
|
615 | tech.setTimeout(function () {
|
616 | tech.trigger('loadstart');
|
617 | }, 1);
|
618 | }
|
619 |
|
620 | tech.hls = new HlsHandler(source, tech, localOptions);
|
621 | tech.hls.xhr = (0, _xhr2['default'])();
|
622 |
|
623 | tech.hls.src(source.src);
|
624 | return tech.hls;
|
625 | },
|
626 | canPlayType: function canPlayType(type) {
|
627 | var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
|
628 |
|
629 | var localOptions = _videoJs2['default'].mergeOptions(_videoJs2['default'].options, options);
|
630 |
|
631 | if (HlsSourceHandler.canPlayType(type, localOptions)) {
|
632 | return 'maybe';
|
633 | }
|
634 | return '';
|
635 | }
|
636 | };
|
637 | };
|
638 |
|
639 | HlsSourceHandler.canPlayType = function (type, options) {
|
640 |
|
641 | if (_videoJs2['default'].browser.IE_VERSION && _videoJs2['default'].browser.IE_VERSION <= 10) {
|
642 | return false;
|
643 | }
|
644 |
|
645 | var mpegurlRE = /^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;
|
646 |
|
647 |
|
648 | if (!options.hls.overrideNative && Hls.supportsNativeHls) {
|
649 | return false;
|
650 | }
|
651 | return mpegurlRE.test(type);
|
652 | };
|
653 |
|
654 | if (typeof _videoJs2['default'].MediaSource === 'undefined' || typeof _videoJs2['default'].URL === 'undefined') {
|
655 | _videoJs2['default'].MediaSource = _videojsContribMediaSources.MediaSource;
|
656 | _videoJs2['default'].URL = _videojsContribMediaSources.URL;
|
657 | }
|
658 |
|
659 | var flashTech = _videoJs2['default'].getTech('Flash');
|
660 |
|
661 |
|
662 | if (_videojsContribMediaSources.MediaSource.supportsNativeMediaSources()) {
|
663 | _videoJs2['default'].getTech('Html5').registerSourceHandler(HlsSourceHandler('html5'), 0);
|
664 | }
|
665 | if (_globalWindow2['default'].Uint8Array && flashTech) {
|
666 | flashTech.registerSourceHandler(HlsSourceHandler('flash'));
|
667 | }
|
668 |
|
669 | _videoJs2['default'].HlsHandler = HlsHandler;
|
670 | _videoJs2['default'].HlsSourceHandler = HlsSourceHandler;
|
671 | _videoJs2['default'].Hls = Hls;
|
672 | if (!_videoJs2['default'].use) {
|
673 | _videoJs2['default'].registerComponent('Hls', Hls);
|
674 | }
|
675 | _videoJs2['default'].m3u8 = _m3u8Parser2['default'];
|
676 | _videoJs2['default'].options.hls = _videoJs2['default'].options.hls || {};
|
677 |
|
678 | if (_videoJs2['default'].registerPlugin) {
|
679 | _videoJs2['default'].registerPlugin('reloadSourceOnError', _reloadSourceOnError2['default']);
|
680 | } else {
|
681 | _videoJs2['default'].plugin('reloadSourceOnError', _reloadSourceOnError2['default']);
|
682 | }
|
683 |
|
684 | module.exports = {
|
685 | Hls: Hls,
|
686 | HlsHandler: HlsHandler,
|
687 | HlsSourceHandler: HlsSourceHandler
|
688 | }; |
\ | No newline at end of file |