[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /*! 2 * MediaElement.js 3 * http://www.mediaelementjs.com/ 4 * 5 * Wrapper that mimics native HTML5 MediaElement (audio and video) 6 * using a variety of technologies (pure JavaScript, Flash, iframe) 7 * 8 * Copyright 2010-2017, John Dyer (http://j.hn/) 9 * License: MIT 10 * 11 */(function(){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}return e})()({1:[function(_dereq_,module,exports){ 12 13 },{}],2:[function(_dereq_,module,exports){ 14 (function (global){ 15 var topLevel = typeof global !== 'undefined' ? global : 16 typeof window !== 'undefined' ? window : {} 17 var minDoc = _dereq_(1); 18 19 var doccy; 20 21 if (typeof document !== 'undefined') { 22 doccy = document; 23 } else { 24 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4']; 25 26 if (!doccy) { 27 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc; 28 } 29 } 30 31 module.exports = doccy; 32 33 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 34 },{"1":1}],3:[function(_dereq_,module,exports){ 35 (function (global){ 36 var win; 37 38 if (typeof window !== "undefined") { 39 win = window; 40 } else if (typeof global !== "undefined") { 41 win = global; 42 } else if (typeof self !== "undefined"){ 43 win = self; 44 } else { 45 win = {}; 46 } 47 48 module.exports = win; 49 50 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 51 },{}],4:[function(_dereq_,module,exports){ 52 (function (root) { 53 54 // Store setTimeout reference so promise-polyfill will be unaffected by 55 // other code modifying setTimeout (like sinon.useFakeTimers()) 56 var setTimeoutFunc = setTimeout; 57 58 function noop() {} 59 60 // Polyfill for Function.prototype.bind 61 function bind(fn, thisArg) { 62 return function () { 63 fn.apply(thisArg, arguments); 64 }; 65 } 66 67 function Promise(fn) { 68 if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new'); 69 if (typeof fn !== 'function') throw new TypeError('not a function'); 70 this._state = 0; 71 this._handled = false; 72 this._value = undefined; 73 this._deferreds = []; 74 75 doResolve(fn, this); 76 } 77 78 function handle(self, deferred) { 79 while (self._state === 3) { 80 self = self._value; 81 } 82 if (self._state === 0) { 83 self._deferreds.push(deferred); 84 return; 85 } 86 self._handled = true; 87 Promise._immediateFn(function () { 88 var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected; 89 if (cb === null) { 90 (self._state === 1 ? resolve : reject)(deferred.promise, self._value); 91 return; 92 } 93 var ret; 94 try { 95 ret = cb(self._value); 96 } catch (e) { 97 reject(deferred.promise, e); 98 return; 99 } 100 resolve(deferred.promise, ret); 101 }); 102 } 103 104 function resolve(self, newValue) { 105 try { 106 // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure 107 if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.'); 108 if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { 109 var then = newValue.then; 110 if (newValue instanceof Promise) { 111 self._state = 3; 112 self._value = newValue; 113 finale(self); 114 return; 115 } else if (typeof then === 'function') { 116 doResolve(bind(then, newValue), self); 117 return; 118 } 119 } 120 self._state = 1; 121 self._value = newValue; 122 finale(self); 123 } catch (e) { 124 reject(self, e); 125 } 126 } 127 128 function reject(self, newValue) { 129 self._state = 2; 130 self._value = newValue; 131 finale(self); 132 } 133 134 function finale(self) { 135 if (self._state === 2 && self._deferreds.length === 0) { 136 Promise._immediateFn(function() { 137 if (!self._handled) { 138 Promise._unhandledRejectionFn(self._value); 139 } 140 }); 141 } 142 143 for (var i = 0, len = self._deferreds.length; i < len; i++) { 144 handle(self, self._deferreds[i]); 145 } 146 self._deferreds = null; 147 } 148 149 function Handler(onFulfilled, onRejected, promise) { 150 this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; 151 this.onRejected = typeof onRejected === 'function' ? onRejected : null; 152 this.promise = promise; 153 } 154 155 /** 156 * Take a potentially misbehaving resolver function and make sure 157 * onFulfilled and onRejected are only called once. 158 * 159 * Makes no guarantees about asynchrony. 160 */ 161 function doResolve(fn, self) { 162 var done = false; 163 try { 164 fn(function (value) { 165 if (done) return; 166 done = true; 167 resolve(self, value); 168 }, function (reason) { 169 if (done) return; 170 done = true; 171 reject(self, reason); 172 }); 173 } catch (ex) { 174 if (done) return; 175 done = true; 176 reject(self, ex); 177 } 178 } 179 180 Promise.prototype['catch'] = function (onRejected) { 181 return this.then(null, onRejected); 182 }; 183 184 Promise.prototype.then = function (onFulfilled, onRejected) { 185 var prom = new (this.constructor)(noop); 186 187 handle(this, new Handler(onFulfilled, onRejected, prom)); 188 return prom; 189 }; 190 191 Promise.all = function (arr) { 192 var args = Array.prototype.slice.call(arr); 193 194 return new Promise(function (resolve, reject) { 195 if (args.length === 0) return resolve([]); 196 var remaining = args.length; 197 198 function res(i, val) { 199 try { 200 if (val && (typeof val === 'object' || typeof val === 'function')) { 201 var then = val.then; 202 if (typeof then === 'function') { 203 then.call(val, function (val) { 204 res(i, val); 205 }, reject); 206 return; 207 } 208 } 209 args[i] = val; 210 if (--remaining === 0) { 211 resolve(args); 212 } 213 } catch (ex) { 214 reject(ex); 215 } 216 } 217 218 for (var i = 0; i < args.length; i++) { 219 res(i, args[i]); 220 } 221 }); 222 }; 223 224 Promise.resolve = function (value) { 225 if (value && typeof value === 'object' && value.constructor === Promise) { 226 return value; 227 } 228 229 return new Promise(function (resolve) { 230 resolve(value); 231 }); 232 }; 233 234 Promise.reject = function (value) { 235 return new Promise(function (resolve, reject) { 236 reject(value); 237 }); 238 }; 239 240 Promise.race = function (values) { 241 return new Promise(function (resolve, reject) { 242 for (var i = 0, len = values.length; i < len; i++) { 243 values[i].then(resolve, reject); 244 } 245 }); 246 }; 247 248 // Use polyfill for setImmediate for performance gains 249 Promise._immediateFn = (typeof setImmediate === 'function' && function (fn) { setImmediate(fn); }) || 250 function (fn) { 251 setTimeoutFunc(fn, 0); 252 }; 253 254 Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) { 255 if (typeof console !== 'undefined' && console) { 256 console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console 257 } 258 }; 259 260 /** 261 * Set the immediate function to execute callbacks 262 * @param fn {function} Function to execute 263 * @deprecated 264 */ 265 Promise._setImmediateFn = function _setImmediateFn(fn) { 266 Promise._immediateFn = fn; 267 }; 268 269 /** 270 * Change the function to execute on unhandled rejection 271 * @param {function} fn Function to execute on unhandled rejection 272 * @deprecated 273 */ 274 Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) { 275 Promise._unhandledRejectionFn = fn; 276 }; 277 278 if (typeof module !== 'undefined' && module.exports) { 279 module.exports = Promise; 280 } else if (!root.Promise) { 281 root.Promise = Promise; 282 } 283 284 })(this); 285 286 },{}],5:[function(_dereq_,module,exports){ 287 'use strict'; 288 289 Object.defineProperty(exports, "__esModule", { 290 value: true 291 }); 292 293 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 294 295 var _mejs = _dereq_(7); 296 297 var _mejs2 = _interopRequireDefault(_mejs); 298 299 var _en = _dereq_(15); 300 301 var _general = _dereq_(27); 302 303 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 304 305 var i18n = { lang: 'en', en: _en.EN }; 306 307 i18n.language = function () { 308 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { 309 args[_key] = arguments[_key]; 310 } 311 312 if (args !== null && args !== undefined && args.length) { 313 314 if (typeof args[0] !== 'string') { 315 throw new TypeError('Language code must be a string value'); 316 } 317 318 if (!/^[a-z]{2,3}((\-|_)[a-z]{2})?$/i.test(args[0])) { 319 throw new TypeError('Language code must have format 2-3 letters and. optionally, hyphen, underscore followed by 2 more letters'); 320 } 321 322 i18n.lang = args[0]; 323 324 if (i18n[args[0]] === undefined) { 325 args[1] = args[1] !== null && args[1] !== undefined && _typeof(args[1]) === 'object' ? args[1] : {}; 326 i18n[args[0]] = !(0, _general.isObjectEmpty)(args[1]) ? args[1] : _en.EN; 327 } else if (args[1] !== null && args[1] !== undefined && _typeof(args[1]) === 'object') { 328 i18n[args[0]] = args[1]; 329 } 330 } 331 332 return i18n.lang; 333 }; 334 335 i18n.t = function (message) { 336 var pluralParam = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 337 338 339 if (typeof message === 'string' && message.length) { 340 341 var str = void 0, 342 pluralForm = void 0; 343 344 var language = i18n.language(); 345 346 var _plural = function _plural(input, number, form) { 347 348 if ((typeof input === 'undefined' ? 'undefined' : _typeof(input)) !== 'object' || typeof number !== 'number' || typeof form !== 'number') { 349 return input; 350 } 351 352 var _pluralForms = function () { 353 return [function () { 354 return arguments.length <= 1 ? undefined : arguments[1]; 355 }, function () { 356 return (arguments.length <= 0 ? undefined : arguments[0]) === 1 ? arguments.length <= 1 ? undefined : arguments[1] : arguments.length <= 2 ? undefined : arguments[2]; 357 }, function () { 358 return (arguments.length <= 0 ? undefined : arguments[0]) === 0 || (arguments.length <= 0 ? undefined : arguments[0]) === 1 ? arguments.length <= 1 ? undefined : arguments[1] : arguments.length <= 2 ? undefined : arguments[2]; 359 }, function () { 360 if ((arguments.length <= 0 ? undefined : arguments[0]) % 10 === 1 && (arguments.length <= 0 ? undefined : arguments[0]) % 100 !== 11) { 361 return arguments.length <= 1 ? undefined : arguments[1]; 362 } else if ((arguments.length <= 0 ? undefined : arguments[0]) !== 0) { 363 return arguments.length <= 2 ? undefined : arguments[2]; 364 } else { 365 return arguments.length <= 3 ? undefined : arguments[3]; 366 } 367 }, function () { 368 if ((arguments.length <= 0 ? undefined : arguments[0]) === 1 || (arguments.length <= 0 ? undefined : arguments[0]) === 11) { 369 return arguments.length <= 1 ? undefined : arguments[1]; 370 } else if ((arguments.length <= 0 ? undefined : arguments[0]) === 2 || (arguments.length <= 0 ? undefined : arguments[0]) === 12) { 371 return arguments.length <= 2 ? undefined : arguments[2]; 372 } else if ((arguments.length <= 0 ? undefined : arguments[0]) > 2 && (arguments.length <= 0 ? undefined : arguments[0]) < 20) { 373 return arguments.length <= 3 ? undefined : arguments[3]; 374 } else { 375 return arguments.length <= 4 ? undefined : arguments[4]; 376 } 377 }, function () { 378 if ((arguments.length <= 0 ? undefined : arguments[0]) === 1) { 379 return arguments.length <= 1 ? undefined : arguments[1]; 380 } else if ((arguments.length <= 0 ? undefined : arguments[0]) === 0 || (arguments.length <= 0 ? undefined : arguments[0]) % 100 > 0 && (arguments.length <= 0 ? undefined : arguments[0]) % 100 < 20) { 381 return arguments.length <= 2 ? undefined : arguments[2]; 382 } else { 383 return arguments.length <= 3 ? undefined : arguments[3]; 384 } 385 }, function () { 386 if ((arguments.length <= 0 ? undefined : arguments[0]) % 10 === 1 && (arguments.length <= 0 ? undefined : arguments[0]) % 100 !== 11) { 387 return arguments.length <= 1 ? undefined : arguments[1]; 388 } else if ((arguments.length <= 0 ? undefined : arguments[0]) % 10 >= 2 && ((arguments.length <= 0 ? undefined : arguments[0]) % 100 < 10 || (arguments.length <= 0 ? undefined : arguments[0]) % 100 >= 20)) { 389 return arguments.length <= 2 ? undefined : arguments[2]; 390 } else { 391 return [3]; 392 } 393 }, function () { 394 if ((arguments.length <= 0 ? undefined : arguments[0]) % 10 === 1 && (arguments.length <= 0 ? undefined : arguments[0]) % 100 !== 11) { 395 return arguments.length <= 1 ? undefined : arguments[1]; 396 } else if ((arguments.length <= 0 ? undefined : arguments[0]) % 10 >= 2 && (arguments.length <= 0 ? undefined : arguments[0]) % 10 <= 4 && ((arguments.length <= 0 ? undefined : arguments[0]) % 100 < 10 || (arguments.length <= 0 ? undefined : arguments[0]) % 100 >= 20)) { 397 return arguments.length <= 2 ? undefined : arguments[2]; 398 } else { 399 return arguments.length <= 3 ? undefined : arguments[3]; 400 } 401 }, function () { 402 if ((arguments.length <= 0 ? undefined : arguments[0]) === 1) { 403 return arguments.length <= 1 ? undefined : arguments[1]; 404 } else if ((arguments.length <= 0 ? undefined : arguments[0]) >= 2 && (arguments.length <= 0 ? undefined : arguments[0]) <= 4) { 405 return arguments.length <= 2 ? undefined : arguments[2]; 406 } else { 407 return arguments.length <= 3 ? undefined : arguments[3]; 408 } 409 }, function () { 410 if ((arguments.length <= 0 ? undefined : arguments[0]) === 1) { 411 return arguments.length <= 1 ? undefined : arguments[1]; 412 } else if ((arguments.length <= 0 ? undefined : arguments[0]) % 10 >= 2 && (arguments.length <= 0 ? undefined : arguments[0]) % 10 <= 4 && ((arguments.length <= 0 ? undefined : arguments[0]) % 100 < 10 || (arguments.length <= 0 ? undefined : arguments[0]) % 100 >= 20)) { 413 return arguments.length <= 2 ? undefined : arguments[2]; 414 } else { 415 return arguments.length <= 3 ? undefined : arguments[3]; 416 } 417 }, function () { 418 if ((arguments.length <= 0 ? undefined : arguments[0]) % 100 === 1) { 419 return arguments.length <= 2 ? undefined : arguments[2]; 420 } else if ((arguments.length <= 0 ? undefined : arguments[0]) % 100 === 2) { 421 return arguments.length <= 3 ? undefined : arguments[3]; 422 } else if ((arguments.length <= 0 ? undefined : arguments[0]) % 100 === 3 || (arguments.length <= 0 ? undefined : arguments[0]) % 100 === 4) { 423 return arguments.length <= 4 ? undefined : arguments[4]; 424 } else { 425 return arguments.length <= 1 ? undefined : arguments[1]; 426 } 427 }, function () { 428 if ((arguments.length <= 0 ? undefined : arguments[0]) === 1) { 429 return arguments.length <= 1 ? undefined : arguments[1]; 430 } else if ((arguments.length <= 0 ? undefined : arguments[0]) === 2) { 431 return arguments.length <= 2 ? undefined : arguments[2]; 432 } else if ((arguments.length <= 0 ? undefined : arguments[0]) > 2 && (arguments.length <= 0 ? undefined : arguments[0]) < 7) { 433 return arguments.length <= 3 ? undefined : arguments[3]; 434 } else if ((arguments.length <= 0 ? undefined : arguments[0]) > 6 && (arguments.length <= 0 ? undefined : arguments[0]) < 11) { 435 return arguments.length <= 4 ? undefined : arguments[4]; 436 } else { 437 return arguments.length <= 5 ? undefined : arguments[5]; 438 } 439 }, function () { 440 if ((arguments.length <= 0 ? undefined : arguments[0]) === 0) { 441 return arguments.length <= 1 ? undefined : arguments[1]; 442 } else if ((arguments.length <= 0 ? undefined : arguments[0]) === 1) { 443 return arguments.length <= 2 ? undefined : arguments[2]; 444 } else if ((arguments.length <= 0 ? undefined : arguments[0]) === 2) { 445 return arguments.length <= 3 ? undefined : arguments[3]; 446 } else if ((arguments.length <= 0 ? undefined : arguments[0]) % 100 >= 3 && (arguments.length <= 0 ? undefined : arguments[0]) % 100 <= 10) { 447 return arguments.length <= 4 ? undefined : arguments[4]; 448 } else if ((arguments.length <= 0 ? undefined : arguments[0]) % 100 >= 11) { 449 return arguments.length <= 5 ? undefined : arguments[5]; 450 } else { 451 return arguments.length <= 6 ? undefined : arguments[6]; 452 } 453 }, function () { 454 if ((arguments.length <= 0 ? undefined : arguments[0]) === 1) { 455 return arguments.length <= 1 ? undefined : arguments[1]; 456 } else if ((arguments.length <= 0 ? undefined : arguments[0]) === 0 || (arguments.length <= 0 ? undefined : arguments[0]) % 100 > 1 && (arguments.length <= 0 ? undefined : arguments[0]) % 100 < 11) { 457 return arguments.length <= 2 ? undefined : arguments[2]; 458 } else if ((arguments.length <= 0 ? undefined : arguments[0]) % 100 > 10 && (arguments.length <= 0 ? undefined : arguments[0]) % 100 < 20) { 459 return arguments.length <= 3 ? undefined : arguments[3]; 460 } else { 461 return arguments.length <= 4 ? undefined : arguments[4]; 462 } 463 }, function () { 464 if ((arguments.length <= 0 ? undefined : arguments[0]) % 10 === 1) { 465 return arguments.length <= 1 ? undefined : arguments[1]; 466 } else if ((arguments.length <= 0 ? undefined : arguments[0]) % 10 === 2) { 467 return arguments.length <= 2 ? undefined : arguments[2]; 468 } else { 469 return arguments.length <= 3 ? undefined : arguments[3]; 470 } 471 }, function () { 472 return (arguments.length <= 0 ? undefined : arguments[0]) !== 11 && (arguments.length <= 0 ? undefined : arguments[0]) % 10 === 1 ? arguments.length <= 1 ? undefined : arguments[1] : arguments.length <= 2 ? undefined : arguments[2]; 473 }, function () { 474 if ((arguments.length <= 0 ? undefined : arguments[0]) === 1) { 475 return arguments.length <= 1 ? undefined : arguments[1]; 476 } else if ((arguments.length <= 0 ? undefined : arguments[0]) % 10 >= 2 && (arguments.length <= 0 ? undefined : arguments[0]) % 10 <= 4 && ((arguments.length <= 0 ? undefined : arguments[0]) % 100 < 10 || (arguments.length <= 0 ? undefined : arguments[0]) % 100 >= 20)) { 477 return arguments.length <= 2 ? undefined : arguments[2]; 478 } else { 479 return arguments.length <= 3 ? undefined : arguments[3]; 480 } 481 }, function () { 482 if ((arguments.length <= 0 ? undefined : arguments[0]) === 1) { 483 return arguments.length <= 1 ? undefined : arguments[1]; 484 } else if ((arguments.length <= 0 ? undefined : arguments[0]) === 2) { 485 return arguments.length <= 2 ? undefined : arguments[2]; 486 } else if ((arguments.length <= 0 ? undefined : arguments[0]) !== 8 && (arguments.length <= 0 ? undefined : arguments[0]) !== 11) { 487 return arguments.length <= 3 ? undefined : arguments[3]; 488 } else { 489 return arguments.length <= 4 ? undefined : arguments[4]; 490 } 491 }, function () { 492 return (arguments.length <= 0 ? undefined : arguments[0]) === 0 ? arguments.length <= 1 ? undefined : arguments[1] : arguments.length <= 2 ? undefined : arguments[2]; 493 }, function () { 494 if ((arguments.length <= 0 ? undefined : arguments[0]) === 1) { 495 return arguments.length <= 1 ? undefined : arguments[1]; 496 } else if ((arguments.length <= 0 ? undefined : arguments[0]) === 2) { 497 return arguments.length <= 2 ? undefined : arguments[2]; 498 } else if ((arguments.length <= 0 ? undefined : arguments[0]) === 3) { 499 return arguments.length <= 3 ? undefined : arguments[3]; 500 } else { 501 return arguments.length <= 4 ? undefined : arguments[4]; 502 } 503 }, function () { 504 if ((arguments.length <= 0 ? undefined : arguments[0]) === 0) { 505 return arguments.length <= 1 ? undefined : arguments[1]; 506 } else if ((arguments.length <= 0 ? undefined : arguments[0]) === 1) { 507 return arguments.length <= 2 ? undefined : arguments[2]; 508 } else { 509 return arguments.length <= 3 ? undefined : arguments[3]; 510 } 511 }]; 512 }(); 513 514 return _pluralForms[form].apply(null, [number].concat(input)); 515 }; 516 517 if (i18n[language] !== undefined) { 518 str = i18n[language][message]; 519 if (pluralParam !== null && typeof pluralParam === 'number') { 520 pluralForm = i18n[language]['mejs.plural-form']; 521 str = _plural.apply(null, [str, pluralParam, pluralForm]); 522 } 523 } 524 525 if (!str && i18n.en) { 526 str = i18n.en[message]; 527 if (pluralParam !== null && typeof pluralParam === 'number') { 528 pluralForm = i18n.en['mejs.plural-form']; 529 str = _plural.apply(null, [str, pluralParam, pluralForm]); 530 } 531 } 532 533 str = str || message; 534 535 if (pluralParam !== null && typeof pluralParam === 'number') { 536 str = str.replace('%1', pluralParam); 537 } 538 539 return (0, _general.escapeHTML)(str); 540 } 541 542 return message; 543 }; 544 545 _mejs2.default.i18n = i18n; 546 547 if (typeof mejsL10n !== 'undefined') { 548 _mejs2.default.i18n.language(mejsL10n.language, mejsL10n.strings); 549 } 550 551 exports.default = i18n; 552 553 },{"15":15,"27":27,"7":7}],6:[function(_dereq_,module,exports){ 554 'use strict'; 555 556 Object.defineProperty(exports, "__esModule", { 557 value: true 558 }); 559 560 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 561 562 var _window = _dereq_(3); 563 564 var _window2 = _interopRequireDefault(_window); 565 566 var _document = _dereq_(2); 567 568 var _document2 = _interopRequireDefault(_document); 569 570 var _mejs = _dereq_(7); 571 572 var _mejs2 = _interopRequireDefault(_mejs); 573 574 var _general = _dereq_(27); 575 576 var _media2 = _dereq_(28); 577 578 var _renderer = _dereq_(8); 579 580 var _constants = _dereq_(25); 581 582 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 583 584 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 585 586 var MediaElement = function MediaElement(idOrNode, options, sources) { 587 var _this = this; 588 589 _classCallCheck(this, MediaElement); 590 591 var t = this; 592 593 sources = Array.isArray(sources) ? sources : null; 594 595 t.defaults = { 596 renderers: [], 597 598 fakeNodeName: 'mediaelementwrapper', 599 600 pluginPath: 'build/', 601 602 shimScriptAccess: 'sameDomain' 603 }; 604 605 options = Object.assign(t.defaults, options); 606 607 t.mediaElement = _document2.default.createElement(options.fakeNodeName); 608 609 var id = idOrNode, 610 error = false; 611 612 if (typeof idOrNode === 'string') { 613 t.mediaElement.originalNode = _document2.default.getElementById(idOrNode); 614 } else { 615 t.mediaElement.originalNode = idOrNode; 616 id = idOrNode.id; 617 } 618 619 if (t.mediaElement.originalNode === undefined || t.mediaElement.originalNode === null) { 620 return null; 621 } 622 623 t.mediaElement.options = options; 624 id = id || 'mejs_' + Math.random().toString().slice(2); 625 626 t.mediaElement.originalNode.setAttribute('id', id + '_from_mejs'); 627 628 var tagName = t.mediaElement.originalNode.tagName.toLowerCase(); 629 if (['video', 'audio'].indexOf(tagName) > -1 && !t.mediaElement.originalNode.getAttribute('preload')) { 630 t.mediaElement.originalNode.setAttribute('preload', 'none'); 631 } 632 633 t.mediaElement.originalNode.parentNode.insertBefore(t.mediaElement, t.mediaElement.originalNode); 634 635 t.mediaElement.appendChild(t.mediaElement.originalNode); 636 637 var processURL = function processURL(url, type) { 638 if (_window2.default.location.protocol === 'https:' && url.indexOf('http:') === 0 && _constants.IS_IOS && _mejs2.default.html5media.mediaTypes.indexOf(type) > -1) { 639 var xhr = new XMLHttpRequest(); 640 xhr.onreadystatechange = function () { 641 if (this.readyState === 4 && this.status === 200) { 642 var _url = _window2.default.URL || _window2.default.webkitURL, 643 blobUrl = _url.createObjectURL(this.response); 644 t.mediaElement.originalNode.setAttribute('src', blobUrl); 645 return blobUrl; 646 } 647 return url; 648 }; 649 xhr.open('GET', url); 650 xhr.responseType = 'blob'; 651 xhr.send(); 652 } 653 654 return url; 655 }; 656 657 var mediaFiles = void 0; 658 659 if (sources !== null) { 660 mediaFiles = sources; 661 } else if (t.mediaElement.originalNode !== null) { 662 663 mediaFiles = []; 664 665 switch (t.mediaElement.originalNode.nodeName.toLowerCase()) { 666 case 'iframe': 667 mediaFiles.push({ 668 type: '', 669 src: t.mediaElement.originalNode.getAttribute('src') 670 }); 671 break; 672 case 'audio': 673 case 'video': 674 var _sources = t.mediaElement.originalNode.children.length, 675 nodeSource = t.mediaElement.originalNode.getAttribute('src'); 676 677 if (nodeSource) { 678 var node = t.mediaElement.originalNode, 679 type = (0, _media2.formatType)(nodeSource, node.getAttribute('type')); 680 mediaFiles.push({ 681 type: type, 682 src: processURL(nodeSource, type) 683 }); 684 } 685 686 for (var i = 0; i < _sources; i++) { 687 var n = t.mediaElement.originalNode.children[i]; 688 if (n.tagName.toLowerCase() === 'source') { 689 var src = n.getAttribute('src'), 690 _type = (0, _media2.formatType)(src, n.getAttribute('type')); 691 mediaFiles.push({ type: _type, src: processURL(src, _type) }); 692 } 693 } 694 break; 695 } 696 } 697 698 t.mediaElement.id = id; 699 t.mediaElement.renderers = {}; 700 t.mediaElement.events = {}; 701 t.mediaElement.promises = []; 702 t.mediaElement.renderer = null; 703 t.mediaElement.rendererName = null; 704 705 t.mediaElement.changeRenderer = function (rendererName, mediaFiles) { 706 707 var t = _this, 708 media = Object.keys(mediaFiles[0]).length > 2 ? mediaFiles[0] : mediaFiles[0].src; 709 710 if (t.mediaElement.renderer !== undefined && t.mediaElement.renderer !== null && t.mediaElement.renderer.name === rendererName) { 711 t.mediaElement.renderer.pause(); 712 if (t.mediaElement.renderer.stop) { 713 t.mediaElement.renderer.stop(); 714 } 715 t.mediaElement.renderer.show(); 716 t.mediaElement.renderer.setSrc(media); 717 return true; 718 } 719 720 if (t.mediaElement.renderer !== undefined && t.mediaElement.renderer !== null) { 721 t.mediaElement.renderer.pause(); 722 if (t.mediaElement.renderer.stop) { 723 t.mediaElement.renderer.stop(); 724 } 725 t.mediaElement.renderer.hide(); 726 } 727 728 var newRenderer = t.mediaElement.renderers[rendererName], 729 newRendererType = null; 730 731 if (newRenderer !== undefined && newRenderer !== null) { 732 newRenderer.show(); 733 newRenderer.setSrc(media); 734 t.mediaElement.renderer = newRenderer; 735 t.mediaElement.rendererName = rendererName; 736 return true; 737 } 738 739 var rendererArray = t.mediaElement.options.renderers.length ? t.mediaElement.options.renderers : _renderer.renderer.order; 740 741 for (var _i = 0, total = rendererArray.length; _i < total; _i++) { 742 var index = rendererArray[_i]; 743 744 if (index === rendererName) { 745 var rendererList = _renderer.renderer.renderers; 746 newRendererType = rendererList[index]; 747 748 var renderOptions = Object.assign(newRendererType.options, t.mediaElement.options); 749 newRenderer = newRendererType.create(t.mediaElement, renderOptions, mediaFiles); 750 newRenderer.name = rendererName; 751 752 t.mediaElement.renderers[newRendererType.name] = newRenderer; 753 t.mediaElement.renderer = newRenderer; 754 t.mediaElement.rendererName = rendererName; 755 newRenderer.show(); 756 return true; 757 } 758 } 759 760 return false; 761 }; 762 763 t.mediaElement.setSize = function (width, height) { 764 if (t.mediaElement.renderer !== undefined && t.mediaElement.renderer !== null) { 765 t.mediaElement.renderer.setSize(width, height); 766 } 767 }; 768 769 t.mediaElement.generateError = function (message, urlList) { 770 message = message || ''; 771 urlList = Array.isArray(urlList) ? urlList : []; 772 var event = (0, _general.createEvent)('error', t.mediaElement); 773 event.message = message; 774 event.urls = urlList; 775 t.mediaElement.dispatchEvent(event); 776 error = true; 777 }; 778 779 var props = _mejs2.default.html5media.properties, 780 methods = _mejs2.default.html5media.methods, 781 addProperty = function addProperty(obj, name, onGet, onSet) { 782 var oldValue = obj[name]; 783 var getFn = function getFn() { 784 return onGet.apply(obj, [oldValue]); 785 }, 786 setFn = function setFn(newValue) { 787 oldValue = onSet.apply(obj, [newValue]); 788 return oldValue; 789 }; 790 791 Object.defineProperty(obj, name, { 792 get: getFn, 793 set: setFn 794 }); 795 }, 796 assignGettersSetters = function assignGettersSetters(propName) { 797 if (propName !== 'src') { 798 799 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1), 800 getFn = function getFn() { 801 return t.mediaElement.renderer !== undefined && t.mediaElement.renderer !== null && typeof t.mediaElement.renderer['get' + capName] === 'function' ? t.mediaElement.renderer['get' + capName]() : null; 802 }, 803 setFn = function setFn(value) { 804 if (t.mediaElement.renderer !== undefined && t.mediaElement.renderer !== null && typeof t.mediaElement.renderer['set' + capName] === 'function') { 805 t.mediaElement.renderer['set' + capName](value); 806 } 807 }; 808 809 addProperty(t.mediaElement, propName, getFn, setFn); 810 t.mediaElement['get' + capName] = getFn; 811 t.mediaElement['set' + capName] = setFn; 812 } 813 }, 814 getSrc = function getSrc() { 815 return t.mediaElement.renderer !== undefined && t.mediaElement.renderer !== null ? t.mediaElement.renderer.getSrc() : null; 816 }, 817 setSrc = function setSrc(value) { 818 var mediaFiles = []; 819 820 if (typeof value === 'string') { 821 mediaFiles.push({ 822 src: value, 823 type: value ? (0, _media2.getTypeFromFile)(value) : '' 824 }); 825 } else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src !== undefined) { 826 var _src = (0, _media2.absolutizeUrl)(value.src), 827 _type2 = value.type, 828 media = Object.assign(value, { 829 src: _src, 830 type: (_type2 === '' || _type2 === null || _type2 === undefined) && _src ? (0, _media2.getTypeFromFile)(_src) : _type2 831 }); 832 mediaFiles.push(media); 833 } else if (Array.isArray(value)) { 834 for (var _i2 = 0, total = value.length; _i2 < total; _i2++) { 835 836 var _src2 = (0, _media2.absolutizeUrl)(value[_i2].src), 837 _type3 = value[_i2].type, 838 _media = Object.assign(value[_i2], { 839 src: _src2, 840 type: (_type3 === '' || _type3 === null || _type3 === undefined) && _src2 ? (0, _media2.getTypeFromFile)(_src2) : _type3 841 }); 842 843 mediaFiles.push(_media); 844 } 845 } 846 847 var renderInfo = _renderer.renderer.select(mediaFiles, t.mediaElement.options.renderers.length ? t.mediaElement.options.renderers : []), 848 event = void 0; 849 850 if (!t.mediaElement.paused && !(t.mediaElement.src == null || t.mediaElement.src === '')) { 851 t.mediaElement.pause(); 852 event = (0, _general.createEvent)('pause', t.mediaElement); 853 t.mediaElement.dispatchEvent(event); 854 } 855 t.mediaElement.originalNode.src = mediaFiles[0].src || ''; 856 857 if (renderInfo === null && mediaFiles[0].src) { 858 t.mediaElement.generateError('No renderer found', mediaFiles); 859 return; 860 } 861 862 var shouldChangeRenderer = !(mediaFiles[0].src == null || mediaFiles[0].src === ''); 863 return shouldChangeRenderer ? t.mediaElement.changeRenderer(renderInfo.rendererName, mediaFiles) : null; 864 }, 865 triggerAction = function triggerAction(methodName, args) { 866 try { 867 if (methodName === 'play' && (t.mediaElement.rendererName === 'native_dash' || t.mediaElement.rendererName === 'native_hls' || t.mediaElement.rendererName === 'vimeo_iframe')) { 868 var response = t.mediaElement.renderer[methodName](args); 869 if (response && typeof response.then === 'function') { 870 response.catch(function () { 871 if (t.mediaElement.paused) { 872 setTimeout(function () { 873 var tmpResponse = t.mediaElement.renderer.play(); 874 if (tmpResponse !== undefined) { 875 tmpResponse.catch(function () { 876 if (!t.mediaElement.renderer.paused) { 877 t.mediaElement.renderer.pause(); 878 } 879 }); 880 } 881 }, 150); 882 } 883 }); 884 } 885 } else { 886 t.mediaElement.renderer[methodName](args); 887 } 888 } catch (e) { 889 t.mediaElement.generateError(e, mediaFiles); 890 } 891 }, 892 assignMethods = function assignMethods(methodName) { 893 t.mediaElement[methodName] = function () { 894 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { 895 args[_key] = arguments[_key]; 896 } 897 898 if (t.mediaElement.renderer !== undefined && t.mediaElement.renderer !== null && typeof t.mediaElement.renderer[methodName] === 'function') { 899 if (t.mediaElement.promises.length) { 900 Promise.all(t.mediaElement.promises).then(function () { 901 triggerAction(methodName, args); 902 }).catch(function (e) { 903 t.mediaElement.generateError(e, mediaFiles); 904 }); 905 } else { 906 triggerAction(methodName, args); 907 } 908 } 909 return null; 910 }; 911 }; 912 913 addProperty(t.mediaElement, 'src', getSrc, setSrc); 914 t.mediaElement.getSrc = getSrc; 915 t.mediaElement.setSrc = setSrc; 916 917 for (var _i3 = 0, total = props.length; _i3 < total; _i3++) { 918 assignGettersSetters(props[_i3]); 919 } 920 921 for (var _i4 = 0, _total = methods.length; _i4 < _total; _i4++) { 922 assignMethods(methods[_i4]); 923 } 924 925 t.mediaElement.addEventListener = function (eventName, callback) { 926 t.mediaElement.events[eventName] = t.mediaElement.events[eventName] || []; 927 928 t.mediaElement.events[eventName].push(callback); 929 }; 930 t.mediaElement.removeEventListener = function (eventName, callback) { 931 if (!eventName) { 932 t.mediaElement.events = {}; 933 return true; 934 } 935 936 var callbacks = t.mediaElement.events[eventName]; 937 938 if (!callbacks) { 939 return true; 940 } 941 942 if (!callback) { 943 t.mediaElement.events[eventName] = []; 944 return true; 945 } 946 947 for (var _i5 = 0; _i5 < callbacks.length; _i5++) { 948 if (callbacks[_i5] === callback) { 949 t.mediaElement.events[eventName].splice(_i5, 1); 950 return true; 951 } 952 } 953 return false; 954 }; 955 956 t.mediaElement.dispatchEvent = function (event) { 957 var callbacks = t.mediaElement.events[event.type]; 958 if (callbacks) { 959 for (var _i6 = 0; _i6 < callbacks.length; _i6++) { 960 callbacks[_i6].apply(null, [event]); 961 } 962 } 963 }; 964 965 t.mediaElement.destroy = function () { 966 var mediaElement = t.mediaElement.originalNode.cloneNode(true); 967 var wrapper = t.mediaElement.parentElement; 968 mediaElement.removeAttribute('id'); 969 mediaElement.remove(); 970 t.mediaElement.remove(); 971 wrapper.appendChild(mediaElement); 972 }; 973 974 if (mediaFiles.length) { 975 t.mediaElement.src = mediaFiles; 976 } 977 978 if (t.mediaElement.promises.length) { 979 Promise.all(t.mediaElement.promises).then(function () { 980 if (t.mediaElement.options.success) { 981 t.mediaElement.options.success(t.mediaElement, t.mediaElement.originalNode); 982 } 983 }).catch(function () { 984 if (error && t.mediaElement.options.error) { 985 t.mediaElement.options.error(t.mediaElement, t.mediaElement.originalNode); 986 } 987 }); 988 } else { 989 if (t.mediaElement.options.success) { 990 t.mediaElement.options.success(t.mediaElement, t.mediaElement.originalNode); 991 } 992 993 if (error && t.mediaElement.options.error) { 994 t.mediaElement.options.error(t.mediaElement, t.mediaElement.originalNode); 995 } 996 } 997 998 return t.mediaElement; 999 }; 1000 1001 _window2.default.MediaElement = MediaElement; 1002 _mejs2.default.MediaElement = MediaElement; 1003 1004 exports.default = MediaElement; 1005 1006 },{"2":2,"25":25,"27":27,"28":28,"3":3,"7":7,"8":8}],7:[function(_dereq_,module,exports){ 1007 'use strict'; 1008 1009 Object.defineProperty(exports, "__esModule", { 1010 value: true 1011 }); 1012 1013 var _window = _dereq_(3); 1014 1015 var _window2 = _interopRequireDefault(_window); 1016 1017 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1018 1019 var mejs = {}; 1020 1021 mejs.version = '4.2.17'; 1022 1023 mejs.html5media = { 1024 properties: ['volume', 'src', 'currentTime', 'muted', 'duration', 'paused', 'ended', 'buffered', 'error', 'networkState', 'readyState', 'seeking', 'seekable', 'currentSrc', 'preload', 'bufferedBytes', 'bufferedTime', 'initialTime', 'startOffsetTime', 'defaultPlaybackRate', 'playbackRate', 'played', 'autoplay', 'loop', 'controls'], 1025 readOnlyProperties: ['duration', 'paused', 'ended', 'buffered', 'error', 'networkState', 'readyState', 'seeking', 'seekable'], 1026 1027 methods: ['load', 'play', 'pause', 'canPlayType'], 1028 1029 events: ['loadstart', 'durationchange', 'loadedmetadata', 'loadeddata', 'progress', 'canplay', 'canplaythrough', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'play', 'playing', 'pause', 'waiting', 'seeking', 'seeked', 'timeupdate', 'ended', 'ratechange', 'volumechange'], 1030 1031 mediaTypes: ['audio/mp3', 'audio/ogg', 'audio/oga', 'audio/wav', 'audio/x-wav', 'audio/wave', 'audio/x-pn-wav', 'audio/mpeg', 'audio/mp4', 'video/mp4', 'video/webm', 'video/ogg', 'video/ogv'] 1032 }; 1033 1034 _window2.default.mejs = mejs; 1035 1036 exports.default = mejs; 1037 1038 },{"3":3}],8:[function(_dereq_,module,exports){ 1039 'use strict'; 1040 1041 Object.defineProperty(exports, "__esModule", { 1042 value: true 1043 }); 1044 exports.renderer = undefined; 1045 1046 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 1047 1048 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; }; }(); 1049 1050 var _mejs = _dereq_(7); 1051 1052 var _mejs2 = _interopRequireDefault(_mejs); 1053 1054 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1055 1056 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 1057 1058 var Renderer = function () { 1059 function Renderer() { 1060 _classCallCheck(this, Renderer); 1061 1062 this.renderers = {}; 1063 this.order = []; 1064 } 1065 1066 _createClass(Renderer, [{ 1067 key: 'add', 1068 value: function add(renderer) { 1069 if (renderer.name === undefined) { 1070 throw new TypeError('renderer must contain at least `name` property'); 1071 } 1072 1073 this.renderers[renderer.name] = renderer; 1074 this.order.push(renderer.name); 1075 } 1076 }, { 1077 key: 'select', 1078 value: function select(mediaFiles) { 1079 var renderers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; 1080 1081 var renderersLength = renderers.length; 1082 1083 renderers = renderers.length ? renderers : this.order; 1084 1085 if (!renderersLength) { 1086 var rendererIndicator = [/^(html5|native)/i, /^flash/i, /iframe$/i], 1087 rendererRanking = function rendererRanking(renderer) { 1088 for (var i = 0, total = rendererIndicator.length; i < total; i++) { 1089 if (rendererIndicator[i].test(renderer)) { 1090 return i; 1091 } 1092 } 1093 return rendererIndicator.length; 1094 }; 1095 1096 renderers.sort(function (a, b) { 1097 return rendererRanking(a) - rendererRanking(b); 1098 }); 1099 } 1100 1101 for (var i = 0, total = renderers.length; i < total; i++) { 1102 var key = renderers[i], 1103 _renderer = this.renderers[key]; 1104 1105 if (_renderer !== null && _renderer !== undefined) { 1106 for (var j = 0, jl = mediaFiles.length; j < jl; j++) { 1107 if (typeof _renderer.canPlayType === 'function' && typeof mediaFiles[j].type === 'string' && _renderer.canPlayType(mediaFiles[j].type)) { 1108 return { 1109 rendererName: _renderer.name, 1110 src: mediaFiles[j].src 1111 }; 1112 } 1113 } 1114 } 1115 } 1116 1117 return null; 1118 } 1119 }, { 1120 key: 'order', 1121 set: function set(order) { 1122 if (!Array.isArray(order)) { 1123 throw new TypeError('order must be an array of strings.'); 1124 } 1125 1126 this._order = order; 1127 }, 1128 get: function get() { 1129 return this._order; 1130 } 1131 }, { 1132 key: 'renderers', 1133 set: function set(renderers) { 1134 if (renderers !== null && (typeof renderers === 'undefined' ? 'undefined' : _typeof(renderers)) !== 'object') { 1135 throw new TypeError('renderers must be an array of objects.'); 1136 } 1137 1138 this._renderers = renderers; 1139 }, 1140 get: function get() { 1141 return this._renderers; 1142 } 1143 }]); 1144 1145 return Renderer; 1146 }(); 1147 1148 var renderer = exports.renderer = new Renderer(); 1149 1150 _mejs2.default.Renderers = renderer; 1151 1152 },{"7":7}],9:[function(_dereq_,module,exports){ 1153 'use strict'; 1154 1155 var _window = _dereq_(3); 1156 1157 var _window2 = _interopRequireDefault(_window); 1158 1159 var _document = _dereq_(2); 1160 1161 var _document2 = _interopRequireDefault(_document); 1162 1163 var _i18n = _dereq_(5); 1164 1165 var _i18n2 = _interopRequireDefault(_i18n); 1166 1167 var _player = _dereq_(16); 1168 1169 var _player2 = _interopRequireDefault(_player); 1170 1171 var _constants = _dereq_(25); 1172 1173 var Features = _interopRequireWildcard(_constants); 1174 1175 var _general = _dereq_(27); 1176 1177 var _dom = _dereq_(26); 1178 1179 var _media = _dereq_(28); 1180 1181 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } 1182 1183 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1184 1185 Object.assign(_player.config, { 1186 usePluginFullScreen: true, 1187 1188 fullscreenText: null, 1189 1190 useFakeFullscreen: false 1191 }); 1192 1193 Object.assign(_player2.default.prototype, { 1194 isFullScreen: false, 1195 1196 isNativeFullScreen: false, 1197 1198 isInIframe: false, 1199 1200 isPluginClickThroughCreated: false, 1201 1202 fullscreenMode: '', 1203 1204 containerSizeTimeout: null, 1205 1206 buildfullscreen: function buildfullscreen(player) { 1207 if (!player.isVideo) { 1208 return; 1209 } 1210 1211 player.isInIframe = _window2.default.location !== _window2.default.parent.location; 1212 1213 player.detectFullscreenMode(); 1214 1215 var t = this, 1216 fullscreenTitle = (0, _general.isString)(t.options.fullscreenText) ? t.options.fullscreenText : _i18n2.default.t('mejs.fullscreen'), 1217 fullscreenBtn = _document2.default.createElement('div'); 1218 1219 fullscreenBtn.className = t.options.classPrefix + 'button ' + t.options.classPrefix + 'fullscreen-button'; 1220 fullscreenBtn.innerHTML = '<button type="button" aria-controls="' + t.id + '" title="' + fullscreenTitle + '" aria-label="' + fullscreenTitle + '" tabindex="0"></button>'; 1221 t.addControlElement(fullscreenBtn, 'fullscreen'); 1222 1223 fullscreenBtn.addEventListener('click', function () { 1224 var isFullScreen = Features.HAS_TRUE_NATIVE_FULLSCREEN && Features.IS_FULLSCREEN || player.isFullScreen; 1225 1226 if (isFullScreen) { 1227 player.exitFullScreen(); 1228 } else { 1229 player.enterFullScreen(); 1230 } 1231 }); 1232 1233 player.fullscreenBtn = fullscreenBtn; 1234 1235 t.options.keyActions.push({ 1236 keys: [70], 1237 action: function action(player, media, key, event) { 1238 if (!event.ctrlKey) { 1239 if (typeof player.enterFullScreen !== 'undefined') { 1240 if (player.isFullScreen) { 1241 player.exitFullScreen(); 1242 } else { 1243 player.enterFullScreen(); 1244 } 1245 } 1246 } 1247 } 1248 }); 1249 1250 t.exitFullscreenCallback = function (e) { 1251 var key = e.which || e.keyCode || 0; 1252 if (t.options.enableKeyboard && key === 27 && (Features.HAS_TRUE_NATIVE_FULLSCREEN && Features.IS_FULLSCREEN || t.isFullScreen)) { 1253 player.exitFullScreen(); 1254 } 1255 }; 1256 1257 t.globalBind('keydown', t.exitFullscreenCallback); 1258 1259 t.normalHeight = 0; 1260 t.normalWidth = 0; 1261 1262 if (Features.HAS_TRUE_NATIVE_FULLSCREEN) { 1263 var fullscreenChanged = function fullscreenChanged() { 1264 if (player.isFullScreen) { 1265 if (Features.isFullScreen()) { 1266 player.isNativeFullScreen = true; 1267 1268 player.setControlsSize(); 1269 } else { 1270 player.isNativeFullScreen = false; 1271 1272 player.exitFullScreen(); 1273 } 1274 } 1275 }; 1276 1277 player.globalBind(Features.FULLSCREEN_EVENT_NAME, fullscreenChanged); 1278 } 1279 }, 1280 cleanfullscreen: function cleanfullscreen(player) { 1281 player.exitFullScreen(); 1282 player.globalUnbind('keydown', player.exitFullscreenCallback); 1283 }, 1284 detectFullscreenMode: function detectFullscreenMode() { 1285 var t = this, 1286 isNative = t.media.rendererName !== null && /(native|html5)/i.test(t.media.rendererName); 1287 1288 var mode = ''; 1289 1290 if (Features.HAS_TRUE_NATIVE_FULLSCREEN && isNative) { 1291 mode = 'native-native'; 1292 } else if (Features.HAS_TRUE_NATIVE_FULLSCREEN && !isNative) { 1293 mode = 'plugin-native'; 1294 } else if (t.usePluginFullScreen && Features.SUPPORT_POINTER_EVENTS) { 1295 mode = 'plugin-click'; 1296 } 1297 1298 t.fullscreenMode = mode; 1299 return mode; 1300 }, 1301 enterFullScreen: function enterFullScreen() { 1302 var t = this, 1303 isNative = t.media.rendererName !== null && /(html5|native)/i.test(t.media.rendererName), 1304 containerStyles = getComputedStyle(t.getElement(t.container)); 1305 1306 if (!t.isVideo) { 1307 return; 1308 } 1309 1310 if (t.options.useFakeFullscreen === false && (Features.IS_IOS || Features.IS_SAFARI) && Features.HAS_IOS_FULLSCREEN && typeof t.media.originalNode.webkitEnterFullscreen === 'function' && t.media.originalNode.canPlayType((0, _media.getTypeFromFile)(t.media.getSrc()))) { 1311 t.media.originalNode.webkitEnterFullscreen(); 1312 return; 1313 } 1314 1315 (0, _dom.addClass)(_document2.default.documentElement, t.options.classPrefix + 'fullscreen'); 1316 (0, _dom.addClass)(t.getElement(t.container), t.options.classPrefix + 'container-fullscreen'); 1317 1318 t.normalHeight = parseFloat(containerStyles.height); 1319 t.normalWidth = parseFloat(containerStyles.width); 1320 1321 if (t.fullscreenMode === 'native-native' || t.fullscreenMode === 'plugin-native') { 1322 Features.requestFullScreen(t.getElement(t.container)); 1323 1324 if (t.isInIframe) { 1325 setTimeout(function checkFullscreen() { 1326 1327 if (t.isNativeFullScreen) { 1328 var percentErrorMargin = 0.002, 1329 windowWidth = _window2.default.innerWidth || _document2.default.documentElement.clientWidth || _document2.default.body.clientWidth, 1330 screenWidth = screen.width, 1331 absDiff = Math.abs(screenWidth - windowWidth), 1332 marginError = screenWidth * percentErrorMargin; 1333 1334 if (absDiff > marginError) { 1335 t.exitFullScreen(); 1336 } else { 1337 setTimeout(checkFullscreen, 500); 1338 } 1339 } 1340 }, 1000); 1341 } 1342 } 1343 1344 t.getElement(t.container).style.width = '100%'; 1345 t.getElement(t.container).style.height = '100%'; 1346 1347 t.containerSizeTimeout = setTimeout(function () { 1348 t.getElement(t.container).style.width = '100%'; 1349 t.getElement(t.container).style.height = '100%'; 1350 t.setControlsSize(); 1351 }, 500); 1352 1353 if (isNative) { 1354 t.node.style.width = '100%'; 1355 t.node.style.height = '100%'; 1356 } else { 1357 var elements = t.getElement(t.container).querySelectorAll('embed, object, video'), 1358 _total = elements.length; 1359 for (var i = 0; i < _total; i++) { 1360 elements[i].style.width = '100%'; 1361 elements[i].style.height = '100%'; 1362 } 1363 } 1364 1365 if (t.options.setDimensions && typeof t.media.setSize === 'function') { 1366 t.media.setSize(screen.width, screen.height); 1367 } 1368 1369 var layers = t.getElement(t.layers).children, 1370 total = layers.length; 1371 for (var _i = 0; _i < total; _i++) { 1372 layers[_i].style.width = '100%'; 1373 layers[_i].style.height = '100%'; 1374 } 1375 1376 if (t.fullscreenBtn) { 1377 (0, _dom.removeClass)(t.fullscreenBtn, t.options.classPrefix + 'fullscreen'); 1378 (0, _dom.addClass)(t.fullscreenBtn, t.options.classPrefix + 'unfullscreen'); 1379 } 1380 1381 t.setControlsSize(); 1382 t.isFullScreen = true; 1383 1384 var zoomFactor = Math.min(screen.width / t.width, screen.height / t.height), 1385 captionText = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'captions-text'); 1386 if (captionText) { 1387 captionText.style.fontSize = zoomFactor * 100 + '%'; 1388 captionText.style.lineHeight = 'normal'; 1389 t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'captions-position').style.bottom = (screen.height - t.normalHeight) / 2 - t.getElement(t.controls).offsetHeight / 2 + zoomFactor + 15 + 'px'; 1390 } 1391 var event = (0, _general.createEvent)('enteredfullscreen', t.getElement(t.container)); 1392 t.getElement(t.container).dispatchEvent(event); 1393 }, 1394 exitFullScreen: function exitFullScreen() { 1395 var t = this, 1396 isNative = t.media.rendererName !== null && /(native|html5)/i.test(t.media.rendererName); 1397 1398 if (!t.isVideo) { 1399 return; 1400 } 1401 1402 clearTimeout(t.containerSizeTimeout); 1403 1404 if (Features.HAS_TRUE_NATIVE_FULLSCREEN && (Features.IS_FULLSCREEN || t.isFullScreen)) { 1405 Features.cancelFullScreen(); 1406 } 1407 1408 (0, _dom.removeClass)(_document2.default.documentElement, t.options.classPrefix + 'fullscreen'); 1409 (0, _dom.removeClass)(t.getElement(t.container), t.options.classPrefix + 'container-fullscreen'); 1410 1411 if (t.options.setDimensions) { 1412 t.getElement(t.container).style.width = t.normalWidth + 'px'; 1413 t.getElement(t.container).style.height = t.normalHeight + 'px'; 1414 1415 if (isNative) { 1416 t.node.style.width = t.normalWidth + 'px'; 1417 t.node.style.height = t.normalHeight + 'px'; 1418 } else { 1419 var elements = t.getElement(t.container).querySelectorAll('embed, object, video'), 1420 _total2 = elements.length; 1421 for (var i = 0; i < _total2; i++) { 1422 elements[i].style.width = t.normalWidth + 'px'; 1423 elements[i].style.height = t.normalHeight + 'px'; 1424 } 1425 } 1426 1427 if (typeof t.media.setSize === 'function') { 1428 t.media.setSize(t.normalWidth, t.normalHeight); 1429 } 1430 1431 var layers = t.getElement(t.layers).children, 1432 total = layers.length; 1433 for (var _i2 = 0; _i2 < total; _i2++) { 1434 layers[_i2].style.width = t.normalWidth + 'px'; 1435 layers[_i2].style.height = t.normalHeight + 'px'; 1436 } 1437 } 1438 1439 if (t.fullscreenBtn) { 1440 (0, _dom.removeClass)(t.fullscreenBtn, t.options.classPrefix + 'unfullscreen'); 1441 (0, _dom.addClass)(t.fullscreenBtn, t.options.classPrefix + 'fullscreen'); 1442 } 1443 1444 t.setControlsSize(); 1445 t.isFullScreen = false; 1446 1447 var captionText = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'captions-text'); 1448 if (captionText) { 1449 captionText.style.fontSize = ''; 1450 captionText.style.lineHeight = ''; 1451 t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'captions-position').style.bottom = ''; 1452 } 1453 var event = (0, _general.createEvent)('exitedfullscreen', t.getElement(t.container)); 1454 t.getElement(t.container).dispatchEvent(event); 1455 } 1456 }); 1457 1458 },{"16":16,"2":2,"25":25,"26":26,"27":27,"28":28,"3":3,"5":5}],10:[function(_dereq_,module,exports){ 1459 'use strict'; 1460 1461 var _document = _dereq_(2); 1462 1463 var _document2 = _interopRequireDefault(_document); 1464 1465 var _player = _dereq_(16); 1466 1467 var _player2 = _interopRequireDefault(_player); 1468 1469 var _i18n = _dereq_(5); 1470 1471 var _i18n2 = _interopRequireDefault(_i18n); 1472 1473 var _general = _dereq_(27); 1474 1475 var _dom = _dereq_(26); 1476 1477 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1478 1479 Object.assign(_player.config, { 1480 playText: null, 1481 1482 pauseText: null 1483 }); 1484 1485 Object.assign(_player2.default.prototype, { 1486 buildplaypause: function buildplaypause(player, controls, layers, media) { 1487 var t = this, 1488 op = t.options, 1489 playTitle = (0, _general.isString)(op.playText) ? op.playText : _i18n2.default.t('mejs.play'), 1490 pauseTitle = (0, _general.isString)(op.pauseText) ? op.pauseText : _i18n2.default.t('mejs.pause'), 1491 play = _document2.default.createElement('div'); 1492 1493 play.className = t.options.classPrefix + 'button ' + t.options.classPrefix + 'playpause-button ' + t.options.classPrefix + 'play'; 1494 play.innerHTML = '<button type="button" aria-controls="' + t.id + '" title="' + playTitle + '" aria-label="' + pauseTitle + '" tabindex="0"></button>'; 1495 play.addEventListener('click', function () { 1496 if (t.paused) { 1497 t.play(); 1498 } else { 1499 t.pause(); 1500 } 1501 }); 1502 1503 var playBtn = play.querySelector('button'); 1504 t.addControlElement(play, 'playpause'); 1505 1506 function togglePlayPause(which) { 1507 if ('play' === which) { 1508 (0, _dom.removeClass)(play, t.options.classPrefix + 'play'); 1509 (0, _dom.removeClass)(play, t.options.classPrefix + 'replay'); 1510 (0, _dom.addClass)(play, t.options.classPrefix + 'pause'); 1511 playBtn.setAttribute('title', pauseTitle); 1512 playBtn.setAttribute('aria-label', pauseTitle); 1513 } else { 1514 1515 (0, _dom.removeClass)(play, t.options.classPrefix + 'pause'); 1516 (0, _dom.removeClass)(play, t.options.classPrefix + 'replay'); 1517 (0, _dom.addClass)(play, t.options.classPrefix + 'play'); 1518 playBtn.setAttribute('title', playTitle); 1519 playBtn.setAttribute('aria-label', playTitle); 1520 } 1521 } 1522 1523 togglePlayPause('pse'); 1524 1525 media.addEventListener('loadedmetadata', function () { 1526 if (media.rendererName.indexOf('flash') === -1) { 1527 togglePlayPause('pse'); 1528 } 1529 }); 1530 media.addEventListener('play', function () { 1531 togglePlayPause('play'); 1532 }); 1533 media.addEventListener('playing', function () { 1534 togglePlayPause('play'); 1535 }); 1536 media.addEventListener('pause', function () { 1537 togglePlayPause('pse'); 1538 }); 1539 media.addEventListener('ended', function () { 1540 if (!player.options.loop) { 1541 (0, _dom.removeClass)(play, t.options.classPrefix + 'pause'); 1542 (0, _dom.removeClass)(play, t.options.classPrefix + 'play'); 1543 (0, _dom.addClass)(play, t.options.classPrefix + 'replay'); 1544 playBtn.setAttribute('title', playTitle); 1545 playBtn.setAttribute('aria-label', playTitle); 1546 } 1547 }); 1548 } 1549 }); 1550 1551 },{"16":16,"2":2,"26":26,"27":27,"5":5}],11:[function(_dereq_,module,exports){ 1552 'use strict'; 1553 1554 var _document = _dereq_(2); 1555 1556 var _document2 = _interopRequireDefault(_document); 1557 1558 var _player = _dereq_(16); 1559 1560 var _player2 = _interopRequireDefault(_player); 1561 1562 var _i18n = _dereq_(5); 1563 1564 var _i18n2 = _interopRequireDefault(_i18n); 1565 1566 var _constants = _dereq_(25); 1567 1568 var _time = _dereq_(30); 1569 1570 var _dom = _dereq_(26); 1571 1572 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1573 1574 Object.assign(_player.config, { 1575 enableProgressTooltip: true, 1576 1577 useSmoothHover: true, 1578 1579 forceLive: false 1580 }); 1581 1582 Object.assign(_player2.default.prototype, { 1583 buildprogress: function buildprogress(player, controls, layers, media) { 1584 1585 var lastKeyPressTime = 0, 1586 mouseIsDown = false, 1587 startedPaused = false; 1588 1589 var t = this, 1590 autoRewindInitial = player.options.autoRewind, 1591 tooltip = player.options.enableProgressTooltip ? '<span class="' + t.options.classPrefix + 'time-float">' + ('<span class="' + t.options.classPrefix + 'time-float-current">00:00</span>') + ('<span class="' + t.options.classPrefix + 'time-float-corner"></span>') + '</span>' : '', 1592 rail = _document2.default.createElement('div'); 1593 1594 rail.className = t.options.classPrefix + 'time-rail'; 1595 rail.innerHTML = '<span class="' + t.options.classPrefix + 'time-total ' + t.options.classPrefix + 'time-slider">' + ('<span class="' + t.options.classPrefix + 'time-buffering"></span>') + ('<span class="' + t.options.classPrefix + 'time-loaded"></span>') + ('<span class="' + t.options.classPrefix + 'time-current"></span>') + ('<span class="' + t.options.classPrefix + 'time-hovered no-hover"></span>') + ('<span class="' + t.options.classPrefix + 'time-handle"><span class="' + t.options.classPrefix + 'time-handle-content"></span></span>') + ('' + tooltip) + '</span>'; 1596 1597 t.addControlElement(rail, 'progress'); 1598 1599 t.options.keyActions.push({ 1600 keys: [37, 227], 1601 action: function action(player) { 1602 if (!isNaN(player.duration) && player.duration > 0) { 1603 if (player.isVideo) { 1604 player.showControls(); 1605 player.startControlsTimer(); 1606 } 1607 1608 var timeSlider = player.getElement(player.container).querySelector('.' + t.options.classPrefix + 'time-total'); 1609 if (timeSlider) { 1610 timeSlider.focus(); 1611 } 1612 1613 var newTime = Math.max(player.currentTime - player.options.defaultSeekBackwardInterval(player), 0); 1614 1615 if (!player.paused) { 1616 player.pause(); 1617 } 1618 1619 setTimeout(function () { 1620 player.setCurrentTime(newTime); 1621 }, 0); 1622 1623 setTimeout(function () { 1624 player.play(); 1625 }, 0); 1626 } 1627 } 1628 }, { 1629 keys: [39, 228], 1630 action: function action(player) { 1631 1632 if (!isNaN(player.duration) && player.duration > 0) { 1633 if (player.isVideo) { 1634 player.showControls(); 1635 player.startControlsTimer(); 1636 } 1637 1638 var timeSlider = player.getElement(player.container).querySelector('.' + t.options.classPrefix + 'time-total'); 1639 if (timeSlider) { 1640 timeSlider.focus(); 1641 } 1642 1643 var newTime = Math.min(player.currentTime + player.options.defaultSeekForwardInterval(player), player.duration); 1644 1645 if (!player.paused) { 1646 player.pause(); 1647 } 1648 1649 setTimeout(function () { 1650 player.setCurrentTime(newTime); 1651 }, 0); 1652 1653 setTimeout(function () { 1654 player.play(); 1655 }, 0); 1656 } 1657 } 1658 }); 1659 1660 t.rail = controls.querySelector('.' + t.options.classPrefix + 'time-rail'); 1661 t.total = controls.querySelector('.' + t.options.classPrefix + 'time-total'); 1662 t.loaded = controls.querySelector('.' + t.options.classPrefix + 'time-loaded'); 1663 t.current = controls.querySelector('.' + t.options.classPrefix + 'time-current'); 1664 t.handle = controls.querySelector('.' + t.options.classPrefix + 'time-handle'); 1665 t.timefloat = controls.querySelector('.' + t.options.classPrefix + 'time-float'); 1666 t.timefloatcurrent = controls.querySelector('.' + t.options.classPrefix + 'time-float-current'); 1667 t.slider = controls.querySelector('.' + t.options.classPrefix + 'time-slider'); 1668 t.hovered = controls.querySelector('.' + t.options.classPrefix + 'time-hovered'); 1669 t.buffer = controls.querySelector('.' + t.options.classPrefix + 'time-buffering'); 1670 t.newTime = 0; 1671 t.forcedHandlePause = false; 1672 t.setTransformStyle = function (element, value) { 1673 element.style.transform = value; 1674 element.style.webkitTransform = value; 1675 element.style.MozTransform = value; 1676 element.style.msTransform = value; 1677 element.style.OTransform = value; 1678 }; 1679 1680 t.buffer.style.display = 'none'; 1681 1682 var handleMouseMove = function handleMouseMove(e) { 1683 var totalStyles = getComputedStyle(t.total), 1684 offsetStyles = (0, _dom.offset)(t.total), 1685 width = t.total.offsetWidth, 1686 transform = function () { 1687 if (totalStyles.webkitTransform !== undefined) { 1688 return 'webkitTransform'; 1689 } else if (totalStyles.mozTransform !== undefined) { 1690 return 'mozTransform '; 1691 } else if (totalStyles.oTransform !== undefined) { 1692 return 'oTransform'; 1693 } else if (totalStyles.msTransform !== undefined) { 1694 return 'msTransform'; 1695 } else { 1696 return 'transform'; 1697 } 1698 }(), 1699 cssMatrix = function () { 1700 if ('WebKitCSSMatrix' in window) { 1701 return 'WebKitCSSMatrix'; 1702 } else if ('MSCSSMatrix' in window) { 1703 return 'MSCSSMatrix'; 1704 } else if ('CSSMatrix' in window) { 1705 return 'CSSMatrix'; 1706 } 1707 }(); 1708 1709 var percentage = 0, 1710 leftPos = 0, 1711 pos = 0, 1712 x = void 0; 1713 1714 if (e.originalEvent && e.originalEvent.changedTouches) { 1715 x = e.originalEvent.changedTouches[0].pageX; 1716 } else if (e.changedTouches) { 1717 x = e.changedTouches[0].pageX; 1718 } else { 1719 x = e.pageX; 1720 } 1721 1722 if (t.getDuration()) { 1723 if (x < offsetStyles.left) { 1724 x = offsetStyles.left; 1725 } else if (x > width + offsetStyles.left) { 1726 x = width + offsetStyles.left; 1727 } 1728 1729 pos = x - offsetStyles.left; 1730 percentage = pos / width; 1731 t.newTime = percentage * t.getDuration(); 1732 1733 if (mouseIsDown && t.getCurrentTime() !== null && t.newTime.toFixed(4) !== t.getCurrentTime().toFixed(4)) { 1734 t.setCurrentRailHandle(t.newTime); 1735 t.updateCurrent(t.newTime); 1736 } 1737 1738 if (!_constants.IS_IOS && !_constants.IS_ANDROID) { 1739 if (pos < 0) { 1740 pos = 0; 1741 } 1742 if (t.options.useSmoothHover && cssMatrix !== null && typeof window[cssMatrix] !== 'undefined') { 1743 var matrix = new window[cssMatrix](getComputedStyle(t.handle)[transform]), 1744 handleLocation = matrix.m41, 1745 hoverScaleX = pos / parseFloat(getComputedStyle(t.total).width) - handleLocation / parseFloat(getComputedStyle(t.total).width); 1746 1747 t.hovered.style.left = handleLocation + 'px'; 1748 t.setTransformStyle(t.hovered, 'scaleX(' + hoverScaleX + ')'); 1749 t.hovered.setAttribute('pos', pos); 1750 1751 if (hoverScaleX >= 0) { 1752 (0, _dom.removeClass)(t.hovered, 'negative'); 1753 } else { 1754 (0, _dom.addClass)(t.hovered, 'negative'); 1755 } 1756 } 1757 1758 if (t.timefloat) { 1759 var half = t.timefloat.offsetWidth / 2, 1760 offsetContainer = mejs.Utils.offset(t.getElement(t.container)), 1761 tooltipStyles = getComputedStyle(t.timefloat); 1762 1763 if (x - offsetContainer.left < t.timefloat.offsetWidth) { 1764 leftPos = half; 1765 } else if (x - offsetContainer.left >= t.getElement(t.container).offsetWidth - half) { 1766 leftPos = t.total.offsetWidth - half; 1767 } else { 1768 leftPos = pos; 1769 } 1770 1771 if ((0, _dom.hasClass)(t.getElement(t.container), t.options.classPrefix + 'long-video')) { 1772 leftPos += parseFloat(tooltipStyles.marginLeft) / 2 + t.timefloat.offsetWidth / 2; 1773 } 1774 1775 t.timefloat.style.left = leftPos + 'px'; 1776 t.timefloatcurrent.innerHTML = (0, _time.secondsToTimeCode)(t.newTime, player.options.alwaysShowHours, player.options.showTimecodeFrameCount, player.options.framesPerSecond, player.options.secondsDecimalLength, player.options.timeFormat); 1777 t.timefloat.style.display = 'block'; 1778 } 1779 } 1780 } else if (!_constants.IS_IOS && !_constants.IS_ANDROID && t.timefloat) { 1781 leftPos = t.timefloat.offsetWidth + width >= t.getElement(t.container).offsetWidth ? t.timefloat.offsetWidth / 2 : 0; 1782 t.timefloat.style.left = leftPos + 'px'; 1783 t.timefloat.style.left = leftPos + 'px'; 1784 t.timefloat.style.display = 'block'; 1785 } 1786 }, 1787 updateSlider = function updateSlider() { 1788 var seconds = t.getCurrentTime(), 1789 timeSliderText = _i18n2.default.t('mejs.time-slider'), 1790 time = (0, _time.secondsToTimeCode)(seconds, player.options.alwaysShowHours, player.options.showTimecodeFrameCount, player.options.framesPerSecond, player.options.secondsDecimalLength, player.options.timeFormat), 1791 duration = t.getDuration(); 1792 1793 t.slider.setAttribute('role', 'slider'); 1794 t.slider.tabIndex = 0; 1795 1796 if (media.paused) { 1797 t.slider.setAttribute('aria-label', timeSliderText); 1798 t.slider.setAttribute('aria-valuemin', 0); 1799 t.slider.setAttribute('aria-valuemax', isNaN(duration) ? 0 : duration); 1800 t.slider.setAttribute('aria-valuenow', seconds); 1801 t.slider.setAttribute('aria-valuetext', time); 1802 } else { 1803 t.slider.removeAttribute('aria-label'); 1804 t.slider.removeAttribute('aria-valuemin'); 1805 t.slider.removeAttribute('aria-valuemax'); 1806 t.slider.removeAttribute('aria-valuenow'); 1807 t.slider.removeAttribute('aria-valuetext'); 1808 } 1809 }, 1810 restartPlayer = function restartPlayer() { 1811 if (new Date() - lastKeyPressTime >= 1000) { 1812 t.play(); 1813 } 1814 }, 1815 handleMouseup = function handleMouseup() { 1816 if (mouseIsDown && t.getCurrentTime() !== null && t.newTime.toFixed(4) !== t.getCurrentTime().toFixed(4)) { 1817 t.setCurrentTime(t.newTime); 1818 t.setCurrentRailHandle(t.newTime); 1819 t.updateCurrent(t.newTime); 1820 } 1821 if (t.forcedHandlePause) { 1822 t.slider.focus(); 1823 t.play(); 1824 } 1825 t.forcedHandlePause = false; 1826 }; 1827 1828 t.slider.addEventListener('focus', function () { 1829 player.options.autoRewind = false; 1830 }); 1831 t.slider.addEventListener('blur', function () { 1832 player.options.autoRewind = autoRewindInitial; 1833 }); 1834 t.slider.addEventListener('keydown', function (e) { 1835 if (new Date() - lastKeyPressTime >= 1000) { 1836 startedPaused = t.paused; 1837 } 1838 1839 if (t.options.enableKeyboard && t.options.keyActions.length) { 1840 1841 var keyCode = e.which || e.keyCode || 0, 1842 duration = t.getDuration(), 1843 seekForward = player.options.defaultSeekForwardInterval(media), 1844 seekBackward = player.options.defaultSeekBackwardInterval(media); 1845 1846 var seekTime = t.getCurrentTime(); 1847 var volume = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'volume-slider'); 1848 1849 if (keyCode === 38 || keyCode === 40) { 1850 if (volume) { 1851 volume.style.display = 'block'; 1852 } 1853 if (t.isVideo) { 1854 t.showControls(); 1855 t.startControlsTimer(); 1856 } 1857 1858 var newVolume = keyCode === 38 ? Math.min(t.volume + 0.1, 1) : Math.max(t.volume - 0.1, 0), 1859 mutePlayer = newVolume <= 0; 1860 t.setVolume(newVolume); 1861 t.setMuted(mutePlayer); 1862 return; 1863 } else { 1864 if (volume) { 1865 volume.style.display = 'none'; 1866 } 1867 } 1868 1869 switch (keyCode) { 1870 case 37: 1871 if (t.getDuration() !== Infinity) { 1872 seekTime -= seekBackward; 1873 } 1874 break; 1875 case 39: 1876 if (t.getDuration() !== Infinity) { 1877 seekTime += seekForward; 1878 } 1879 break; 1880 case 36: 1881 seekTime = 0; 1882 break; 1883 case 35: 1884 seekTime = duration; 1885 break; 1886 case 13: 1887 case 32: 1888 if (_constants.IS_FIREFOX) { 1889 if (t.paused) { 1890 t.play(); 1891 } else { 1892 t.pause(); 1893 } 1894 } 1895 return; 1896 default: 1897 return; 1898 } 1899 1900 seekTime = seekTime < 0 || isNaN(seekTime) ? 0 : seekTime >= duration ? duration : Math.floor(seekTime); 1901 lastKeyPressTime = new Date(); 1902 if (!startedPaused) { 1903 player.pause(); 1904 } 1905 1906 setTimeout(function () { 1907 t.setCurrentTime(seekTime); 1908 }, 0); 1909 1910 if (seekTime < t.getDuration() && !startedPaused) { 1911 setTimeout(restartPlayer, 1100); 1912 } 1913 1914 player.showControls(); 1915 1916 e.preventDefault(); 1917 e.stopPropagation(); 1918 } 1919 }); 1920 1921 var events = ['mousedown', 'touchstart']; 1922 1923 t.slider.addEventListener('dragstart', function () { 1924 return false; 1925 }); 1926 1927 for (var i = 0, total = events.length; i < total; i++) { 1928 t.slider.addEventListener(events[i], function (e) { 1929 t.forcedHandlePause = false; 1930 if (t.getDuration() !== Infinity) { 1931 if (e.which === 1 || e.which === 0) { 1932 if (!t.paused) { 1933 t.pause(); 1934 t.forcedHandlePause = true; 1935 } 1936 1937 mouseIsDown = true; 1938 handleMouseMove(e); 1939 var endEvents = ['mouseup', 'touchend']; 1940 1941 for (var j = 0, totalEvents = endEvents.length; j < totalEvents; j++) { 1942 t.getElement(t.container).addEventListener(endEvents[j], function (event) { 1943 var target = event.target; 1944 if (target === t.slider || target.closest('.' + t.options.classPrefix + 'time-slider')) { 1945 handleMouseMove(event); 1946 } 1947 }); 1948 } 1949 t.globalBind('mouseup.dur touchend.dur', function () { 1950 handleMouseup(); 1951 mouseIsDown = false; 1952 if (t.timefloat) { 1953 t.timefloat.style.display = 'none'; 1954 } 1955 }); 1956 } 1957 } 1958 }, _constants.SUPPORT_PASSIVE_EVENT && events[i] === 'touchstart' ? { passive: true } : false); 1959 } 1960 t.slider.addEventListener('mouseenter', function (e) { 1961 if (e.target === t.slider && t.getDuration() !== Infinity) { 1962 t.getElement(t.container).addEventListener('mousemove', function (event) { 1963 var target = event.target; 1964 if (target === t.slider || target.closest('.' + t.options.classPrefix + 'time-slider')) { 1965 handleMouseMove(event); 1966 } 1967 }); 1968 if (t.timefloat && !_constants.IS_IOS && !_constants.IS_ANDROID) { 1969 t.timefloat.style.display = 'block'; 1970 } 1971 if (t.hovered && !_constants.IS_IOS && !_constants.IS_ANDROID && t.options.useSmoothHover) { 1972 (0, _dom.removeClass)(t.hovered, 'no-hover'); 1973 } 1974 } 1975 }); 1976 t.slider.addEventListener('mouseleave', function () { 1977 if (t.getDuration() !== Infinity) { 1978 if (!mouseIsDown) { 1979 if (t.timefloat) { 1980 t.timefloat.style.display = 'none'; 1981 } 1982 if (t.hovered && t.options.useSmoothHover) { 1983 (0, _dom.addClass)(t.hovered, 'no-hover'); 1984 } 1985 } 1986 } 1987 }); 1988 1989 t.broadcastCallback = function (e) { 1990 var broadcast = controls.querySelector('.' + t.options.classPrefix + 'broadcast'); 1991 if (!t.options.forceLive && t.getDuration() !== Infinity) { 1992 if (broadcast) { 1993 t.slider.style.display = ''; 1994 broadcast.remove(); 1995 } 1996 1997 player.setProgressRail(e); 1998 if (!t.forcedHandlePause) { 1999 player.setCurrentRail(e); 2000 } 2001 updateSlider(); 2002 } else if (!broadcast && t.options.forceLive) { 2003 var label = _document2.default.createElement('span'); 2004 label.className = t.options.classPrefix + 'broadcast'; 2005 label.innerText = _i18n2.default.t('mejs.live-broadcast'); 2006 t.slider.style.display = 'none'; 2007 t.rail.appendChild(label); 2008 } 2009 }; 2010 2011 media.addEventListener('progress', t.broadcastCallback); 2012 media.addEventListener('timeupdate', t.broadcastCallback); 2013 media.addEventListener('play', function () { 2014 t.buffer.style.display = 'none'; 2015 }); 2016 media.addEventListener('playing', function () { 2017 t.buffer.style.display = 'none'; 2018 }); 2019 media.addEventListener('seeking', function () { 2020 t.buffer.style.display = ''; 2021 }); 2022 media.addEventListener('seeked', function () { 2023 t.buffer.style.display = 'none'; 2024 }); 2025 media.addEventListener('pause', function () { 2026 t.buffer.style.display = 'none'; 2027 }); 2028 media.addEventListener('waiting', function () { 2029 t.buffer.style.display = ''; 2030 }); 2031 media.addEventListener('loadeddata', function () { 2032 t.buffer.style.display = ''; 2033 }); 2034 media.addEventListener('canplay', function () { 2035 t.buffer.style.display = 'none'; 2036 }); 2037 media.addEventListener('error', function () { 2038 t.buffer.style.display = 'none'; 2039 }); 2040 2041 t.getElement(t.container).addEventListener('controlsresize', function (e) { 2042 if (t.getDuration() !== Infinity) { 2043 player.setProgressRail(e); 2044 if (!t.forcedHandlePause) { 2045 player.setCurrentRail(e); 2046 } 2047 } 2048 }); 2049 }, 2050 cleanprogress: function cleanprogress(player, controls, layers, media) { 2051 media.removeEventListener('progress', player.broadcastCallback); 2052 media.removeEventListener('timeupdate', player.broadcastCallback); 2053 if (player.rail) { 2054 player.rail.remove(); 2055 } 2056 }, 2057 setProgressRail: function setProgressRail(e) { 2058 var t = this, 2059 target = e !== undefined ? e.detail.target || e.target : t.media; 2060 2061 var percent = null; 2062 2063 if (target && target.buffered && target.buffered.length > 0 && target.buffered.end && t.getDuration()) { 2064 percent = target.buffered.end(target.buffered.length - 1) / t.getDuration(); 2065 } else if (target && target.bytesTotal !== undefined && target.bytesTotal > 0 && target.bufferedBytes !== undefined) { 2066 percent = target.bufferedBytes / target.bytesTotal; 2067 } else if (e && e.lengthComputable && e.total !== 0) { 2068 percent = e.loaded / e.total; 2069 } 2070 2071 if (percent !== null) { 2072 percent = Math.min(1, Math.max(0, percent)); 2073 2074 if (t.loaded) { 2075 t.setTransformStyle(t.loaded, 'scaleX(' + percent + ')'); 2076 } 2077 } 2078 }, 2079 setCurrentRailHandle: function setCurrentRailHandle(fakeTime) { 2080 var t = this; 2081 t.setCurrentRailMain(t, fakeTime); 2082 }, 2083 setCurrentRail: function setCurrentRail() { 2084 var t = this; 2085 t.setCurrentRailMain(t); 2086 }, 2087 setCurrentRailMain: function setCurrentRailMain(t, fakeTime) { 2088 if (t.getCurrentTime() !== undefined && t.getDuration()) { 2089 var nTime = typeof fakeTime === 'undefined' ? t.getCurrentTime() : fakeTime; 2090 2091 if (t.total && t.handle) { 2092 var tW = parseFloat(getComputedStyle(t.total).width); 2093 2094 var newWidth = Math.round(tW * nTime / t.getDuration()), 2095 handlePos = newWidth - Math.round(t.handle.offsetWidth / 2); 2096 2097 handlePos = handlePos < 0 ? 0 : handlePos; 2098 t.setTransformStyle(t.current, 'scaleX(' + newWidth / tW + ')'); 2099 t.setTransformStyle(t.handle, 'translateX(' + handlePos + 'px)'); 2100 2101 if (t.options.useSmoothHover && !(0, _dom.hasClass)(t.hovered, 'no-hover')) { 2102 var pos = parseInt(t.hovered.getAttribute('pos'), 10); 2103 pos = isNaN(pos) ? 0 : pos; 2104 2105 var hoverScaleX = pos / tW - handlePos / tW; 2106 2107 t.hovered.style.left = handlePos + 'px'; 2108 t.setTransformStyle(t.hovered, 'scaleX(' + hoverScaleX + ')'); 2109 2110 if (hoverScaleX >= 0) { 2111 (0, _dom.removeClass)(t.hovered, 'negative'); 2112 } else { 2113 (0, _dom.addClass)(t.hovered, 'negative'); 2114 } 2115 } 2116 } 2117 } 2118 } 2119 }); 2120 2121 },{"16":16,"2":2,"25":25,"26":26,"30":30,"5":5}],12:[function(_dereq_,module,exports){ 2122 'use strict'; 2123 2124 var _document = _dereq_(2); 2125 2126 var _document2 = _interopRequireDefault(_document); 2127 2128 var _player = _dereq_(16); 2129 2130 var _player2 = _interopRequireDefault(_player); 2131 2132 var _time = _dereq_(30); 2133 2134 var _dom = _dereq_(26); 2135 2136 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2137 2138 Object.assign(_player.config, { 2139 duration: 0, 2140 2141 timeAndDurationSeparator: '<span> | </span>' 2142 }); 2143 2144 Object.assign(_player2.default.prototype, { 2145 buildcurrent: function buildcurrent(player, controls, layers, media) { 2146 var t = this, 2147 time = _document2.default.createElement('div'); 2148 2149 time.className = t.options.classPrefix + 'time'; 2150 time.setAttribute('role', 'timer'); 2151 time.setAttribute('aria-live', 'off'); 2152 time.innerHTML = '<span class="' + t.options.classPrefix + 'currenttime">' + (0, _time.secondsToTimeCode)(0, player.options.alwaysShowHours, player.options.showTimecodeFrameCount, player.options.framesPerSecond, player.options.secondsDecimalLength, player.options.timeFormat) + '</span>'; 2153 2154 t.addControlElement(time, 'current'); 2155 player.updateCurrent(); 2156 t.updateTimeCallback = function () { 2157 if (t.controlsAreVisible) { 2158 player.updateCurrent(); 2159 } 2160 }; 2161 media.addEventListener('timeupdate', t.updateTimeCallback); 2162 }, 2163 cleancurrent: function cleancurrent(player, controls, layers, media) { 2164 media.removeEventListener('timeupdate', player.updateTimeCallback); 2165 }, 2166 buildduration: function buildduration(player, controls, layers, media) { 2167 var t = this, 2168 currTime = controls.lastChild.querySelector('.' + t.options.classPrefix + 'currenttime'); 2169 2170 if (currTime) { 2171 controls.querySelector('.' + t.options.classPrefix + 'time').innerHTML += t.options.timeAndDurationSeparator + '<span class="' + t.options.classPrefix + 'duration">' + ((0, _time.secondsToTimeCode)(t.options.duration, t.options.alwaysShowHours, t.options.showTimecodeFrameCount, t.options.framesPerSecond, t.options.secondsDecimalLength, t.options.timeFormat) + '</span>'); 2172 } else { 2173 if (controls.querySelector('.' + t.options.classPrefix + 'currenttime')) { 2174 (0, _dom.addClass)(controls.querySelector('.' + t.options.classPrefix + 'currenttime').parentNode, t.options.classPrefix + 'currenttime-container'); 2175 } 2176 2177 var duration = _document2.default.createElement('div'); 2178 duration.className = t.options.classPrefix + 'time ' + t.options.classPrefix + 'duration-container'; 2179 duration.innerHTML = '<span class="' + t.options.classPrefix + 'duration">' + ((0, _time.secondsToTimeCode)(t.options.duration, t.options.alwaysShowHours, t.options.showTimecodeFrameCount, t.options.framesPerSecond, t.options.secondsDecimalLength, t.options.timeFormat) + '</span>'); 2180 2181 t.addControlElement(duration, 'duration'); 2182 } 2183 2184 t.updateDurationCallback = function () { 2185 if (t.controlsAreVisible) { 2186 player.updateDuration(); 2187 } 2188 }; 2189 2190 media.addEventListener('timeupdate', t.updateDurationCallback); 2191 }, 2192 cleanduration: function cleanduration(player, controls, layers, media) { 2193 media.removeEventListener('timeupdate', player.updateDurationCallback); 2194 }, 2195 updateCurrent: function updateCurrent() { 2196 var t = this; 2197 2198 var currentTime = t.getCurrentTime(); 2199 2200 if (isNaN(currentTime)) { 2201 currentTime = 0; 2202 } 2203 2204 var timecode = (0, _time.secondsToTimeCode)(currentTime, t.options.alwaysShowHours, t.options.showTimecodeFrameCount, t.options.framesPerSecond, t.options.secondsDecimalLength, t.options.timeFormat); 2205 2206 if (timecode.length > 5) { 2207 (0, _dom.addClass)(t.getElement(t.container), t.options.classPrefix + 'long-video'); 2208 } else { 2209 (0, _dom.removeClass)(t.getElement(t.container), t.options.classPrefix + 'long-video'); 2210 } 2211 2212 if (t.getElement(t.controls).querySelector('.' + t.options.classPrefix + 'currenttime')) { 2213 t.getElement(t.controls).querySelector('.' + t.options.classPrefix + 'currenttime').innerText = timecode; 2214 } 2215 }, 2216 updateDuration: function updateDuration() { 2217 var t = this; 2218 2219 var duration = t.getDuration(); 2220 2221 if (t.media !== undefined && (isNaN(duration) || duration === Infinity || duration < 0)) { 2222 t.media.duration = t.options.duration = duration = 0; 2223 } 2224 2225 if (t.options.duration > 0) { 2226 duration = t.options.duration; 2227 } 2228 2229 var timecode = (0, _time.secondsToTimeCode)(duration, t.options.alwaysShowHours, t.options.showTimecodeFrameCount, t.options.framesPerSecond, t.options.secondsDecimalLength, t.options.timeFormat); 2230 2231 if (timecode.length > 5) { 2232 (0, _dom.addClass)(t.getElement(t.container), t.options.classPrefix + 'long-video'); 2233 } else { 2234 (0, _dom.removeClass)(t.getElement(t.container), t.options.classPrefix + 'long-video'); 2235 } 2236 2237 if (t.getElement(t.controls).querySelector('.' + t.options.classPrefix + 'duration') && duration > 0) { 2238 t.getElement(t.controls).querySelector('.' + t.options.classPrefix + 'duration').innerHTML = timecode; 2239 } 2240 } 2241 }); 2242 2243 },{"16":16,"2":2,"26":26,"30":30}],13:[function(_dereq_,module,exports){ 2244 'use strict'; 2245 2246 var _document = _dereq_(2); 2247 2248 var _document2 = _interopRequireDefault(_document); 2249 2250 var _mejs = _dereq_(7); 2251 2252 var _mejs2 = _interopRequireDefault(_mejs); 2253 2254 var _i18n = _dereq_(5); 2255 2256 var _i18n2 = _interopRequireDefault(_i18n); 2257 2258 var _player = _dereq_(16); 2259 2260 var _player2 = _interopRequireDefault(_player); 2261 2262 var _time = _dereq_(30); 2263 2264 var _general = _dereq_(27); 2265 2266 var _dom = _dereq_(26); 2267 2268 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 2269 2270 Object.assign(_player.config, { 2271 startLanguage: '', 2272 2273 tracksText: null, 2274 2275 chaptersText: null, 2276 2277 tracksAriaLive: false, 2278 2279 hideCaptionsButtonWhenEmpty: true, 2280 2281 toggleCaptionsButtonWhenOnlyOne: false, 2282 2283 slidesSelector: '' 2284 }); 2285 2286 Object.assign(_player2.default.prototype, { 2287 hasChapters: false, 2288 2289 buildtracks: function buildtracks(player, controls, layers, media) { 2290 2291 this.findTracks(); 2292 2293 if (!player.tracks.length && (!player.trackFiles || !player.trackFiles.length === 0)) { 2294 return; 2295 } 2296 2297 var t = this, 2298 attr = t.options.tracksAriaLive ? ' role="log" aria-live="assertive" aria-atomic="false"' : '', 2299 tracksTitle = (0, _general.isString)(t.options.tracksText) ? t.options.tracksText : _i18n2.default.t('mejs.captions-subtitles'), 2300 chaptersTitle = (0, _general.isString)(t.options.chaptersText) ? t.options.chaptersText : _i18n2.default.t('mejs.captions-chapters'), 2301 total = player.trackFiles === null ? player.tracks.length : player.trackFiles.length; 2302 2303 if (t.domNode.textTracks) { 2304 for (var i = t.domNode.textTracks.length - 1; i >= 0; i--) { 2305 t.domNode.textTracks[i].mode = 'hidden'; 2306 } 2307 } 2308 2309 t.cleartracks(player); 2310 2311 player.captions = _document2.default.createElement('div'); 2312 player.captions.className = t.options.classPrefix + 'captions-layer ' + t.options.classPrefix + 'layer'; 2313 player.captions.innerHTML = '<div class="' + t.options.classPrefix + 'captions-position ' + t.options.classPrefix + 'captions-position-hover"' + attr + '>' + ('<span class="' + t.options.classPrefix + 'captions-text"></span>') + '</div>'; 2314 player.captions.style.display = 'none'; 2315 layers.insertBefore(player.captions, layers.firstChild); 2316 2317 player.captionsText = player.captions.querySelector('.' + t.options.classPrefix + 'captions-text'); 2318 2319 player.captionsButton = _document2.default.createElement('div'); 2320 player.captionsButton.className = t.options.classPrefix + 'button ' + t.options.classPrefix + 'captions-button'; 2321 player.captionsButton.innerHTML = '<button type="button" aria-controls="' + t.id + '" title="' + tracksTitle + '" aria-label="' + tracksTitle + '" tabindex="0"></button>' + ('<div class="' + t.options.classPrefix + 'captions-selector ' + t.options.classPrefix + 'offscreen">') + ('<ul class="' + t.options.classPrefix + 'captions-selector-list">') + ('<li class="' + t.options.classPrefix + 'captions-selector-list-item">') + ('<input type="radio" class="' + t.options.classPrefix + 'captions-selector-input" ') + ('name="' + player.id + '_captions" id="' + player.id + '_captions_none" ') + 'value="none" checked disabled>' + ('<label class="' + t.options.classPrefix + 'captions-selector-label ') + (t.options.classPrefix + 'captions-selected" ') + ('for="' + player.id + '_captions_none">' + _i18n2.default.t('mejs.none') + '</label>') + '</li>' + '</ul>' + '</div>'; 2322 2323 t.addControlElement(player.captionsButton, 'tracks'); 2324 2325 player.captionsButton.querySelector('.' + t.options.classPrefix + 'captions-selector-input').disabled = false; 2326 2327 player.chaptersButton = _document2.default.createElement('div'); 2328 player.chaptersButton.className = t.options.classPrefix + 'button ' + t.options.classPrefix + 'chapters-button'; 2329 player.chaptersButton.innerHTML = '<button type="button" aria-controls="' + t.id + '" title="' + chaptersTitle + '" aria-label="' + chaptersTitle + '" tabindex="0"></button>' + ('<div class="' + t.options.classPrefix + 'chapters-selector ' + t.options.classPrefix + 'offscreen">') + ('<ul class="' + t.options.classPrefix + 'chapters-selector-list"></ul>') + '</div>'; 2330 2331 var subtitleCount = 0; 2332 2333 for (var _i = 0; _i < total; _i++) { 2334 var kind = player.tracks[_i].kind, 2335 src = player.tracks[_i].src; 2336 if (src.trim()) { 2337 if (kind === 'subtitles' || kind === 'captions') { 2338 subtitleCount++; 2339 } else if (kind === 'chapters' && !controls.querySelector('.' + t.options.classPrefix + 'chapter-selector')) { 2340 player.captionsButton.parentNode.insertBefore(player.chaptersButton, player.captionsButton); 2341 } 2342 } 2343 } 2344 2345 player.trackToLoad = -1; 2346 player.selectedTrack = null; 2347 player.isLoadingTrack = false; 2348 2349 for (var _i2 = 0; _i2 < total; _i2++) { 2350 var _kind = player.tracks[_i2].kind; 2351 if (player.tracks[_i2].src.trim() && (_kind === 'subtitles' || _kind === 'captions')) { 2352 player.addTrackButton(player.tracks[_i2].trackId, player.tracks[_i2].srclang, player.tracks[_i2].label); 2353 } 2354 } 2355 2356 player.loadNextTrack(); 2357 2358 var inEvents = ['mouseenter', 'focusin'], 2359 outEvents = ['mouseleave', 'focusout']; 2360 2361 if (t.options.toggleCaptionsButtonWhenOnlyOne && subtitleCount === 1) { 2362 player.captionsButton.addEventListener('click', function (e) { 2363 var trackId = 'none'; 2364 if (player.selectedTrack === null) { 2365 trackId = player.tracks[0].trackId; 2366 } 2367 var keyboard = e.keyCode || e.which; 2368 player.setTrack(trackId, typeof keyboard !== 'undefined'); 2369 }); 2370 } else { 2371 var labels = player.captionsButton.querySelectorAll('.' + t.options.classPrefix + 'captions-selector-label'), 2372 captions = player.captionsButton.querySelectorAll('input[type=radio]'); 2373 2374 for (var _i3 = 0, _total = inEvents.length; _i3 < _total; _i3++) { 2375 player.captionsButton.addEventListener(inEvents[_i3], function () { 2376 (0, _dom.removeClass)(this.querySelector('.' + t.options.classPrefix + 'captions-selector'), t.options.classPrefix + 'offscreen'); 2377 }); 2378 } 2379 2380 for (var _i4 = 0, _total2 = outEvents.length; _i4 < _total2; _i4++) { 2381 player.captionsButton.addEventListener(outEvents[_i4], function () { 2382 (0, _dom.addClass)(this.querySelector('.' + t.options.classPrefix + 'captions-selector'), t.options.classPrefix + 'offscreen'); 2383 }); 2384 } 2385 2386 for (var _i5 = 0, _total3 = captions.length; _i5 < _total3; _i5++) { 2387 captions[_i5].addEventListener('click', function (e) { 2388 var keyboard = e.keyCode || e.which; 2389 player.setTrack(this.value, typeof keyboard !== 'undefined'); 2390 }); 2391 } 2392 2393 for (var _i6 = 0, _total4 = labels.length; _i6 < _total4; _i6++) { 2394 labels[_i6].addEventListener('click', function (e) { 2395 var radio = (0, _dom.siblings)(this, function (el) { 2396 return el.tagName === 'INPUT'; 2397 })[0], 2398 event = (0, _general.createEvent)('click', radio); 2399 radio.dispatchEvent(event); 2400 e.preventDefault(); 2401 }); 2402 } 2403 2404 player.captionsButton.addEventListener('keydown', function (e) { 2405 e.stopPropagation(); 2406 }); 2407 } 2408 2409 for (var _i7 = 0, _total5 = inEvents.length; _i7 < _total5; _i7++) { 2410 player.chaptersButton.addEventListener(inEvents[_i7], function () { 2411 if (this.querySelector('.' + t.options.classPrefix + 'chapters-selector-list').children.length) { 2412 (0, _dom.removeClass)(this.querySelector('.' + t.options.classPrefix + 'chapters-selector'), t.options.classPrefix + 'offscreen'); 2413 } 2414 }); 2415 } 2416 2417 for (var _i8 = 0, _total6 = outEvents.length; _i8 < _total6; _i8++) { 2418 player.chaptersButton.addEventListener(outEvents[_i8], function () { 2419 (0, _dom.addClass)(this.querySelector('.' + t.options.classPrefix + 'chapters-selector'), t.options.classPrefix + 'offscreen'); 2420 }); 2421 } 2422 2423 player.chaptersButton.addEventListener('keydown', function (e) { 2424 e.stopPropagation(); 2425 }); 2426 2427 if (!player.options.alwaysShowControls) { 2428 player.getElement(player.container).addEventListener('controlsshown', function () { 2429 (0, _dom.addClass)(player.getElement(player.container).querySelector('.' + t.options.classPrefix + 'captions-position'), t.options.classPrefix + 'captions-position-hover'); 2430 }); 2431 2432 player.getElement(player.container).addEventListener('controlshidden', function () { 2433 if (!media.paused) { 2434 (0, _dom.removeClass)(player.getElement(player.container).querySelector('.' + t.options.classPrefix + 'captions-position'), t.options.classPrefix + 'captions-position-hover'); 2435 } 2436 }); 2437 } else { 2438 (0, _dom.addClass)(player.getElement(player.container).querySelector('.' + t.options.classPrefix + 'captions-position'), t.options.classPrefix + 'captions-position-hover'); 2439 } 2440 2441 media.addEventListener('timeupdate', function () { 2442 player.displayCaptions(); 2443 }); 2444 2445 if (player.options.slidesSelector !== '') { 2446 player.slidesContainer = _document2.default.querySelectorAll(player.options.slidesSelector); 2447 2448 media.addEventListener('timeupdate', function () { 2449 player.displaySlides(); 2450 }); 2451 } 2452 }, 2453 cleartracks: function cleartracks(player) { 2454 if (player) { 2455 if (player.captions) { 2456 player.captions.remove(); 2457 } 2458 if (player.chapters) { 2459 player.chapters.remove(); 2460 } 2461 if (player.captionsText) { 2462 player.captionsText.remove(); 2463 } 2464 if (player.captionsButton) { 2465 player.captionsButton.remove(); 2466 } 2467 if (player.chaptersButton) { 2468 player.chaptersButton.remove(); 2469 } 2470 } 2471 }, 2472 rebuildtracks: function rebuildtracks() { 2473 var t = this; 2474 t.findTracks(); 2475 t.buildtracks(t, t.getElement(t.controls), t.getElement(t.layers), t.media); 2476 }, 2477 findTracks: function findTracks() { 2478 var t = this, 2479 tracktags = t.trackFiles === null ? t.node.querySelectorAll('track') : t.trackFiles, 2480 total = tracktags.length; 2481 2482 t.tracks = []; 2483 for (var i = 0; i < total; i++) { 2484 var track = tracktags[i], 2485 srclang = track.getAttribute('srclang').toLowerCase() || '', 2486 trackId = t.id + '_track_' + i + '_' + track.getAttribute('kind') + '_' + srclang; 2487 t.tracks.push({ 2488 trackId: trackId, 2489 srclang: srclang, 2490 src: track.getAttribute('src'), 2491 kind: track.getAttribute('kind'), 2492 label: track.getAttribute('label') || '', 2493 entries: [], 2494 isLoaded: false 2495 }); 2496 } 2497 }, 2498 setTrack: function setTrack(trackId, setByKeyboard) { 2499 2500 var t = this, 2501 radios = t.captionsButton.querySelectorAll('input[type="radio"]'), 2502 captions = t.captionsButton.querySelectorAll('.' + t.options.classPrefix + 'captions-selected'), 2503 track = t.captionsButton.querySelector('input[value="' + trackId + '"]'); 2504 2505 for (var i = 0, total = radios.length; i < total; i++) { 2506 radios[i].checked = false; 2507 } 2508 2509 for (var _i9 = 0, _total7 = captions.length; _i9 < _total7; _i9++) { 2510 (0, _dom.removeClass)(captions[_i9], t.options.classPrefix + 'captions-selected'); 2511 } 2512 2513 track.checked = true; 2514 var labels = (0, _dom.siblings)(track, function (el) { 2515 return (0, _dom.hasClass)(el, t.options.classPrefix + 'captions-selector-label'); 2516 }); 2517 for (var _i10 = 0, _total8 = labels.length; _i10 < _total8; _i10++) { 2518 (0, _dom.addClass)(labels[_i10], t.options.classPrefix + 'captions-selected'); 2519 } 2520 2521 if (trackId === 'none') { 2522 t.selectedTrack = null; 2523 (0, _dom.removeClass)(t.captionsButton, t.options.classPrefix + 'captions-enabled'); 2524 } else { 2525 for (var _i11 = 0, _total9 = t.tracks.length; _i11 < _total9; _i11++) { 2526 var _track = t.tracks[_i11]; 2527 if (_track.trackId === trackId) { 2528 if (t.selectedTrack === null) { 2529 (0, _dom.addClass)(t.captionsButton, t.options.classPrefix + 'captions-enabled'); 2530 } 2531 t.selectedTrack = _track; 2532 t.captions.setAttribute('lang', t.selectedTrack.srclang); 2533 t.displayCaptions(); 2534 break; 2535 } 2536 } 2537 } 2538 2539 var event = (0, _general.createEvent)('captionschange', t.media); 2540 event.detail.caption = t.selectedTrack; 2541 t.media.dispatchEvent(event); 2542 2543 if (!setByKeyboard) { 2544 setTimeout(function () { 2545 t.getElement(t.container).focus(); 2546 }, 500); 2547 } 2548 }, 2549 loadNextTrack: function loadNextTrack() { 2550 var t = this; 2551 2552 t.trackToLoad++; 2553 if (t.trackToLoad < t.tracks.length) { 2554 t.isLoadingTrack = true; 2555 t.loadTrack(t.trackToLoad); 2556 } else { 2557 t.isLoadingTrack = false; 2558 t.checkForTracks(); 2559 } 2560 }, 2561 loadTrack: function loadTrack(index) { 2562 var t = this, 2563 track = t.tracks[index]; 2564 2565 if (track !== undefined && (track.src !== undefined || track.src !== "")) { 2566 (0, _dom.ajax)(track.src, 'text', function (d) { 2567 track.entries = typeof d === 'string' && /<tt\s+xml/ig.exec(d) ? _mejs2.default.TrackFormatParser.dfxp.parse(d) : _mejs2.default.TrackFormatParser.webvtt.parse(d); 2568 2569 track.isLoaded = true; 2570 t.enableTrackButton(track); 2571 t.loadNextTrack(); 2572 2573 if (track.kind === 'slides') { 2574 t.setupSlides(track); 2575 } else if (track.kind === 'chapters' && !t.hasChapters) { 2576 t.drawChapters(track); 2577 t.hasChapters = true; 2578 } 2579 }, function () { 2580 t.removeTrackButton(track.trackId); 2581 t.loadNextTrack(); 2582 }); 2583 } 2584 }, 2585 enableTrackButton: function enableTrackButton(track) { 2586 var t = this, 2587 lang = track.srclang, 2588 target = _document2.default.getElementById('' + track.trackId); 2589 2590 if (!target) { 2591 return; 2592 } 2593 2594 var label = track.label; 2595 2596 if (label === '') { 2597 label = _i18n2.default.t(_mejs2.default.language.codes[lang]) || lang; 2598 } 2599 target.disabled = false; 2600 var targetSiblings = (0, _dom.siblings)(target, function (el) { 2601 return (0, _dom.hasClass)(el, t.options.classPrefix + 'captions-selector-label'); 2602 }); 2603 for (var i = 0, total = targetSiblings.length; i < total; i++) { 2604 targetSiblings[i].innerHTML = label; 2605 } 2606 2607 if (t.options.startLanguage === lang) { 2608 target.checked = true; 2609 var event = (0, _general.createEvent)('click', target); 2610 target.dispatchEvent(event); 2611 } 2612 }, 2613 removeTrackButton: function removeTrackButton(trackId) { 2614 var element = _document2.default.getElementById('' + trackId); 2615 if (element) { 2616 var button = element.closest('li'); 2617 if (button) { 2618 button.remove(); 2619 } 2620 } 2621 }, 2622 addTrackButton: function addTrackButton(trackId, lang, label) { 2623 var t = this; 2624 if (label === '') { 2625 label = _i18n2.default.t(_mejs2.default.language.codes[lang]) || lang; 2626 } 2627 2628 t.captionsButton.querySelector('ul').innerHTML += '<li class="' + t.options.classPrefix + 'captions-selector-list-item">' + ('<input type="radio" class="' + t.options.classPrefix + 'captions-selector-input" ') + ('name="' + t.id + '_captions" id="' + trackId + '" value="' + trackId + '" disabled>') + ('<label class="' + t.options.classPrefix + 'captions-selector-label"') + ('for="' + trackId + '">' + label + ' (loading)</label>') + '</li>'; 2629 }, 2630 checkForTracks: function checkForTracks() { 2631 var t = this; 2632 2633 var hasSubtitles = false; 2634 2635 if (t.options.hideCaptionsButtonWhenEmpty) { 2636 for (var i = 0, total = t.tracks.length; i < total; i++) { 2637 var kind = t.tracks[i].kind; 2638 if ((kind === 'subtitles' || kind === 'captions') && t.tracks[i].isLoaded) { 2639 hasSubtitles = true; 2640 break; 2641 } 2642 } 2643 2644 t.captionsButton.style.display = hasSubtitles ? '' : 'none'; 2645 t.setControlsSize(); 2646 } 2647 }, 2648 displayCaptions: function displayCaptions() { 2649 if (this.tracks === undefined) { 2650 return; 2651 } 2652 2653 var t = this, 2654 track = t.selectedTrack, 2655 sanitize = function sanitize(html) { 2656 var div = _document2.default.createElement('div'); 2657 div.innerHTML = html; 2658 2659 var scripts = div.getElementsByTagName('script'); 2660 var i = scripts.length; 2661 while (i--) { 2662 scripts[i].remove(); 2663 } 2664 2665 var allElements = div.getElementsByTagName('*'); 2666 for (var _i12 = 0, n = allElements.length; _i12 < n; _i12++) { 2667 var attributesObj = allElements[_i12].attributes, 2668 attributes = Array.prototype.slice.call(attributesObj); 2669 2670 for (var j = 0, total = attributes.length; j < total; j++) { 2671 if (attributes[j].name.startsWith('on') || attributes[j].value.startsWith('javascript')) { 2672 allElements[_i12].remove(); 2673 } else if (attributes[j].name === 'style') { 2674 allElements[_i12].removeAttribute(attributes[j].name); 2675 } 2676 } 2677 } 2678 return div.innerHTML; 2679 }; 2680 2681 if (track !== null && track.isLoaded) { 2682 var i = t.searchTrackPosition(track.entries, t.media.currentTime); 2683 if (i > -1) { 2684 var text = track.entries[i].text; 2685 if (typeof t.options.captionTextPreprocessor === 'function') text = t.options.captionTextPreprocessor(text); 2686 t.captionsText.innerHTML = sanitize(text); 2687 t.captionsText.className = t.options.classPrefix + 'captions-text ' + (track.entries[i].identifier || ''); 2688 t.captions.style.display = ''; 2689 t.captions.style.height = '0px'; 2690 return; 2691 } 2692 t.captions.style.display = 'none'; 2693 } else { 2694 t.captions.style.display = 'none'; 2695 } 2696 }, 2697 setupSlides: function setupSlides(track) { 2698 var t = this; 2699 t.slides = track; 2700 t.slides.entries.imgs = [t.slides.entries.length]; 2701 t.showSlide(0); 2702 }, 2703 showSlide: function showSlide(index) { 2704 var _this = this; 2705 2706 var t = this; 2707 2708 if (t.tracks === undefined || t.slidesContainer === undefined) { 2709 return; 2710 } 2711 2712 var url = t.slides.entries[index].text; 2713 2714 var img = t.slides.entries[index].imgs; 2715 2716 if (img === undefined || img.fadeIn === undefined) { 2717 var image = _document2.default.createElement('img'); 2718 image.src = url; 2719 image.addEventListener('load', function () { 2720 var self = _this, 2721 visible = (0, _dom.siblings)(self, function (el) { 2722 return visible(el); 2723 }); 2724 self.style.display = 'none'; 2725 t.slidesContainer.innerHTML += self.innerHTML; 2726 (0, _dom.fadeIn)(t.slidesContainer.querySelector(image)); 2727 for (var i = 0, total = visible.length; i < total; i++) { 2728 (0, _dom.fadeOut)(visible[i], 400); 2729 } 2730 }); 2731 t.slides.entries[index].imgs = img = image; 2732 } else if (!(0, _dom.visible)(img)) { 2733 var _visible = (0, _dom.siblings)(self, function (el) { 2734 return _visible(el); 2735 }); 2736 (0, _dom.fadeIn)(t.slidesContainer.querySelector(img)); 2737 for (var i = 0, total = _visible.length; i < total; i++) { 2738 (0, _dom.fadeOut)(_visible[i]); 2739 } 2740 } 2741 }, 2742 displaySlides: function displaySlides() { 2743 var t = this; 2744 2745 if (this.slides === undefined) { 2746 return; 2747 } 2748 2749 var slides = t.slides, 2750 i = t.searchTrackPosition(slides.entries, t.media.currentTime); 2751 2752 if (i > -1) { 2753 t.showSlide(i); 2754 } 2755 }, 2756 drawChapters: function drawChapters(chapters) { 2757 var t = this, 2758 total = chapters.entries.length; 2759 2760 if (!total) { 2761 return; 2762 } 2763 2764 t.chaptersButton.querySelector('ul').innerHTML = ''; 2765 2766 for (var i = 0; i < total; i++) { 2767 t.chaptersButton.querySelector('ul').innerHTML += '<li class="' + t.options.classPrefix + 'chapters-selector-list-item" ' + 'role="menuitemcheckbox" aria-live="polite" aria-disabled="false" aria-checked="false">' + ('<input type="radio" class="' + t.options.classPrefix + 'captions-selector-input" ') + ('name="' + t.id + '_chapters" id="' + t.id + '_chapters_' + i + '" value="' + chapters.entries[i].start + '" disabled>') + ('<label class="' + t.options.classPrefix + 'chapters-selector-label"') + ('for="' + t.id + '_chapters_' + i + '">' + chapters.entries[i].text + '</label>') + '</li>'; 2768 } 2769 2770 var radios = t.chaptersButton.querySelectorAll('input[type="radio"]'), 2771 labels = t.chaptersButton.querySelectorAll('.' + t.options.classPrefix + 'chapters-selector-label'); 2772 2773 for (var _i13 = 0, _total10 = radios.length; _i13 < _total10; _i13++) { 2774 radios[_i13].disabled = false; 2775 radios[_i13].checked = false; 2776 radios[_i13].addEventListener('click', function (e) { 2777 var self = this, 2778 listItems = t.chaptersButton.querySelectorAll('li'), 2779 label = (0, _dom.siblings)(self, function (el) { 2780 return (0, _dom.hasClass)(el, t.options.classPrefix + 'chapters-selector-label'); 2781 })[0]; 2782 2783 self.checked = true; 2784 self.parentNode.setAttribute('aria-checked', true); 2785 (0, _dom.addClass)(label, t.options.classPrefix + 'chapters-selected'); 2786 (0, _dom.removeClass)(t.chaptersButton.querySelector('.' + t.options.classPrefix + 'chapters-selected'), t.options.classPrefix + 'chapters-selected'); 2787 2788 for (var _i14 = 0, _total11 = listItems.length; _i14 < _total11; _i14++) { 2789 listItems[_i14].setAttribute('aria-checked', false); 2790 } 2791 2792 var keyboard = e.keyCode || e.which; 2793 if (typeof keyboard === 'undefined') { 2794 setTimeout(function () { 2795 t.getElement(t.container).focus(); 2796 }, 500); 2797 } 2798 2799 t.media.setCurrentTime(parseFloat(self.value)); 2800 if (t.media.paused) { 2801 t.media.play(); 2802 } 2803 }); 2804 } 2805 2806 for (var _i15 = 0, _total12 = labels.length; _i15 < _total12; _i15++) { 2807 labels[_i15].addEventListener('click', function (e) { 2808 var radio = (0, _dom.siblings)(this, function (el) { 2809 return el.tagName === 'INPUT'; 2810 })[0], 2811 event = (0, _general.createEvent)('click', radio); 2812 radio.dispatchEvent(event); 2813 e.preventDefault(); 2814 }); 2815 } 2816 }, 2817 searchTrackPosition: function searchTrackPosition(tracks, currentTime) { 2818 var lo = 0, 2819 hi = tracks.length - 1, 2820 mid = void 0, 2821 start = void 0, 2822 stop = void 0; 2823 2824 while (lo <= hi) { 2825 mid = lo + hi >> 1; 2826 start = tracks[mid].start; 2827 stop = tracks[mid].stop; 2828 2829 if (currentTime >= start && currentTime < stop) { 2830 return mid; 2831 } else if (start < currentTime) { 2832 lo = mid + 1; 2833 } else if (start > currentTime) { 2834 hi = mid - 1; 2835 } 2836 } 2837 2838 return -1; 2839 } 2840 }); 2841 2842 _mejs2.default.language = { 2843 codes: { 2844 af: 'mejs.afrikaans', 2845 sq: 'mejs.albanian', 2846 ar: 'mejs.arabic', 2847 be: 'mejs.belarusian', 2848 bg: 'mejs.bulgarian', 2849 ca: 'mejs.catalan', 2850 zh: 'mejs.chinese', 2851 'zh-cn': 'mejs.chinese-simplified', 2852 'zh-tw': 'mejs.chines-traditional', 2853 hr: 'mejs.croatian', 2854 cs: 'mejs.czech', 2855 da: 'mejs.danish', 2856 nl: 'mejs.dutch', 2857 en: 'mejs.english', 2858 et: 'mejs.estonian', 2859 fl: 'mejs.filipino', 2860 fi: 'mejs.finnish', 2861 fr: 'mejs.french', 2862 gl: 'mejs.galician', 2863 de: 'mejs.german', 2864 el: 'mejs.greek', 2865 ht: 'mejs.haitian-creole', 2866 iw: 'mejs.hebrew', 2867 hi: 'mejs.hindi', 2868 hu: 'mejs.hungarian', 2869 is: 'mejs.icelandic', 2870 id: 'mejs.indonesian', 2871 ga: 'mejs.irish', 2872 it: 'mejs.italian', 2873 ja: 'mejs.japanese', 2874 ko: 'mejs.korean', 2875 lv: 'mejs.latvian', 2876 lt: 'mejs.lithuanian', 2877 mk: 'mejs.macedonian', 2878 ms: 'mejs.malay', 2879 mt: 'mejs.maltese', 2880 no: 'mejs.norwegian', 2881 fa: 'mejs.persian', 2882 pl: 'mejs.polish', 2883 pt: 'mejs.portuguese', 2884 ro: 'mejs.romanian', 2885 ru: 'mejs.russian', 2886 sr: 'mejs.serbian', 2887 sk: 'mejs.slovak', 2888 sl: 'mejs.slovenian', 2889 es: 'mejs.spanish', 2890 sw: 'mejs.swahili', 2891 sv: 'mejs.swedish', 2892 tl: 'mejs.tagalog', 2893 th: 'mejs.thai', 2894 tr: 'mejs.turkish', 2895 uk: 'mejs.ukrainian', 2896 vi: 'mejs.vietnamese', 2897 cy: 'mejs.welsh', 2898 yi: 'mejs.yiddish' 2899 } 2900 }; 2901 2902 _mejs2.default.TrackFormatParser = { 2903 webvtt: { 2904 pattern: /^((?:[0-9]{1,2}:)?[0-9]{2}:[0-9]{2}([,.][0-9]{1,3})?) --\> ((?:[0-9]{1,2}:)?[0-9]{2}:[0-9]{2}([,.][0-9]{3})?)(.*)$/, 2905 2906 parse: function parse(trackText) { 2907 var lines = trackText.split(/\r?\n/), 2908 entries = []; 2909 2910 var timecode = void 0, 2911 text = void 0, 2912 identifier = void 0; 2913 2914 for (var i = 0, total = lines.length; i < total; i++) { 2915 timecode = this.pattern.exec(lines[i]); 2916 2917 if (timecode && i < lines.length) { 2918 if (i - 1 >= 0 && lines[i - 1] !== '') { 2919 identifier = lines[i - 1]; 2920 } 2921 i++; 2922 2923 text = lines[i]; 2924 i++; 2925 while (lines[i] !== '' && i < lines.length) { 2926 text = text + '\n' + lines[i]; 2927 i++; 2928 } 2929 text = text === null ? '' : text.trim().replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, "<a href='$1' target='_blank'>$1</a>"); 2930 entries.push({ 2931 identifier: identifier, 2932 start: (0, _time.convertSMPTEtoSeconds)(timecode[1]) === 0 ? 0.200 : (0, _time.convertSMPTEtoSeconds)(timecode[1]), 2933 stop: (0, _time.convertSMPTEtoSeconds)(timecode[3]), 2934 text: text, 2935 settings: timecode[5] 2936 }); 2937 } 2938 identifier = ''; 2939 } 2940 return entries; 2941 } 2942 }, 2943 2944 dfxp: { 2945 parse: function parse(trackText) { 2946 var trackElem = _document2.default.adoptNode(new DOMParser().parseFromString(trackText, 'application/xml').documentElement), 2947 container = trackElem.querySelector('div'), 2948 lines = container.querySelectorAll('p'), 2949 styleNode = _document2.default.getElementById(container.getAttribute('style')), 2950 entries = []; 2951 2952 var styles = void 0; 2953 2954 if (styleNode) { 2955 styleNode.removeAttribute('id'); 2956 var attributes = styleNode.attributes; 2957 if (attributes.length) { 2958 styles = {}; 2959 for (var i = 0, total = attributes.length; i < total; i++) { 2960 styles[attributes[i].name.split(":")[1]] = attributes[i].value; 2961 } 2962 } 2963 } 2964 2965 for (var _i16 = 0, _total13 = lines.length; _i16 < _total13; _i16++) { 2966 var style = void 0, 2967 _temp = { 2968 start: null, 2969 stop: null, 2970 style: null, 2971 text: null 2972 }; 2973 2974 if (lines[_i16].getAttribute('begin')) { 2975 _temp.start = (0, _time.convertSMPTEtoSeconds)(lines[_i16].getAttribute('begin')); 2976 } 2977 if (!_temp.start && lines[_i16 - 1].getAttribute('end')) { 2978 _temp.start = (0, _time.convertSMPTEtoSeconds)(lines[_i16 - 1].getAttribute('end')); 2979 } 2980 if (lines[_i16].getAttribute('end')) { 2981 _temp.stop = (0, _time.convertSMPTEtoSeconds)(lines[_i16].getAttribute('end')); 2982 } 2983 if (!_temp.stop && lines[_i16 + 1].getAttribute('begin')) { 2984 _temp.stop = (0, _time.convertSMPTEtoSeconds)(lines[_i16 + 1].getAttribute('begin')); 2985 } 2986 2987 if (styles) { 2988 style = ''; 2989 for (var _style in styles) { 2990 style += _style + ': ' + styles[_style] + ';'; 2991 } 2992 } 2993 if (style) { 2994 _temp.style = style; 2995 } 2996 if (_temp.start === 0) { 2997 _temp.start = 0.200; 2998 } 2999 _temp.text = lines[_i16].innerHTML.trim().replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_| !:, .; ]*[-A-Z0-9+&@#\/%=~_|])/ig, "<a href='$1' target='_blank'>$1</a>"); 3000 entries.push(_temp); 3001 } 3002 return entries; 3003 } 3004 } 3005 }; 3006 3007 },{"16":16,"2":2,"26":26,"27":27,"30":30,"5":5,"7":7}],14:[function(_dereq_,module,exports){ 3008 'use strict'; 3009 3010 var _document = _dereq_(2); 3011 3012 var _document2 = _interopRequireDefault(_document); 3013 3014 var _player = _dereq_(16); 3015 3016 var _player2 = _interopRequireDefault(_player); 3017 3018 var _i18n = _dereq_(5); 3019 3020 var _i18n2 = _interopRequireDefault(_i18n); 3021 3022 var _constants = _dereq_(25); 3023 3024 var _general = _dereq_(27); 3025 3026 var _dom = _dereq_(26); 3027 3028 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3029 3030 Object.assign(_player.config, { 3031 muteText: null, 3032 3033 unmuteText: null, 3034 3035 allyVolumeControlText: null, 3036 3037 hideVolumeOnTouchDevices: true, 3038 3039 audioVolume: 'horizontal', 3040 3041 videoVolume: 'vertical', 3042 3043 startVolume: 0.8 3044 }); 3045 3046 Object.assign(_player2.default.prototype, { 3047 buildvolume: function buildvolume(player, controls, layers, media) { 3048 if ((_constants.IS_ANDROID || _constants.IS_IOS) && this.options.hideVolumeOnTouchDevices) { 3049 return; 3050 } 3051 3052 var t = this, 3053 mode = t.isVideo ? t.options.videoVolume : t.options.audioVolume, 3054 muteText = (0, _general.isString)(t.options.muteText) ? t.options.muteText : _i18n2.default.t('mejs.mute'), 3055 unmuteText = (0, _general.isString)(t.options.unmuteText) ? t.options.unmuteText : _i18n2.default.t('mejs.unmute'), 3056 volumeControlText = (0, _general.isString)(t.options.allyVolumeControlText) ? t.options.allyVolumeControlText : _i18n2.default.t('mejs.volume-help-text'), 3057 mute = _document2.default.createElement('div'); 3058 3059 mute.className = t.options.classPrefix + 'button ' + t.options.classPrefix + 'volume-button ' + t.options.classPrefix + 'mute'; 3060 mute.innerHTML = mode === 'horizontal' ? '<button type="button" aria-controls="' + t.id + '" title="' + muteText + '" aria-label="' + muteText + '" tabindex="0"></button>' : '<button type="button" aria-controls="' + t.id + '" title="' + muteText + '" aria-label="' + muteText + '" tabindex="0"></button>' + ('<a href="javascript:void(0);" class="' + t.options.classPrefix + 'volume-slider" ') + ('aria-label="' + _i18n2.default.t('mejs.volume-slider') + '" aria-valuemin="0" aria-valuemax="100" role="slider" ') + 'aria-orientation="vertical">' + ('<span class="' + t.options.classPrefix + 'offscreen">' + volumeControlText + '</span>') + ('<div class="' + t.options.classPrefix + 'volume-total">') + ('<div class="' + t.options.classPrefix + 'volume-current"></div>') + ('<div class="' + t.options.classPrefix + 'volume-handle"></div>') + '</div>' + '</a>'; 3061 3062 t.addControlElement(mute, 'volume'); 3063 3064 t.options.keyActions.push({ 3065 keys: [38], 3066 action: function action(player) { 3067 var volumeSlider = player.getElement(player.container).querySelector('.' + t.options.classPrefix + 'volume-slider'); 3068 if (volumeSlider && volumeSlider.matches(':focus')) { 3069 volumeSlider.style.display = 'block'; 3070 } 3071 if (player.isVideo) { 3072 player.showControls(); 3073 player.startControlsTimer(); 3074 } 3075 3076 var newVolume = Math.min(player.volume + 0.1, 1); 3077 player.setVolume(newVolume); 3078 if (newVolume > 0) { 3079 player.setMuted(false); 3080 } 3081 } 3082 }, { 3083 keys: [40], 3084 action: function action(player) { 3085 var volumeSlider = player.getElement(player.container).querySelector('.' + t.options.classPrefix + 'volume-slider'); 3086 if (volumeSlider) { 3087 volumeSlider.style.display = 'block'; 3088 } 3089 3090 if (player.isVideo) { 3091 player.showControls(); 3092 player.startControlsTimer(); 3093 } 3094 3095 var newVolume = Math.max(player.volume - 0.1, 0); 3096 player.setVolume(newVolume); 3097 3098 if (newVolume <= 0.1) { 3099 player.setMuted(true); 3100 } 3101 } 3102 }, { 3103 keys: [77], 3104 action: function action(player) { 3105 var volumeSlider = player.getElement(player.container).querySelector('.' + t.options.classPrefix + 'volume-slider'); 3106 if (volumeSlider) { 3107 volumeSlider.style.display = 'block'; 3108 } 3109 3110 if (player.isVideo) { 3111 player.showControls(); 3112 player.startControlsTimer(); 3113 } 3114 if (player.media.muted) { 3115 player.setMuted(false); 3116 } else { 3117 player.setMuted(true); 3118 } 3119 } 3120 }); 3121 3122 if (mode === 'horizontal') { 3123 var anchor = _document2.default.createElement('a'); 3124 anchor.className = t.options.classPrefix + 'horizontal-volume-slider'; 3125 anchor.href = 'javascript:void(0);'; 3126 anchor.setAttribute('aria-label', _i18n2.default.t('mejs.volume-slider')); 3127 anchor.setAttribute('aria-valuemin', 0); 3128 anchor.setAttribute('aria-valuemax', 100); 3129 anchor.setAttribute('aria-valuenow', 100); 3130 anchor.setAttribute('role', 'slider'); 3131 anchor.innerHTML += '<span class="' + t.options.classPrefix + 'offscreen">' + volumeControlText + '</span>' + ('<div class="' + t.options.classPrefix + 'horizontal-volume-total">') + ('<div class="' + t.options.classPrefix + 'horizontal-volume-current"></div>') + ('<div class="' + t.options.classPrefix + 'horizontal-volume-handle"></div>') + '</div>'; 3132 mute.parentNode.insertBefore(anchor, mute.nextSibling); 3133 } 3134 3135 var mouseIsDown = false, 3136 mouseIsOver = false, 3137 modified = false, 3138 updateVolumeSlider = function updateVolumeSlider() { 3139 var volume = Math.floor(media.volume * 100); 3140 volumeSlider.setAttribute('aria-valuenow', volume); 3141 volumeSlider.setAttribute('aria-valuetext', volume + '%'); 3142 }; 3143 3144 var volumeSlider = mode === 'vertical' ? t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'volume-slider') : t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'horizontal-volume-slider'), 3145 volumeTotal = mode === 'vertical' ? t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'volume-total') : t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'horizontal-volume-total'), 3146 volumeCurrent = mode === 'vertical' ? t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'volume-current') : t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'horizontal-volume-current'), 3147 volumeHandle = mode === 'vertical' ? t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'volume-handle') : t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'horizontal-volume-handle'), 3148 positionVolumeHandle = function positionVolumeHandle(volume) { 3149 3150 if (volume === null || isNaN(volume) || volume === undefined) { 3151 return; 3152 } 3153 3154 volume = Math.max(0, volume); 3155 volume = Math.min(volume, 1); 3156 3157 if (volume === 0) { 3158 (0, _dom.removeClass)(mute, t.options.classPrefix + 'mute'); 3159 (0, _dom.addClass)(mute, t.options.classPrefix + 'unmute'); 3160 var button = mute.firstElementChild; 3161 button.setAttribute('title', unmuteText); 3162 button.setAttribute('aria-label', unmuteText); 3163 } else { 3164 (0, _dom.removeClass)(mute, t.options.classPrefix + 'unmute'); 3165 (0, _dom.addClass)(mute, t.options.classPrefix + 'mute'); 3166 var _button = mute.firstElementChild; 3167 _button.setAttribute('title', muteText); 3168 _button.setAttribute('aria-label', muteText); 3169 } 3170 3171 var volumePercentage = volume * 100 + '%', 3172 volumeStyles = getComputedStyle(volumeHandle); 3173 3174 if (mode === 'vertical') { 3175 volumeCurrent.style.bottom = 0; 3176 volumeCurrent.style.height = volumePercentage; 3177 volumeHandle.style.bottom = volumePercentage; 3178 volumeHandle.style.marginBottom = -parseFloat(volumeStyles.height) / 2 + 'px'; 3179 } else { 3180 volumeCurrent.style.left = 0; 3181 volumeCurrent.style.width = volumePercentage; 3182 volumeHandle.style.left = volumePercentage; 3183 volumeHandle.style.marginLeft = -parseFloat(volumeStyles.width) / 2 + 'px'; 3184 } 3185 }, 3186 handleVolumeMove = function handleVolumeMove(e) { 3187 var totalOffset = (0, _dom.offset)(volumeTotal), 3188 volumeStyles = getComputedStyle(volumeTotal); 3189 3190 modified = true; 3191 3192 var volume = null; 3193 3194 if (mode === 'vertical') { 3195 var railHeight = parseFloat(volumeStyles.height), 3196 newY = e.pageY - totalOffset.top; 3197 3198 volume = (railHeight - newY) / railHeight; 3199 3200 if (totalOffset.top === 0 || totalOffset.left === 0) { 3201 return; 3202 } 3203 } else { 3204 var railWidth = parseFloat(volumeStyles.width), 3205 newX = e.pageX - totalOffset.left; 3206 3207 volume = newX / railWidth; 3208 } 3209 3210 volume = Math.max(0, volume); 3211 volume = Math.min(volume, 1); 3212 3213 positionVolumeHandle(volume); 3214 3215 t.setMuted(volume === 0); 3216 t.setVolume(volume); 3217 3218 e.preventDefault(); 3219 e.stopPropagation(); 3220 }, 3221 toggleMute = function toggleMute() { 3222 if (t.muted) { 3223 positionVolumeHandle(0); 3224 (0, _dom.removeClass)(mute, t.options.classPrefix + 'mute'); 3225 (0, _dom.addClass)(mute, t.options.classPrefix + 'unmute'); 3226 } else { 3227 3228 positionVolumeHandle(media.volume); 3229 (0, _dom.removeClass)(mute, t.options.classPrefix + 'unmute'); 3230 (0, _dom.addClass)(mute, t.options.classPrefix + 'mute'); 3231 } 3232 }; 3233 3234 player.getElement(player.container).addEventListener('keydown', function (e) { 3235 var hasFocus = !!e.target.closest('.' + t.options.classPrefix + 'container'); 3236 if (!hasFocus && mode === 'vertical') { 3237 volumeSlider.style.display = 'none'; 3238 } 3239 }); 3240 3241 mute.addEventListener('mouseenter', function (e) { 3242 if (e.target === mute) { 3243 volumeSlider.style.display = 'block'; 3244 mouseIsOver = true; 3245 e.preventDefault(); 3246 e.stopPropagation(); 3247 } 3248 }); 3249 mute.addEventListener('focusin', function () { 3250 volumeSlider.style.display = 'block'; 3251 mouseIsOver = true; 3252 }); 3253 3254 mute.addEventListener('focusout', function (e) { 3255 if ((!e.relatedTarget || e.relatedTarget && !e.relatedTarget.matches('.' + t.options.classPrefix + 'volume-slider')) && mode === 'vertical') { 3256 volumeSlider.style.display = 'none'; 3257 } 3258 }); 3259 mute.addEventListener('mouseleave', function () { 3260 mouseIsOver = false; 3261 if (!mouseIsDown && mode === 'vertical') { 3262 volumeSlider.style.display = 'none'; 3263 } 3264 }); 3265 mute.addEventListener('focusout', function () { 3266 mouseIsOver = false; 3267 }); 3268 mute.addEventListener('keydown', function (e) { 3269 if (t.options.enableKeyboard && t.options.keyActions.length) { 3270 var keyCode = e.which || e.keyCode || 0, 3271 volume = media.volume; 3272 3273 switch (keyCode) { 3274 case 38: 3275 volume = Math.min(volume + 0.1, 1); 3276 break; 3277 case 40: 3278 volume = Math.max(0, volume - 0.1); 3279 break; 3280 default: 3281 return true; 3282 } 3283 3284 mouseIsDown = false; 3285 positionVolumeHandle(volume); 3286 media.setVolume(volume); 3287 3288 e.preventDefault(); 3289 e.stopPropagation(); 3290 } 3291 }); 3292 mute.querySelector('button').addEventListener('click', function () { 3293 media.setMuted(!media.muted); 3294 var event = (0, _general.createEvent)('volumechange', media); 3295 media.dispatchEvent(event); 3296 }); 3297 3298 volumeSlider.addEventListener('dragstart', function () { 3299 return false; 3300 }); 3301 3302 volumeSlider.addEventListener('mouseover', function () { 3303 mouseIsOver = true; 3304 }); 3305 volumeSlider.addEventListener('focusin', function () { 3306 volumeSlider.style.display = 'block'; 3307 mouseIsOver = true; 3308 }); 3309 volumeSlider.addEventListener('focusout', function () { 3310 mouseIsOver = false; 3311 if (!mouseIsDown && mode === 'vertical') { 3312 volumeSlider.style.display = 'none'; 3313 } 3314 }); 3315 volumeSlider.addEventListener('mousedown', function (e) { 3316 handleVolumeMove(e); 3317 t.globalBind('mousemove.vol', function (event) { 3318 var target = event.target; 3319 if (mouseIsDown && (target === volumeSlider || target.closest(mode === 'vertical' ? '.' + t.options.classPrefix + 'volume-slider' : '.' + t.options.classPrefix + 'horizontal-volume-slider'))) { 3320 handleVolumeMove(event); 3321 } 3322 }); 3323 t.globalBind('mouseup.vol', function () { 3324 mouseIsDown = false; 3325 if (!mouseIsOver && mode === 'vertical') { 3326 volumeSlider.style.display = 'none'; 3327 } 3328 }); 3329 mouseIsDown = true; 3330 e.preventDefault(); 3331 e.stopPropagation(); 3332 }); 3333 3334 media.addEventListener('volumechange', function (e) { 3335 if (!mouseIsDown) { 3336 toggleMute(); 3337 } 3338 updateVolumeSlider(e); 3339 }); 3340 3341 var rendered = false; 3342 media.addEventListener('rendererready', function () { 3343 if (!modified) { 3344 setTimeout(function () { 3345 rendered = true; 3346 if (player.options.startVolume === 0 || media.originalNode.muted) { 3347 media.setMuted(true); 3348 } 3349 media.setVolume(player.options.startVolume); 3350 t.setControlsSize(); 3351 }, 250); 3352 } 3353 }); 3354 3355 media.addEventListener('loadedmetadata', function () { 3356 setTimeout(function () { 3357 if (!modified && !rendered) { 3358 if (player.options.startVolume === 0 || media.originalNode.muted) { 3359 media.setMuted(true); 3360 } 3361 if (player.options.startVolume === 0) { 3362 player.options.startVolume = 0; 3363 } 3364 media.setVolume(player.options.startVolume); 3365 t.setControlsSize(); 3366 } 3367 rendered = false; 3368 }, 250); 3369 }); 3370 3371 if (player.options.startVolume === 0 || media.originalNode.muted) { 3372 media.setMuted(true); 3373 if (player.options.startVolume === 0) { 3374 player.options.startVolume = 0; 3375 } 3376 toggleMute(); 3377 } 3378 3379 t.getElement(t.container).addEventListener('controlsresize', function () { 3380 toggleMute(); 3381 }); 3382 } 3383 }); 3384 3385 },{"16":16,"2":2,"25":25,"26":26,"27":27,"5":5}],15:[function(_dereq_,module,exports){ 3386 'use strict'; 3387 3388 Object.defineProperty(exports, "__esModule", { 3389 value: true 3390 }); 3391 var EN = exports.EN = { 3392 'mejs.plural-form': 1, 3393 3394 'mejs.download-file': 'Download File', 3395 3396 'mejs.install-flash': 'You are using a browser that does not have Flash player enabled or installed. Please turn on your Flash player plugin or download the latest version from https://get.adobe.com/flashplayer/', 3397 3398 'mejs.fullscreen': 'Fullscreen', 3399 3400 'mejs.play': 'Play', 3401 'mejs.pause': 'Pause', 3402 3403 'mejs.time-slider': 'Time Slider', 3404 'mejs.time-help-text': 'Use Left/Right Arrow keys to advance one second, Up/Down arrows to advance ten seconds.', 3405 'mejs.live-broadcast': 'Live Broadcast', 3406 3407 'mejs.volume-help-text': 'Use Up/Down Arrow keys to increase or decrease volume.', 3408 'mejs.unmute': 'Unmute', 3409 'mejs.mute': 'Mute', 3410 'mejs.volume-slider': 'Volume Slider', 3411 3412 'mejs.video-player': 'Video Player', 3413 'mejs.audio-player': 'Audio Player', 3414 3415 'mejs.captions-subtitles': 'Captions/Subtitles', 3416 'mejs.captions-chapters': 'Chapters', 3417 'mejs.none': 'None', 3418 'mejs.afrikaans': 'Afrikaans', 3419 'mejs.albanian': 'Albanian', 3420 'mejs.arabic': 'Arabic', 3421 'mejs.belarusian': 'Belarusian', 3422 'mejs.bulgarian': 'Bulgarian', 3423 'mejs.catalan': 'Catalan', 3424 'mejs.chinese': 'Chinese', 3425 'mejs.chinese-simplified': 'Chinese (Simplified)', 3426 'mejs.chinese-traditional': 'Chinese (Traditional)', 3427 'mejs.croatian': 'Croatian', 3428 'mejs.czech': 'Czech', 3429 'mejs.danish': 'Danish', 3430 'mejs.dutch': 'Dutch', 3431 'mejs.english': 'English', 3432 'mejs.estonian': 'Estonian', 3433 'mejs.filipino': 'Filipino', 3434 'mejs.finnish': 'Finnish', 3435 'mejs.french': 'French', 3436 'mejs.galician': 'Galician', 3437 'mejs.german': 'German', 3438 'mejs.greek': 'Greek', 3439 'mejs.haitian-creole': 'Haitian Creole', 3440 'mejs.hebrew': 'Hebrew', 3441 'mejs.hindi': 'Hindi', 3442 'mejs.hungarian': 'Hungarian', 3443 'mejs.icelandic': 'Icelandic', 3444 'mejs.indonesian': 'Indonesian', 3445 'mejs.irish': 'Irish', 3446 'mejs.italian': 'Italian', 3447 'mejs.japanese': 'Japanese', 3448 'mejs.korean': 'Korean', 3449 'mejs.latvian': 'Latvian', 3450 'mejs.lithuanian': 'Lithuanian', 3451 'mejs.macedonian': 'Macedonian', 3452 'mejs.malay': 'Malay', 3453 'mejs.maltese': 'Maltese', 3454 'mejs.norwegian': 'Norwegian', 3455 'mejs.persian': 'Persian', 3456 'mejs.polish': 'Polish', 3457 'mejs.portuguese': 'Portuguese', 3458 'mejs.romanian': 'Romanian', 3459 'mejs.russian': 'Russian', 3460 'mejs.serbian': 'Serbian', 3461 'mejs.slovak': 'Slovak', 3462 'mejs.slovenian': 'Slovenian', 3463 'mejs.spanish': 'Spanish', 3464 'mejs.swahili': 'Swahili', 3465 'mejs.swedish': 'Swedish', 3466 'mejs.tagalog': 'Tagalog', 3467 'mejs.thai': 'Thai', 3468 'mejs.turkish': 'Turkish', 3469 'mejs.ukrainian': 'Ukrainian', 3470 'mejs.vietnamese': 'Vietnamese', 3471 'mejs.welsh': 'Welsh', 3472 'mejs.yiddish': 'Yiddish' 3473 }; 3474 3475 },{}],16:[function(_dereq_,module,exports){ 3476 'use strict'; 3477 3478 Object.defineProperty(exports, "__esModule", { 3479 value: true 3480 }); 3481 exports.config = undefined; 3482 3483 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 3484 3485 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; }; }(); 3486 3487 var _window = _dereq_(3); 3488 3489 var _window2 = _interopRequireDefault(_window); 3490 3491 var _document = _dereq_(2); 3492 3493 var _document2 = _interopRequireDefault(_document); 3494 3495 var _mejs = _dereq_(7); 3496 3497 var _mejs2 = _interopRequireDefault(_mejs); 3498 3499 var _mediaelement = _dereq_(6); 3500 3501 var _mediaelement2 = _interopRequireDefault(_mediaelement); 3502 3503 var _default = _dereq_(17); 3504 3505 var _default2 = _interopRequireDefault(_default); 3506 3507 var _i18n = _dereq_(5); 3508 3509 var _i18n2 = _interopRequireDefault(_i18n); 3510 3511 var _constants = _dereq_(25); 3512 3513 var _general = _dereq_(27); 3514 3515 var _time = _dereq_(30); 3516 3517 var _media = _dereq_(28); 3518 3519 var _dom = _dereq_(26); 3520 3521 var dom = _interopRequireWildcard(_dom); 3522 3523 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } 3524 3525 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3526 3527 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 3528 3529 _mejs2.default.mepIndex = 0; 3530 3531 _mejs2.default.players = {}; 3532 3533 var config = exports.config = { 3534 poster: '', 3535 3536 showPosterWhenEnded: false, 3537 3538 showPosterWhenPaused: false, 3539 3540 defaultVideoWidth: 480, 3541 3542 defaultVideoHeight: 270, 3543 3544 videoWidth: -1, 3545 3546 videoHeight: -1, 3547 3548 defaultAudioWidth: 400, 3549 3550 defaultAudioHeight: 40, 3551 3552 defaultSeekBackwardInterval: function defaultSeekBackwardInterval(media) { 3553 return media.getDuration() * 0.05; 3554 }, 3555 3556 defaultSeekForwardInterval: function defaultSeekForwardInterval(media) { 3557 return media.getDuration() * 0.05; 3558 }, 3559 3560 setDimensions: true, 3561 3562 audioWidth: -1, 3563 3564 audioHeight: -1, 3565 3566 loop: false, 3567 3568 autoRewind: true, 3569 3570 enableAutosize: true, 3571 3572 timeFormat: '', 3573 3574 alwaysShowHours: false, 3575 3576 showTimecodeFrameCount: false, 3577 3578 framesPerSecond: 25, 3579 3580 alwaysShowControls: false, 3581 3582 hideVideoControlsOnLoad: false, 3583 3584 hideVideoControlsOnPause: false, 3585 3586 clickToPlayPause: true, 3587 3588 controlsTimeoutDefault: 1500, 3589 3590 controlsTimeoutMouseEnter: 2500, 3591 3592 controlsTimeoutMouseLeave: 1000, 3593 3594 iPadUseNativeControls: false, 3595 3596 iPhoneUseNativeControls: false, 3597 3598 AndroidUseNativeControls: false, 3599 3600 features: ['playpause', 'current', 'progress', 'duration', 'tracks', 'volume', 'fullscreen'], 3601 3602 useDefaultControls: false, 3603 3604 isVideo: true, 3605 3606 stretching: 'auto', 3607 3608 classPrefix: 'mejs__', 3609 3610 enableKeyboard: true, 3611 3612 pauseOtherPlayers: true, 3613 3614 secondsDecimalLength: 0, 3615 3616 customError: null, 3617 3618 keyActions: [{ 3619 keys: [32, 179], 3620 action: function action(player) { 3621 3622 if (!_constants.IS_FIREFOX) { 3623 if (player.paused || player.ended) { 3624 player.play(); 3625 } else { 3626 player.pause(); 3627 } 3628 } 3629 } 3630 }] 3631 }; 3632 3633 _mejs2.default.MepDefaults = config; 3634 3635 var MediaElementPlayer = function () { 3636 function MediaElementPlayer(node, o) { 3637 _classCallCheck(this, MediaElementPlayer); 3638 3639 var t = this, 3640 element = typeof node === 'string' ? _document2.default.getElementById(node) : node; 3641 3642 if (!(t instanceof MediaElementPlayer)) { 3643 return new MediaElementPlayer(element, o); 3644 } 3645 3646 t.node = t.media = element; 3647 3648 if (!t.node) { 3649 return; 3650 } 3651 3652 if (t.media.player) { 3653 return t.media.player; 3654 } 3655 3656 t.hasFocus = false; 3657 3658 t.controlsAreVisible = true; 3659 3660 t.controlsEnabled = true; 3661 3662 t.controlsTimer = null; 3663 3664 t.currentMediaTime = 0; 3665 3666 t.proxy = null; 3667 3668 if (o === undefined) { 3669 var options = t.node.getAttribute('data-mejsoptions'); 3670 o = options ? JSON.parse(options) : {}; 3671 } 3672 3673 t.options = Object.assign({}, config, o); 3674 3675 if (t.options.loop && !t.media.getAttribute('loop')) { 3676 t.media.loop = true; 3677 t.node.loop = true; 3678 } else if (t.media.loop) { 3679 t.options.loop = true; 3680 } 3681 3682 if (!t.options.timeFormat) { 3683 t.options.timeFormat = 'mm:ss'; 3684 if (t.options.alwaysShowHours) { 3685 t.options.timeFormat = 'hh:mm:ss'; 3686 } 3687 if (t.options.showTimecodeFrameCount) { 3688 t.options.timeFormat += ':ff'; 3689 } 3690 } 3691 3692 (0, _time.calculateTimeFormat)(0, t.options, t.options.framesPerSecond || 25); 3693 3694 t.id = 'mep_' + _mejs2.default.mepIndex++; 3695 3696 _mejs2.default.players[t.id] = t; 3697 3698 t.init(); 3699 3700 return t; 3701 } 3702 3703 _createClass(MediaElementPlayer, [{ 3704 key: 'getElement', 3705 value: function getElement(element) { 3706 return element; 3707 } 3708 }, { 3709 key: 'init', 3710 value: function init() { 3711 var t = this, 3712 playerOptions = Object.assign({}, t.options, { 3713 success: function success(media, domNode) { 3714 t._meReady(media, domNode); 3715 }, 3716 error: function error(e) { 3717 t._handleError(e); 3718 } 3719 }), 3720 tagName = t.node.tagName.toLowerCase(); 3721 3722 t.isDynamic = tagName !== 'audio' && tagName !== 'video' && tagName !== 'iframe'; 3723 t.isVideo = t.isDynamic ? t.options.isVideo : tagName !== 'audio' && t.options.isVideo; 3724 t.mediaFiles = null; 3725 t.trackFiles = null; 3726 3727 if (_constants.IS_IPAD && t.options.iPadUseNativeControls || _constants.IS_IPHONE && t.options.iPhoneUseNativeControls) { 3728 t.node.setAttribute('controls', true); 3729 3730 if (_constants.IS_IPAD && t.node.getAttribute('autoplay')) { 3731 t.play(); 3732 } 3733 } else if ((t.isVideo || !t.isVideo && (t.options.features.length || t.options.useDefaultControls)) && !(_constants.IS_ANDROID && t.options.AndroidUseNativeControls)) { 3734 t.node.removeAttribute('controls'); 3735 var videoPlayerTitle = t.isVideo ? _i18n2.default.t('mejs.video-player') : _i18n2.default.t('mejs.audio-player'); 3736 3737 var offscreen = _document2.default.createElement('span'); 3738 offscreen.className = t.options.classPrefix + 'offscreen'; 3739 offscreen.innerText = videoPlayerTitle; 3740 t.media.parentNode.insertBefore(offscreen, t.media); 3741 3742 t.container = _document2.default.createElement('div'); 3743 t.getElement(t.container).id = t.id; 3744 t.getElement(t.container).className = t.options.classPrefix + 'container ' + t.options.classPrefix + 'container-keyboard-inactive ' + t.media.className; 3745 t.getElement(t.container).tabIndex = 0; 3746 t.getElement(t.container).setAttribute('role', 'application'); 3747 t.getElement(t.container).setAttribute('aria-label', videoPlayerTitle); 3748 t.getElement(t.container).innerHTML = '<div class="' + t.options.classPrefix + 'inner">' + ('<div class="' + t.options.classPrefix + 'mediaelement"></div>') + ('<div class="' + t.options.classPrefix + 'layers"></div>') + ('<div class="' + t.options.classPrefix + 'controls"></div>') + '</div>'; 3749 t.getElement(t.container).addEventListener('focus', function (e) { 3750 if (!t.controlsAreVisible && !t.hasFocus && t.controlsEnabled) { 3751 t.showControls(true); 3752 3753 var btnSelector = (0, _general.isNodeAfter)(e.relatedTarget, t.getElement(t.container)) ? '.' + t.options.classPrefix + 'controls .' + t.options.classPrefix + 'button:last-child > button' : '.' + t.options.classPrefix + 'playpause-button > button', 3754 button = t.getElement(t.container).querySelector(btnSelector); 3755 3756 button.focus(); 3757 } 3758 }); 3759 t.node.parentNode.insertBefore(t.getElement(t.container), t.node); 3760 3761 if (!t.options.features.length && !t.options.useDefaultControls) { 3762 t.getElement(t.container).style.background = 'transparent'; 3763 t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'controls').style.display = 'none'; 3764 } 3765 3766 if (t.isVideo && t.options.stretching === 'fill' && !dom.hasClass(t.getElement(t.container).parentNode, t.options.classPrefix + 'fill-container')) { 3767 t.outerContainer = t.media.parentNode; 3768 3769 var wrapper = _document2.default.createElement('div'); 3770 wrapper.className = t.options.classPrefix + 'fill-container'; 3771 t.getElement(t.container).parentNode.insertBefore(wrapper, t.getElement(t.container)); 3772 wrapper.appendChild(t.getElement(t.container)); 3773 } 3774 3775 if (_constants.IS_ANDROID) { 3776 dom.addClass(t.getElement(t.container), t.options.classPrefix + 'android'); 3777 } 3778 if (_constants.IS_IOS) { 3779 dom.addClass(t.getElement(t.container), t.options.classPrefix + 'ios'); 3780 } 3781 if (_constants.IS_IPAD) { 3782 dom.addClass(t.getElement(t.container), t.options.classPrefix + 'ipad'); 3783 } 3784 if (_constants.IS_IPHONE) { 3785 dom.addClass(t.getElement(t.container), t.options.classPrefix + 'iphone'); 3786 } 3787 dom.addClass(t.getElement(t.container), t.isVideo ? t.options.classPrefix + 'video' : t.options.classPrefix + 'audio'); 3788 3789 t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'mediaelement').appendChild(t.node); 3790 3791 t.media.player = t; 3792 3793 t.controls = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'controls'); 3794 t.layers = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'layers'); 3795 3796 var tagType = t.isVideo ? 'video' : 'audio', 3797 capsTagName = tagType.substring(0, 1).toUpperCase() + tagType.substring(1); 3798 3799 if (t.options[tagType + 'Width'] > 0 || t.options[tagType + 'Width'].toString().indexOf('%') > -1) { 3800 t.width = t.options[tagType + 'Width']; 3801 } else if (t.node.style.width !== '' && t.node.style.width !== null) { 3802 t.width = t.node.style.width; 3803 } else if (t.node.getAttribute('width')) { 3804 t.width = t.node.getAttribute('width'); 3805 } else { 3806 t.width = t.options['default' + capsTagName + 'Width']; 3807 } 3808 3809 if (t.options[tagType + 'Height'] > 0 || t.options[tagType + 'Height'].toString().indexOf('%') > -1) { 3810 t.height = t.options[tagType + 'Height']; 3811 } else if (t.node.style.height !== '' && t.node.style.height !== null) { 3812 t.height = t.node.style.height; 3813 } else if (t.node.getAttribute('height')) { 3814 t.height = t.node.getAttribute('height'); 3815 } else { 3816 t.height = t.options['default' + capsTagName + 'Height']; 3817 } 3818 3819 t.initialAspectRatio = t.height >= t.width ? t.width / t.height : t.height / t.width; 3820 3821 t.setPlayerSize(t.width, t.height); 3822 3823 playerOptions.pluginWidth = t.width; 3824 playerOptions.pluginHeight = t.height; 3825 } else if (!t.isVideo && !t.options.features.length && !t.options.useDefaultControls) { 3826 t.node.style.display = 'none'; 3827 } 3828 3829 _mejs2.default.MepDefaults = playerOptions; 3830 3831 new _mediaelement2.default(t.media, playerOptions, t.mediaFiles); 3832 3833 if (t.getElement(t.container) !== undefined && t.options.features.length && t.controlsAreVisible && !t.options.hideVideoControlsOnLoad) { 3834 var event = (0, _general.createEvent)('controlsshown', t.getElement(t.container)); 3835 t.getElement(t.container).dispatchEvent(event); 3836 } 3837 } 3838 }, { 3839 key: 'showControls', 3840 value: function showControls(doAnimation) { 3841 var t = this; 3842 3843 doAnimation = doAnimation === undefined || doAnimation; 3844 3845 if (t.controlsAreVisible || !t.isVideo) { 3846 return; 3847 } 3848 3849 if (doAnimation) { 3850 (function () { 3851 dom.fadeIn(t.getElement(t.controls), 200, function () { 3852 dom.removeClass(t.getElement(t.controls), t.options.classPrefix + 'offscreen'); 3853 var event = (0, _general.createEvent)('controlsshown', t.getElement(t.container)); 3854 t.getElement(t.container).dispatchEvent(event); 3855 }); 3856 3857 var controls = t.getElement(t.container).querySelectorAll('.' + t.options.classPrefix + 'control'); 3858 3859 var _loop = function _loop(i, total) { 3860 dom.fadeIn(controls[i], 200, function () { 3861 dom.removeClass(controls[i], t.options.classPrefix + 'offscreen'); 3862 }); 3863 }; 3864 3865 for (var i = 0, total = controls.length; i < total; i++) { 3866 _loop(i, total); 3867 } 3868 })(); 3869 } else { 3870 dom.removeClass(t.getElement(t.controls), t.options.classPrefix + 'offscreen'); 3871 t.getElement(t.controls).style.display = ''; 3872 t.getElement(t.controls).style.opacity = 1; 3873 3874 var controls = t.getElement(t.container).querySelectorAll('.' + t.options.classPrefix + 'control'); 3875 for (var i = 0, total = controls.length; i < total; i++) { 3876 dom.removeClass(controls[i], t.options.classPrefix + 'offscreen'); 3877 controls[i].style.display = ''; 3878 } 3879 3880 var event = (0, _general.createEvent)('controlsshown', t.getElement(t.container)); 3881 t.getElement(t.container).dispatchEvent(event); 3882 } 3883 3884 t.controlsAreVisible = true; 3885 t.setControlsSize(); 3886 } 3887 }, { 3888 key: 'hideControls', 3889 value: function hideControls(doAnimation, forceHide) { 3890 var t = this; 3891 3892 doAnimation = doAnimation === undefined || doAnimation; 3893 3894 if (forceHide !== true && (!t.controlsAreVisible || t.options.alwaysShowControls || t.paused && t.readyState === 4 && (!t.options.hideVideoControlsOnLoad && t.currentTime <= 0 || !t.options.hideVideoControlsOnPause && t.currentTime > 0) || t.isVideo && !t.options.hideVideoControlsOnLoad && !t.readyState || t.ended)) { 3895 return; 3896 } 3897 3898 if (doAnimation) { 3899 (function () { 3900 dom.fadeOut(t.getElement(t.controls), 200, function () { 3901 dom.addClass(t.getElement(t.controls), t.options.classPrefix + 'offscreen'); 3902 t.getElement(t.controls).style.display = ''; 3903 var event = (0, _general.createEvent)('controlshidden', t.getElement(t.container)); 3904 t.getElement(t.container).dispatchEvent(event); 3905 }); 3906 3907 var controls = t.getElement(t.container).querySelectorAll('.' + t.options.classPrefix + 'control'); 3908 3909 var _loop2 = function _loop2(i, total) { 3910 dom.fadeOut(controls[i], 200, function () { 3911 dom.addClass(controls[i], t.options.classPrefix + 'offscreen'); 3912 controls[i].style.display = ''; 3913 }); 3914 }; 3915 3916 for (var i = 0, total = controls.length; i < total; i++) { 3917 _loop2(i, total); 3918 } 3919 })(); 3920 } else { 3921 dom.addClass(t.getElement(t.controls), t.options.classPrefix + 'offscreen'); 3922 t.getElement(t.controls).style.display = ''; 3923 t.getElement(t.controls).style.opacity = 0; 3924 3925 var controls = t.getElement(t.container).querySelectorAll('.' + t.options.classPrefix + 'control'); 3926 for (var i = 0, total = controls.length; i < total; i++) { 3927 dom.addClass(controls[i], t.options.classPrefix + 'offscreen'); 3928 controls[i].style.display = ''; 3929 } 3930 3931 var event = (0, _general.createEvent)('controlshidden', t.getElement(t.container)); 3932 t.getElement(t.container).dispatchEvent(event); 3933 } 3934 3935 t.controlsAreVisible = false; 3936 } 3937 }, { 3938 key: 'startControlsTimer', 3939 value: function startControlsTimer(timeout) { 3940 var t = this; 3941 3942 timeout = typeof timeout !== 'undefined' ? timeout : t.options.controlsTimeoutDefault; 3943 3944 t.killControlsTimer('start'); 3945 3946 t.controlsTimer = setTimeout(function () { 3947 t.hideControls(); 3948 t.killControlsTimer('hide'); 3949 }, timeout); 3950 } 3951 }, { 3952 key: 'killControlsTimer', 3953 value: function killControlsTimer() { 3954 var t = this; 3955 3956 if (t.controlsTimer !== null) { 3957 clearTimeout(t.controlsTimer); 3958 delete t.controlsTimer; 3959 t.controlsTimer = null; 3960 } 3961 } 3962 }, { 3963 key: 'disableControls', 3964 value: function disableControls() { 3965 var t = this; 3966 3967 t.killControlsTimer(); 3968 t.controlsEnabled = false; 3969 t.hideControls(false, true); 3970 } 3971 }, { 3972 key: 'enableControls', 3973 value: function enableControls() { 3974 var t = this; 3975 3976 t.controlsEnabled = true; 3977 t.showControls(false); 3978 } 3979 }, { 3980 key: '_setDefaultPlayer', 3981 value: function _setDefaultPlayer() { 3982 var t = this; 3983 if (t.proxy) { 3984 t.proxy.pause(); 3985 } 3986 t.proxy = new _default2.default(t); 3987 t.media.addEventListener('loadedmetadata', function () { 3988 if (t.getCurrentTime() > 0 && t.currentMediaTime > 0) { 3989 t.setCurrentTime(t.currentMediaTime); 3990 if (!_constants.IS_IOS && !_constants.IS_ANDROID) { 3991 t.play(); 3992 } 3993 } 3994 }); 3995 } 3996 }, { 3997 key: '_meReady', 3998 value: function _meReady(media, domNode) { 3999 var t = this, 4000 autoplayAttr = domNode.getAttribute('autoplay'), 4001 autoplay = !(autoplayAttr === undefined || autoplayAttr === null || autoplayAttr === 'false'), 4002 isNative = media.rendererName !== null && /(native|html5)/i.test(media.rendererName); 4003 4004 if (t.getElement(t.controls)) { 4005 t.enableControls(); 4006 } 4007 4008 if (t.getElement(t.container) && t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'overlay-play')) { 4009 t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'overlay-play').style.display = ''; 4010 } 4011 4012 if (t.created) { 4013 return; 4014 } 4015 4016 t.created = true; 4017 t.media = media; 4018 t.domNode = domNode; 4019 4020 if (!(_constants.IS_ANDROID && t.options.AndroidUseNativeControls) && !(_constants.IS_IPAD && t.options.iPadUseNativeControls) && !(_constants.IS_IPHONE && t.options.iPhoneUseNativeControls)) { 4021 if (!t.isVideo && !t.options.features.length && !t.options.useDefaultControls) { 4022 if (autoplay && isNative) { 4023 t.play(); 4024 } 4025 4026 if (t.options.success) { 4027 4028 if (typeof t.options.success === 'string') { 4029 _window2.default[t.options.success](t.media, t.domNode, t); 4030 } else { 4031 t.options.success(t.media, t.domNode, t); 4032 } 4033 } 4034 4035 return; 4036 } 4037 4038 t.featurePosition = {}; 4039 4040 t._setDefaultPlayer(); 4041 4042 t.buildposter(t, t.getElement(t.controls), t.getElement(t.layers), t.media); 4043 t.buildkeyboard(t, t.getElement(t.controls), t.getElement(t.layers), t.media); 4044 t.buildoverlays(t, t.getElement(t.controls), t.getElement(t.layers), t.media); 4045 4046 if (t.options.useDefaultControls) { 4047 var defaultControls = ['playpause', 'current', 'progress', 'duration', 'tracks', 'volume', 'fullscreen']; 4048 t.options.features = defaultControls.concat(t.options.features.filter(function (item) { 4049 return defaultControls.indexOf(item) === -1; 4050 })); 4051 } 4052 4053 t.buildfeatures(t, t.getElement(t.controls), t.getElement(t.layers), t.media); 4054 4055 var event = (0, _general.createEvent)('controlsready', t.getElement(t.container)); 4056 t.getElement(t.container).dispatchEvent(event); 4057 4058 t.setPlayerSize(t.width, t.height); 4059 t.setControlsSize(); 4060 4061 if (t.isVideo) { 4062 t.clickToPlayPauseCallback = function () { 4063 4064 if (t.options.clickToPlayPause) { 4065 var button = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'overlay-button'), 4066 pressed = button.getAttribute('aria-pressed'); 4067 4068 if (t.paused && pressed) { 4069 t.pause(); 4070 } else if (t.paused) { 4071 t.play(); 4072 } else { 4073 t.pause(); 4074 } 4075 4076 button.setAttribute('aria-pressed', !pressed); 4077 t.getElement(t.container).focus(); 4078 } 4079 }; 4080 4081 t.createIframeLayer(); 4082 4083 t.media.addEventListener('click', t.clickToPlayPauseCallback); 4084 4085 if ((_constants.IS_ANDROID || _constants.IS_IOS) && !t.options.alwaysShowControls) { 4086 t.node.addEventListener('touchstart', function () { 4087 if (t.controlsAreVisible) { 4088 t.hideControls(false); 4089 } else { 4090 if (t.controlsEnabled) { 4091 t.showControls(false); 4092 } 4093 } 4094 }, _constants.SUPPORT_PASSIVE_EVENT ? { passive: true } : false); 4095 } else { 4096 t.getElement(t.container).addEventListener('mouseenter', function () { 4097 if (t.controlsEnabled) { 4098 if (!t.options.alwaysShowControls) { 4099 t.killControlsTimer('enter'); 4100 t.showControls(); 4101 t.startControlsTimer(t.options.controlsTimeoutMouseEnter); 4102 } 4103 } 4104 }); 4105 t.getElement(t.container).addEventListener('mousemove', function () { 4106 if (t.controlsEnabled) { 4107 if (!t.controlsAreVisible) { 4108 t.showControls(); 4109 } 4110 if (!t.options.alwaysShowControls) { 4111 t.startControlsTimer(t.options.controlsTimeoutMouseEnter); 4112 } 4113 } 4114 }); 4115 t.getElement(t.container).addEventListener('mouseleave', function () { 4116 if (t.controlsEnabled) { 4117 if (!t.paused && !t.options.alwaysShowControls) { 4118 t.startControlsTimer(t.options.controlsTimeoutMouseLeave); 4119 } 4120 } 4121 }); 4122 } 4123 4124 if (t.options.hideVideoControlsOnLoad) { 4125 t.hideControls(false); 4126 } 4127 4128 if (t.options.enableAutosize) { 4129 t.media.addEventListener('loadedmetadata', function (e) { 4130 var target = e !== undefined ? e.detail.target || e.target : t.media; 4131 if (t.options.videoHeight <= 0 && !t.domNode.getAttribute('height') && !t.domNode.style.height && target !== null && !isNaN(target.videoHeight)) { 4132 t.setPlayerSize(target.videoWidth, target.videoHeight); 4133 t.setControlsSize(); 4134 t.media.setSize(target.videoWidth, target.videoHeight); 4135 } 4136 }); 4137 } 4138 } 4139 4140 t.media.addEventListener('play', function () { 4141 t.hasFocus = true; 4142 4143 for (var playerIndex in _mejs2.default.players) { 4144 if (_mejs2.default.players.hasOwnProperty(playerIndex)) { 4145 var p = _mejs2.default.players[playerIndex]; 4146 4147 if (p.id !== t.id && t.options.pauseOtherPlayers && !p.paused && !p.ended && p.options.ignorePauseOtherPlayersOption !== true) { 4148 p.pause(); 4149 p.hasFocus = false; 4150 } 4151 } 4152 } 4153 4154 if (!(_constants.IS_ANDROID || _constants.IS_IOS) && !t.options.alwaysShowControls && t.isVideo) { 4155 t.hideControls(); 4156 } 4157 }); 4158 4159 t.media.addEventListener('ended', function () { 4160 if (t.options.autoRewind) { 4161 try { 4162 t.setCurrentTime(0); 4163 4164 setTimeout(function () { 4165 var loadingElement = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'overlay-loading'); 4166 if (loadingElement && loadingElement.parentNode) { 4167 loadingElement.parentNode.style.display = 'none'; 4168 } 4169 }, 20); 4170 } catch (exp) { 4171 4172 } 4173 } 4174 4175 if (typeof t.media.renderer.stop === 'function') { 4176 t.media.renderer.stop(); 4177 } else { 4178 t.pause(); 4179 } 4180 4181 if (t.setProgressRail) { 4182 t.setProgressRail(); 4183 } 4184 if (t.setCurrentRail) { 4185 t.setCurrentRail(); 4186 } 4187 4188 if (t.options.loop) { 4189 t.play(); 4190 } else if (!t.options.alwaysShowControls && t.controlsEnabled) { 4191 t.showControls(); 4192 } 4193 }); 4194 4195 t.media.addEventListener('loadedmetadata', function () { 4196 4197 (0, _time.calculateTimeFormat)(t.getDuration(), t.options, t.options.framesPerSecond || 25); 4198 4199 if (t.updateDuration) { 4200 t.updateDuration(); 4201 } 4202 if (t.updateCurrent) { 4203 t.updateCurrent(); 4204 } 4205 4206 if (!t.isFullScreen) { 4207 t.setPlayerSize(t.width, t.height); 4208 t.setControlsSize(); 4209 } 4210 }); 4211 4212 var duration = null; 4213 t.media.addEventListener('timeupdate', function () { 4214 if (!isNaN(t.getDuration()) && duration !== t.getDuration()) { 4215 duration = t.getDuration(); 4216 (0, _time.calculateTimeFormat)(duration, t.options, t.options.framesPerSecond || 25); 4217 4218 if (t.updateDuration) { 4219 t.updateDuration(); 4220 } 4221 if (t.updateCurrent) { 4222 t.updateCurrent(); 4223 } 4224 4225 t.setControlsSize(); 4226 } 4227 }); 4228 4229 t.getElement(t.container).addEventListener('click', function (e) { 4230 dom.addClass(e.currentTarget, t.options.classPrefix + 'container-keyboard-inactive'); 4231 }); 4232 4233 t.getElement(t.container).addEventListener('focusin', function (e) { 4234 dom.removeClass(e.currentTarget, t.options.classPrefix + 'container-keyboard-inactive'); 4235 if (t.isVideo && !_constants.IS_ANDROID && !_constants.IS_IOS && t.controlsEnabled && !t.options.alwaysShowControls) { 4236 t.killControlsTimer('enter'); 4237 t.showControls(); 4238 t.startControlsTimer(t.options.controlsTimeoutMouseEnter); 4239 } 4240 }); 4241 4242 t.getElement(t.container).addEventListener('focusout', function (e) { 4243 setTimeout(function () { 4244 if (e.relatedTarget) { 4245 if (t.keyboardAction && !e.relatedTarget.closest('.' + t.options.classPrefix + 'container')) { 4246 t.keyboardAction = false; 4247 if (t.isVideo && !t.options.alwaysShowControls && !t.paused) { 4248 t.startControlsTimer(t.options.controlsTimeoutMouseLeave); 4249 } 4250 } 4251 } 4252 }, 0); 4253 }); 4254 4255 setTimeout(function () { 4256 t.setPlayerSize(t.width, t.height); 4257 t.setControlsSize(); 4258 }, 0); 4259 4260 t.globalResizeCallback = function () { 4261 if (!(t.isFullScreen || _constants.HAS_TRUE_NATIVE_FULLSCREEN && _document2.default.webkitIsFullScreen)) { 4262 t.setPlayerSize(t.width, t.height); 4263 } 4264 4265 t.setControlsSize(); 4266 }; 4267 4268 t.globalBind('resize', t.globalResizeCallback); 4269 } 4270 4271 if (autoplay && isNative) { 4272 t.play(); 4273 } 4274 4275 if (t.options.success) { 4276 if (typeof t.options.success === 'string') { 4277 _window2.default[t.options.success](t.media, t.domNode, t); 4278 } else { 4279 t.options.success(t.media, t.domNode, t); 4280 } 4281 } 4282 } 4283 }, { 4284 key: '_handleError', 4285 value: function _handleError(e, media, node) { 4286 var t = this, 4287 play = t.getElement(t.layers).querySelector('.' + t.options.classPrefix + 'overlay-play'); 4288 4289 if (play) { 4290 play.style.display = 'none'; 4291 } 4292 4293 if (t.options.error) { 4294 t.options.error(e, media, node); 4295 } 4296 4297 if (t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'cannotplay')) { 4298 t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'cannotplay').remove(); 4299 } 4300 4301 var errorContainer = _document2.default.createElement('div'); 4302 errorContainer.className = t.options.classPrefix + 'cannotplay'; 4303 errorContainer.style.width = '100%'; 4304 errorContainer.style.height = '100%'; 4305 4306 var errorContent = typeof t.options.customError === 'function' ? t.options.customError(t.media, t.media.originalNode) : t.options.customError, 4307 imgError = ''; 4308 4309 if (!errorContent) { 4310 var poster = t.media.originalNode.getAttribute('poster'); 4311 if (poster) { 4312 imgError = '<img src="' + poster + '" alt="' + _mejs2.default.i18n.t('mejs.download-file') + '">'; 4313 } 4314 4315 if (e.message) { 4316 errorContent = '<p>' + e.message + '</p>'; 4317 } 4318 4319 if (e.urls) { 4320 for (var i = 0, total = e.urls.length; i < total; i++) { 4321 var url = e.urls[i]; 4322 errorContent += '<a href="' + url.src + '" data-type="' + url.type + '"><span>' + _mejs2.default.i18n.t('mejs.download-file') + ': ' + url.src + '</span></a>'; 4323 } 4324 } 4325 } 4326 4327 if (errorContent && t.getElement(t.layers).querySelector('.' + t.options.classPrefix + 'overlay-error')) { 4328 errorContainer.innerHTML = errorContent; 4329 t.getElement(t.layers).querySelector('.' + t.options.classPrefix + 'overlay-error').innerHTML = '' + imgError + errorContainer.outerHTML; 4330 t.getElement(t.layers).querySelector('.' + t.options.classPrefix + 'overlay-error').parentNode.style.display = 'block'; 4331 } 4332 4333 if (t.controlsEnabled) { 4334 t.disableControls(); 4335 } 4336 } 4337 }, { 4338 key: 'setPlayerSize', 4339 value: function setPlayerSize(width, height) { 4340 var t = this; 4341 4342 if (!t.options.setDimensions) { 4343 return false; 4344 } 4345 4346 if (typeof width !== 'undefined') { 4347 t.width = width; 4348 } 4349 4350 if (typeof height !== 'undefined') { 4351 t.height = height; 4352 } 4353 4354 switch (t.options.stretching) { 4355 case 'fill': 4356 if (t.isVideo) { 4357 t.setFillMode(); 4358 } else { 4359 t.setDimensions(t.width, t.height); 4360 } 4361 break; 4362 case 'responsive': 4363 t.setResponsiveMode(); 4364 break; 4365 case 'none': 4366 t.setDimensions(t.width, t.height); 4367 break; 4368 4369 default: 4370 if (t.hasFluidMode() === true) { 4371 t.setResponsiveMode(); 4372 } else { 4373 t.setDimensions(t.width, t.height); 4374 } 4375 break; 4376 } 4377 } 4378 }, { 4379 key: 'hasFluidMode', 4380 value: function hasFluidMode() { 4381 var t = this; 4382 4383 return t.height.toString().indexOf('%') !== -1 || t.node && t.node.style.maxWidth && t.node.style.maxWidth !== 'none' && t.node.style.maxWidth !== t.width || t.node && t.node.currentStyle && t.node.currentStyle.maxWidth === '100%'; 4384 } 4385 }, { 4386 key: 'setResponsiveMode', 4387 value: function setResponsiveMode() { 4388 var t = this, 4389 parent = function () { 4390 4391 var parentEl = void 0, 4392 el = t.getElement(t.container); 4393 4394 while (el) { 4395 try { 4396 if (_constants.IS_FIREFOX && el.tagName.toLowerCase() === 'html' && _window2.default.self !== _window2.default.top && _window2.default.frameElement !== null) { 4397 return _window2.default.frameElement; 4398 } else { 4399 parentEl = el.parentElement; 4400 } 4401 } catch (e) { 4402 parentEl = el.parentElement; 4403 } 4404 4405 if (parentEl && dom.visible(parentEl)) { 4406 return parentEl; 4407 } 4408 el = parentEl; 4409 } 4410 4411 return null; 4412 }(), 4413 parentStyles = parent ? getComputedStyle(parent, null) : getComputedStyle(_document2.default.body, null), 4414 nativeWidth = function () { 4415 if (t.isVideo) { 4416 if (t.node.videoWidth && t.node.videoWidth > 0) { 4417 return t.node.videoWidth; 4418 } else if (t.node.getAttribute('width')) { 4419 return t.node.getAttribute('width'); 4420 } else { 4421 return t.options.defaultVideoWidth; 4422 } 4423 } else { 4424 return t.options.defaultAudioWidth; 4425 } 4426 }(), 4427 nativeHeight = function () { 4428 if (t.isVideo) { 4429 if (t.node.videoHeight && t.node.videoHeight > 0) { 4430 return t.node.videoHeight; 4431 } else if (t.node.getAttribute('height')) { 4432 return t.node.getAttribute('height'); 4433 } else { 4434 return t.options.defaultVideoHeight; 4435 } 4436 } else { 4437 return t.options.defaultAudioHeight; 4438 } 4439 }(), 4440 aspectRatio = function () { 4441 if (!t.options.enableAutosize) { 4442 return t.initialAspectRatio; 4443 } 4444 var ratio = 1; 4445 if (!t.isVideo) { 4446 return ratio; 4447 } 4448 4449 if (t.node.videoWidth && t.node.videoWidth > 0 && t.node.videoHeight && t.node.videoHeight > 0) { 4450 ratio = t.height >= t.width ? t.node.videoWidth / t.node.videoHeight : t.node.videoHeight / t.node.videoWidth; 4451 } else { 4452 ratio = t.initialAspectRatio; 4453 } 4454 4455 if (isNaN(ratio) || ratio < 0.01 || ratio > 100) { 4456 ratio = 1; 4457 } 4458 4459 return ratio; 4460 }(), 4461 parentHeight = parseFloat(parentStyles.height); 4462 4463 var newHeight = void 0, 4464 parentWidth = parseFloat(parentStyles.width); 4465 4466 if (t.isVideo) { 4467 if (t.height === '100%') { 4468 newHeight = parseFloat(parentWidth * nativeHeight / nativeWidth, 10); 4469 } else { 4470 newHeight = t.height >= t.width ? parseFloat(parentWidth / aspectRatio, 10) : parseFloat(parentWidth * aspectRatio, 10); 4471 } 4472 } else { 4473 newHeight = nativeHeight; 4474 } 4475 4476 if (isNaN(newHeight)) { 4477 newHeight = parentHeight; 4478 } 4479 4480 if (t.getElement(t.container).parentNode.length > 0 && t.getElement(t.container).parentNode.tagName.toLowerCase() === 'body') { 4481 parentWidth = _window2.default.innerWidth || _document2.default.documentElement.clientWidth || _document2.default.body.clientWidth; 4482 newHeight = _window2.default.innerHeight || _document2.default.documentElement.clientHeight || _document2.default.body.clientHeight; 4483 } 4484 4485 if (newHeight && parentWidth) { 4486 t.getElement(t.container).style.width = parentWidth + 'px'; 4487 t.getElement(t.container).style.height = newHeight + 'px'; 4488 4489 t.node.style.width = '100%'; 4490 t.node.style.height = '100%'; 4491 4492 if (t.isVideo && t.media.setSize) { 4493 t.media.setSize(parentWidth, newHeight); 4494 } 4495 4496 var layerChildren = t.getElement(t.layers).children; 4497 for (var i = 0, total = layerChildren.length; i < total; i++) { 4498 layerChildren[i].style.width = '100%'; 4499 layerChildren[i].style.height = '100%'; 4500 } 4501 } 4502 } 4503 }, { 4504 key: 'setFillMode', 4505 value: function setFillMode() { 4506 var t = this; 4507 var isIframe = _window2.default.self !== _window2.default.top && _window2.default.frameElement !== null; 4508 var parent = function () { 4509 var parentEl = void 0, 4510 el = t.getElement(t.container); 4511 4512 while (el) { 4513 try { 4514 if (_constants.IS_FIREFOX && el.tagName.toLowerCase() === 'html' && _window2.default.self !== _window2.default.top && _window2.default.frameElement !== null) { 4515 return _window2.default.frameElement; 4516 } else { 4517 parentEl = el.parentElement; 4518 } 4519 } catch (e) { 4520 parentEl = el.parentElement; 4521 } 4522 4523 if (parentEl && dom.visible(parentEl)) { 4524 return parentEl; 4525 } 4526 el = parentEl; 4527 } 4528 4529 return null; 4530 }(); 4531 var parentStyles = parent ? getComputedStyle(parent, null) : getComputedStyle(_document2.default.body, null); 4532 4533 if (t.node.style.height !== 'none' && t.node.style.height !== t.height) { 4534 t.node.style.height = 'auto'; 4535 } 4536 if (t.node.style.maxWidth !== 'none' && t.node.style.maxWidth !== t.width) { 4537 t.node.style.maxWidth = 'none'; 4538 } 4539 4540 if (t.node.style.maxHeight !== 'none' && t.node.style.maxHeight !== t.height) { 4541 t.node.style.maxHeight = 'none'; 4542 } 4543 4544 if (t.node.currentStyle) { 4545 if (t.node.currentStyle.height === '100%') { 4546 t.node.currentStyle.height = 'auto'; 4547 } 4548 if (t.node.currentStyle.maxWidth === '100%') { 4549 t.node.currentStyle.maxWidth = 'none'; 4550 } 4551 if (t.node.currentStyle.maxHeight === '100%') { 4552 t.node.currentStyle.maxHeight = 'none'; 4553 } 4554 } 4555 4556 if (!isIframe && !parseFloat(parentStyles.width)) { 4557 parent.style.width = t.media.offsetWidth + 'px'; 4558 } 4559 4560 if (!isIframe && !parseFloat(parentStyles.height)) { 4561 parent.style.height = t.media.offsetHeight + 'px'; 4562 } 4563 4564 parentStyles = getComputedStyle(parent); 4565 4566 var parentWidth = parseFloat(parentStyles.width), 4567 parentHeight = parseFloat(parentStyles.height); 4568 4569 t.setDimensions('100%', '100%'); 4570 4571 var poster = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'poster>img'); 4572 if (poster) { 4573 poster.style.display = ''; 4574 } 4575 4576 var targetElement = t.getElement(t.container).querySelectorAll('object, embed, iframe, video'), 4577 initHeight = t.height, 4578 initWidth = t.width, 4579 scaleX1 = parentWidth, 4580 scaleY1 = initHeight * parentWidth / initWidth, 4581 scaleX2 = initWidth * parentHeight / initHeight, 4582 scaleY2 = parentHeight, 4583 bScaleOnWidth = scaleX2 > parentWidth === false, 4584 finalWidth = bScaleOnWidth ? Math.floor(scaleX1) : Math.floor(scaleX2), 4585 finalHeight = bScaleOnWidth ? Math.floor(scaleY1) : Math.floor(scaleY2), 4586 width = bScaleOnWidth ? parentWidth + 'px' : finalWidth + 'px', 4587 height = bScaleOnWidth ? finalHeight + 'px' : parentHeight + 'px'; 4588 4589 for (var i = 0, total = targetElement.length; i < total; i++) { 4590 targetElement[i].style.height = height; 4591 targetElement[i].style.width = width; 4592 if (t.media.setSize) { 4593 t.media.setSize(width, height); 4594 } 4595 4596 targetElement[i].style.marginLeft = Math.floor((parentWidth - finalWidth) / 2) + 'px'; 4597 targetElement[i].style.marginTop = 0; 4598 } 4599 } 4600 }, { 4601 key: 'setDimensions', 4602 value: function setDimensions(width, height) { 4603 var t = this; 4604 4605 width = (0, _general.isString)(width) && width.indexOf('%') > -1 ? width : parseFloat(width) + 'px'; 4606 height = (0, _general.isString)(height) && height.indexOf('%') > -1 ? height : parseFloat(height) + 'px'; 4607 4608 t.getElement(t.container).style.width = width; 4609 t.getElement(t.container).style.height = height; 4610 4611 var layers = t.getElement(t.layers).children; 4612 for (var i = 0, total = layers.length; i < total; i++) { 4613 layers[i].style.width = width; 4614 layers[i].style.height = height; 4615 } 4616 } 4617 }, { 4618 key: 'setControlsSize', 4619 value: function setControlsSize() { 4620 var t = this; 4621 4622 if (!dom.visible(t.getElement(t.container))) { 4623 return; 4624 } 4625 4626 if (t.rail && dom.visible(t.rail)) { 4627 var totalStyles = t.total ? getComputedStyle(t.total, null) : null, 4628 totalMargin = totalStyles ? parseFloat(totalStyles.marginLeft) + parseFloat(totalStyles.marginRight) : 0, 4629 railStyles = getComputedStyle(t.rail), 4630 railMargin = parseFloat(railStyles.marginLeft) + parseFloat(railStyles.marginRight); 4631 4632 var siblingsWidth = 0; 4633 4634 var siblings = dom.siblings(t.rail, function (el) { 4635 return el !== t.rail; 4636 }), 4637 total = siblings.length; 4638 for (var i = 0; i < total; i++) { 4639 siblingsWidth += siblings[i].offsetWidth; 4640 } 4641 4642 siblingsWidth += totalMargin + (totalMargin === 0 ? railMargin * 2 : railMargin) + 1; 4643 4644 t.getElement(t.container).style.minWidth = siblingsWidth + 'px'; 4645 4646 var event = (0, _general.createEvent)('controlsresize', t.getElement(t.container)); 4647 t.getElement(t.container).dispatchEvent(event); 4648 } else { 4649 var children = t.getElement(t.controls).children; 4650 var minWidth = 0; 4651 4652 for (var _i = 0, _total = children.length; _i < _total; _i++) { 4653 minWidth += children[_i].offsetWidth; 4654 } 4655 4656 t.getElement(t.container).style.minWidth = minWidth + 'px'; 4657 } 4658 } 4659 }, { 4660 key: 'addControlElement', 4661 value: function addControlElement(element, key) { 4662 4663 var t = this; 4664 4665 if (t.featurePosition[key] !== undefined) { 4666 var child = t.getElement(t.controls).children[t.featurePosition[key] - 1]; 4667 child.parentNode.insertBefore(element, child.nextSibling); 4668 } else { 4669 t.getElement(t.controls).appendChild(element); 4670 var children = t.getElement(t.controls).children; 4671 for (var i = 0, total = children.length; i < total; i++) { 4672 if (element === children[i]) { 4673 t.featurePosition[key] = i; 4674 break; 4675 } 4676 } 4677 } 4678 } 4679 }, { 4680 key: 'createIframeLayer', 4681 value: function createIframeLayer() { 4682 var t = this; 4683 4684 if (t.isVideo && t.media.rendererName !== null && t.media.rendererName.indexOf('iframe') > -1 && !_document2.default.getElementById(t.media.id + '-iframe-overlay')) { 4685 4686 var layer = _document2.default.createElement('div'), 4687 target = _document2.default.getElementById(t.media.id + '_' + t.media.rendererName); 4688 4689 layer.id = t.media.id + '-iframe-overlay'; 4690 layer.className = t.options.classPrefix + 'iframe-overlay'; 4691 layer.addEventListener('click', function (e) { 4692 if (t.options.clickToPlayPause) { 4693 if (t.paused) { 4694 t.play(); 4695 } else { 4696 t.pause(); 4697 } 4698 4699 e.preventDefault(); 4700 e.stopPropagation(); 4701 } 4702 }); 4703 4704 target.parentNode.insertBefore(layer, target); 4705 } 4706 } 4707 }, { 4708 key: 'resetSize', 4709 value: function resetSize() { 4710 var t = this; 4711 4712 setTimeout(function () { 4713 t.setPlayerSize(t.width, t.height); 4714 t.setControlsSize(); 4715 }, 50); 4716 } 4717 }, { 4718 key: 'setPoster', 4719 value: function setPoster(url) { 4720 var t = this; 4721 4722 if (t.getElement(t.container)) { 4723 var posterDiv = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'poster'); 4724 4725 if (!posterDiv) { 4726 posterDiv = _document2.default.createElement('div'); 4727 posterDiv.className = t.options.classPrefix + 'poster ' + t.options.classPrefix + 'layer'; 4728 t.getElement(t.layers).appendChild(posterDiv); 4729 } 4730 4731 var posterImg = posterDiv.querySelector('img'); 4732 4733 if (!posterImg && url) { 4734 posterImg = _document2.default.createElement('img'); 4735 posterImg.className = t.options.classPrefix + 'poster-img'; 4736 posterImg.width = '100%'; 4737 posterImg.height = '100%'; 4738 posterDiv.style.display = ''; 4739 posterDiv.appendChild(posterImg); 4740 } 4741 4742 if (url) { 4743 posterImg.setAttribute('src', url); 4744 posterDiv.style.backgroundImage = 'url("' + url + '")'; 4745 posterDiv.style.display = ''; 4746 } else if (posterImg) { 4747 posterDiv.style.backgroundImage = 'none'; 4748 posterDiv.style.display = 'none'; 4749 posterImg.remove(); 4750 } else { 4751 posterDiv.style.display = 'none'; 4752 } 4753 } else if (_constants.IS_IPAD && t.options.iPadUseNativeControls || _constants.IS_IPHONE && t.options.iPhoneUseNativeControls || _constants.IS_ANDROID && t.options.AndroidUseNativeControls) { 4754 t.media.originalNode.poster = url; 4755 } 4756 } 4757 }, { 4758 key: 'changeSkin', 4759 value: function changeSkin(className) { 4760 var t = this; 4761 4762 t.getElement(t.container).className = t.options.classPrefix + 'container ' + className; 4763 t.setPlayerSize(t.width, t.height); 4764 t.setControlsSize(); 4765 } 4766 }, { 4767 key: 'globalBind', 4768 value: function globalBind(events, callback) { 4769 var t = this, 4770 doc = t.node ? t.node.ownerDocument : _document2.default; 4771 4772 events = (0, _general.splitEvents)(events, t.id); 4773 if (events.d) { 4774 var eventList = events.d.split(' '); 4775 for (var i = 0, total = eventList.length; i < total; i++) { 4776 eventList[i].split('.').reduce(function (part, e) { 4777 doc.addEventListener(e, callback, false); 4778 return e; 4779 }, ''); 4780 } 4781 } 4782 if (events.w) { 4783 var _eventList = events.w.split(' '); 4784 for (var _i2 = 0, _total2 = _eventList.length; _i2 < _total2; _i2++) { 4785 _eventList[_i2].split('.').reduce(function (part, e) { 4786 _window2.default.addEventListener(e, callback, false); 4787 return e; 4788 }, ''); 4789 } 4790 } 4791 } 4792 }, { 4793 key: 'globalUnbind', 4794 value: function globalUnbind(events, callback) { 4795 var t = this, 4796 doc = t.node ? t.node.ownerDocument : _document2.default; 4797 4798 events = (0, _general.splitEvents)(events, t.id); 4799 if (events.d) { 4800 var eventList = events.d.split(' '); 4801 for (var i = 0, total = eventList.length; i < total; i++) { 4802 eventList[i].split('.').reduce(function (part, e) { 4803 doc.removeEventListener(e, callback, false); 4804 return e; 4805 }, ''); 4806 } 4807 } 4808 if (events.w) { 4809 var _eventList2 = events.w.split(' '); 4810 for (var _i3 = 0, _total3 = _eventList2.length; _i3 < _total3; _i3++) { 4811 _eventList2[_i3].split('.').reduce(function (part, e) { 4812 _window2.default.removeEventListener(e, callback, false); 4813 return e; 4814 }, ''); 4815 } 4816 } 4817 } 4818 }, { 4819 key: 'buildfeatures', 4820 value: function buildfeatures(player, controls, layers, media) { 4821 var t = this; 4822 4823 for (var i = 0, total = t.options.features.length; i < total; i++) { 4824 var feature = t.options.features[i]; 4825 if (t['build' + feature]) { 4826 try { 4827 t['build' + feature](player, controls, layers, media); 4828 } catch (e) { 4829 console.error('error building ' + feature, e); 4830 } 4831 } 4832 } 4833 } 4834 }, { 4835 key: 'buildposter', 4836 value: function buildposter(player, controls, layers, media) { 4837 var t = this, 4838 poster = _document2.default.createElement('div'); 4839 4840 poster.className = t.options.classPrefix + 'poster ' + t.options.classPrefix + 'layer'; 4841 layers.appendChild(poster); 4842 4843 var posterUrl = media.originalNode.getAttribute('poster'); 4844 4845 if (player.options.poster !== '') { 4846 if (posterUrl && _constants.IS_IOS) { 4847 media.originalNode.removeAttribute('poster'); 4848 } 4849 posterUrl = player.options.poster; 4850 } 4851 4852 if (posterUrl) { 4853 t.setPoster(posterUrl); 4854 } else if (t.media.renderer !== null && typeof t.media.renderer.getPosterUrl === 'function') { 4855 t.setPoster(t.media.renderer.getPosterUrl()); 4856 } else { 4857 poster.style.display = 'none'; 4858 } 4859 4860 media.addEventListener('play', function () { 4861 poster.style.display = 'none'; 4862 }); 4863 4864 media.addEventListener('playing', function () { 4865 poster.style.display = 'none'; 4866 }); 4867 4868 if (player.options.showPosterWhenEnded && player.options.autoRewind) { 4869 media.addEventListener('ended', function () { 4870 poster.style.display = ''; 4871 }); 4872 } 4873 4874 media.addEventListener('error', function () { 4875 poster.style.display = 'none'; 4876 }); 4877 4878 if (player.options.showPosterWhenPaused) { 4879 media.addEventListener('pause', function () { 4880 if (!player.ended) { 4881 poster.style.display = ''; 4882 } 4883 }); 4884 } 4885 } 4886 }, { 4887 key: 'buildoverlays', 4888 value: function buildoverlays(player, controls, layers, media) { 4889 4890 if (!player.isVideo) { 4891 return; 4892 } 4893 4894 var t = this, 4895 loading = _document2.default.createElement('div'), 4896 error = _document2.default.createElement('div'), 4897 bigPlay = _document2.default.createElement('div'); 4898 4899 loading.style.display = 'none'; 4900 loading.className = t.options.classPrefix + 'overlay ' + t.options.classPrefix + 'layer'; 4901 loading.innerHTML = '<div class="' + t.options.classPrefix + 'overlay-loading">' + ('<span class="' + t.options.classPrefix + 'overlay-loading-bg-img"></span>') + '</div>'; 4902 layers.appendChild(loading); 4903 4904 error.style.display = 'none'; 4905 error.className = t.options.classPrefix + 'overlay ' + t.options.classPrefix + 'layer'; 4906 error.innerHTML = '<div class="' + t.options.classPrefix + 'overlay-error"></div>'; 4907 layers.appendChild(error); 4908 4909 bigPlay.className = t.options.classPrefix + 'overlay ' + t.options.classPrefix + 'layer ' + t.options.classPrefix + 'overlay-play'; 4910 bigPlay.innerHTML = '<div class="' + t.options.classPrefix + 'overlay-button" role="button" tabindex="0" ' + ('aria-label="' + _i18n2.default.t('mejs.play') + '" aria-pressed="false"></div>'); 4911 bigPlay.addEventListener('click', function () { 4912 if (t.options.clickToPlayPause) { 4913 4914 var button = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'overlay-button'), 4915 pressed = button.getAttribute('aria-pressed'); 4916 4917 if (t.paused) { 4918 t.play(); 4919 } else { 4920 t.pause(); 4921 } 4922 4923 button.setAttribute('aria-pressed', !!pressed); 4924 t.getElement(t.container).focus(); 4925 } 4926 }); 4927 4928 bigPlay.addEventListener('keydown', function (e) { 4929 var keyPressed = e.keyCode || e.which || 0; 4930 4931 if (keyPressed === 13 || _constants.IS_FIREFOX && keyPressed === 32) { 4932 var event = (0, _general.createEvent)('click', bigPlay); 4933 bigPlay.dispatchEvent(event); 4934 return false; 4935 } 4936 }); 4937 4938 layers.appendChild(bigPlay); 4939 4940 if (t.media.rendererName !== null && (/(youtube|facebook)/i.test(t.media.rendererName) && !(t.media.originalNode.getAttribute('poster') || player.options.poster || typeof t.media.renderer.getPosterUrl === 'function' && t.media.renderer.getPosterUrl()) || _constants.IS_STOCK_ANDROID || t.media.originalNode.getAttribute('autoplay'))) { 4941 bigPlay.style.display = 'none'; 4942 } 4943 4944 var hasError = false; 4945 4946 media.addEventListener('play', function () { 4947 bigPlay.style.display = 'none'; 4948 loading.style.display = 'none'; 4949 error.style.display = 'none'; 4950 hasError = false; 4951 }); 4952 media.addEventListener('playing', function () { 4953 bigPlay.style.display = 'none'; 4954 loading.style.display = 'none'; 4955 error.style.display = 'none'; 4956 hasError = false; 4957 }); 4958 media.addEventListener('seeking', function () { 4959 bigPlay.style.display = 'none'; 4960 loading.style.display = ''; 4961 hasError = false; 4962 }); 4963 media.addEventListener('seeked', function () { 4964 bigPlay.style.display = t.paused && !_constants.IS_STOCK_ANDROID ? '' : 'none'; 4965 loading.style.display = 'none'; 4966 hasError = false; 4967 }); 4968 media.addEventListener('pause', function () { 4969 loading.style.display = 'none'; 4970 if (!_constants.IS_STOCK_ANDROID && !hasError) { 4971 bigPlay.style.display = ''; 4972 } 4973 hasError = false; 4974 }); 4975 media.addEventListener('waiting', function () { 4976 loading.style.display = ''; 4977 hasError = false; 4978 }); 4979 4980 media.addEventListener('loadeddata', function () { 4981 loading.style.display = ''; 4982 4983 if (_constants.IS_ANDROID) { 4984 media.canplayTimeout = setTimeout(function () { 4985 if (_document2.default.createEvent) { 4986 var evt = _document2.default.createEvent('HTMLEvents'); 4987 evt.initEvent('canplay', true, true); 4988 return media.dispatchEvent(evt); 4989 } 4990 }, 300); 4991 } 4992 hasError = false; 4993 }); 4994 media.addEventListener('canplay', function () { 4995 loading.style.display = 'none'; 4996 4997 clearTimeout(media.canplayTimeout); 4998 hasError = false; 4999 }); 5000 5001 media.addEventListener('error', function (e) { 5002 t._handleError(e, t.media, t.node); 5003 loading.style.display = 'none'; 5004 bigPlay.style.display = 'none'; 5005 hasError = true; 5006 }); 5007 5008 media.addEventListener('loadedmetadata', function () { 5009 if (!t.controlsEnabled) { 5010 t.enableControls(); 5011 } 5012 }); 5013 5014 media.addEventListener('keydown', function (e) { 5015 t.onkeydown(player, media, e); 5016 hasError = false; 5017 }); 5018 } 5019 }, { 5020 key: 'buildkeyboard', 5021 value: function buildkeyboard(player, controls, layers, media) { 5022 5023 var t = this; 5024 5025 t.getElement(t.container).addEventListener('keydown', function () { 5026 t.keyboardAction = true; 5027 }); 5028 5029 t.globalKeydownCallback = function (event) { 5030 var container = _document2.default.activeElement.closest('.' + t.options.classPrefix + 'container'), 5031 target = t.media.closest('.' + t.options.classPrefix + 'container'); 5032 t.hasFocus = !!(container && target && container.id === target.id); 5033 return t.onkeydown(player, media, event); 5034 }; 5035 5036 t.globalClickCallback = function (event) { 5037 t.hasFocus = !!event.target.closest('.' + t.options.classPrefix + 'container'); 5038 }; 5039 5040 t.globalBind('keydown', t.globalKeydownCallback); 5041 5042 t.globalBind('click', t.globalClickCallback); 5043 } 5044 }, { 5045 key: 'onkeydown', 5046 value: function onkeydown(player, media, e) { 5047 5048 if (player.hasFocus && player.options.enableKeyboard) { 5049 for (var i = 0, total = player.options.keyActions.length; i < total; i++) { 5050 var keyAction = player.options.keyActions[i]; 5051 5052 for (var j = 0, jl = keyAction.keys.length; j < jl; j++) { 5053 if (e.keyCode === keyAction.keys[j]) { 5054 keyAction.action(player, media, e.keyCode, e); 5055 e.preventDefault(); 5056 e.stopPropagation(); 5057 return; 5058 } 5059 } 5060 } 5061 } 5062 5063 return true; 5064 } 5065 }, { 5066 key: 'play', 5067 value: function play() { 5068 this.proxy.play(); 5069 } 5070 }, { 5071 key: 'pause', 5072 value: function pause() { 5073 this.proxy.pause(); 5074 } 5075 }, { 5076 key: 'load', 5077 value: function load() { 5078 this.proxy.load(); 5079 } 5080 }, { 5081 key: 'setCurrentTime', 5082 value: function setCurrentTime(time) { 5083 this.proxy.setCurrentTime(time); 5084 } 5085 }, { 5086 key: 'getCurrentTime', 5087 value: function getCurrentTime() { 5088 return this.proxy.currentTime; 5089 } 5090 }, { 5091 key: 'getDuration', 5092 value: function getDuration() { 5093 return this.proxy.duration; 5094 } 5095 }, { 5096 key: 'setVolume', 5097 value: function setVolume(volume) { 5098 this.proxy.volume = volume; 5099 } 5100 }, { 5101 key: 'getVolume', 5102 value: function getVolume() { 5103 return this.proxy.getVolume(); 5104 } 5105 }, { 5106 key: 'setMuted', 5107 value: function setMuted(value) { 5108 this.proxy.setMuted(value); 5109 } 5110 }, { 5111 key: 'setSrc', 5112 value: function setSrc(src) { 5113 if (!this.controlsEnabled) { 5114 this.enableControls(); 5115 } 5116 this.proxy.setSrc(src); 5117 } 5118 }, { 5119 key: 'getSrc', 5120 value: function getSrc() { 5121 return this.proxy.getSrc(); 5122 } 5123 }, { 5124 key: 'canPlayType', 5125 value: function canPlayType(type) { 5126 return this.proxy.canPlayType(type); 5127 } 5128 }, { 5129 key: 'remove', 5130 value: function remove() { 5131 var t = this, 5132 rendererName = t.media.rendererName, 5133 src = t.media.originalNode.src; 5134 5135 for (var featureIndex in t.options.features) { 5136 var feature = t.options.features[featureIndex]; 5137 if (t['clean' + feature]) { 5138 try { 5139 t['clean' + feature](t, t.getElement(t.layers), t.getElement(t.controls), t.media); 5140 } catch (e) { 5141 console.error('error cleaning ' + feature, e); 5142 } 5143 } 5144 } 5145 5146 var nativeWidth = t.node.getAttribute('width'), 5147 nativeHeight = t.node.getAttribute('height'); 5148 5149 if (nativeWidth) { 5150 if (nativeWidth.indexOf('%') === -1) { 5151 nativeWidth = nativeWidth + 'px'; 5152 } 5153 } else { 5154 nativeWidth = 'auto'; 5155 } 5156 5157 if (nativeHeight) { 5158 if (nativeHeight.indexOf('%') === -1) { 5159 nativeHeight = nativeHeight + 'px'; 5160 } 5161 } else { 5162 nativeHeight = 'auto'; 5163 } 5164 5165 t.node.style.width = nativeWidth; 5166 t.node.style.height = nativeHeight; 5167 5168 t.setPlayerSize(0, 0); 5169 5170 if (!t.isDynamic) { 5171 (function () { 5172 t.node.setAttribute('controls', true); 5173 t.node.setAttribute('id', t.node.getAttribute('id').replace('_' + rendererName, '').replace('_from_mejs', '')); 5174 var poster = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'poster>img'); 5175 if (poster) { 5176 t.node.setAttribute('poster', poster.src); 5177 } 5178 5179 delete t.node.autoplay; 5180 5181 t.node.setAttribute('src', ''); 5182 if (t.media.canPlayType((0, _media.getTypeFromFile)(src)) !== '') { 5183 t.node.setAttribute('src', src); 5184 } 5185 5186 if (rendererName && rendererName.indexOf('iframe') > -1) { 5187 var layer = _document2.default.getElementById(t.media.id + '-iframe-overlay'); 5188 layer.remove(); 5189 } 5190 5191 var node = t.node.cloneNode(); 5192 node.style.display = ''; 5193 t.getElement(t.container).parentNode.insertBefore(node, t.getElement(t.container)); 5194 t.node.remove(); 5195 5196 if (t.mediaFiles) { 5197 for (var i = 0, total = t.mediaFiles.length; i < total; i++) { 5198 var source = _document2.default.createElement('source'); 5199 source.setAttribute('src', t.mediaFiles[i].src); 5200 source.setAttribute('type', t.mediaFiles[i].type); 5201 node.appendChild(source); 5202 } 5203 } 5204 if (t.trackFiles) { 5205 var _loop3 = function _loop3(_i4, _total4) { 5206 var track = t.trackFiles[_i4]; 5207 var newTrack = _document2.default.createElement('track'); 5208 newTrack.kind = track.kind; 5209 newTrack.label = track.label; 5210 newTrack.srclang = track.srclang; 5211 newTrack.src = track.src; 5212 5213 node.appendChild(newTrack); 5214 newTrack.addEventListener('load', function () { 5215 this.mode = 'showing'; 5216 node.textTracks[_i4].mode = 'showing'; 5217 }); 5218 }; 5219 5220 for (var _i4 = 0, _total4 = t.trackFiles.length; _i4 < _total4; _i4++) { 5221 _loop3(_i4, _total4); 5222 } 5223 } 5224 5225 delete t.node; 5226 delete t.mediaFiles; 5227 delete t.trackFiles; 5228 })(); 5229 } else { 5230 t.getElement(t.container).parentNode.insertBefore(t.node, t.getElement(t.container)); 5231 } 5232 5233 if (t.media.renderer && typeof t.media.renderer.destroy === 'function') { 5234 t.media.renderer.destroy(); 5235 } 5236 5237 delete _mejs2.default.players[t.id]; 5238 5239 if (_typeof(t.getElement(t.container)) === 'object') { 5240 var offscreen = t.getElement(t.container).parentNode.querySelector('.' + t.options.classPrefix + 'offscreen'); 5241 if (offscreen) { 5242 offscreen.remove(); 5243 } 5244 t.getElement(t.container).remove(); 5245 } 5246 t.globalUnbind('resize', t.globalResizeCallback); 5247 t.globalUnbind('keydown', t.globalKeydownCallback); 5248 t.globalUnbind('click', t.globalClickCallback); 5249 5250 delete t.media.player; 5251 } 5252 }, { 5253 key: 'paused', 5254 get: function get() { 5255 return this.proxy.paused; 5256 } 5257 }, { 5258 key: 'muted', 5259 get: function get() { 5260 return this.proxy.muted; 5261 }, 5262 set: function set(muted) { 5263 this.setMuted(muted); 5264 } 5265 }, { 5266 key: 'ended', 5267 get: function get() { 5268 return this.proxy.ended; 5269 } 5270 }, { 5271 key: 'readyState', 5272 get: function get() { 5273 return this.proxy.readyState; 5274 } 5275 }, { 5276 key: 'currentTime', 5277 set: function set(time) { 5278 this.setCurrentTime(time); 5279 }, 5280 get: function get() { 5281 return this.getCurrentTime(); 5282 } 5283 }, { 5284 key: 'duration', 5285 get: function get() { 5286 return this.getDuration(); 5287 } 5288 }, { 5289 key: 'volume', 5290 set: function set(volume) { 5291 this.setVolume(volume); 5292 }, 5293 get: function get() { 5294 return this.getVolume(); 5295 } 5296 }, { 5297 key: 'src', 5298 set: function set(src) { 5299 this.setSrc(src); 5300 }, 5301 get: function get() { 5302 return this.getSrc(); 5303 } 5304 }]); 5305 5306 return MediaElementPlayer; 5307 }(); 5308 5309 _window2.default.MediaElementPlayer = MediaElementPlayer; 5310 _mejs2.default.MediaElementPlayer = MediaElementPlayer; 5311 5312 exports.default = MediaElementPlayer; 5313 5314 },{"17":17,"2":2,"25":25,"26":26,"27":27,"28":28,"3":3,"30":30,"5":5,"6":6,"7":7}],17:[function(_dereq_,module,exports){ 5315 'use strict'; 5316 5317 Object.defineProperty(exports, "__esModule", { 5318 value: true 5319 }); 5320 5321 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; }; }(); 5322 5323 var _window = _dereq_(3); 5324 5325 var _window2 = _interopRequireDefault(_window); 5326 5327 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5328 5329 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 5330 5331 var DefaultPlayer = function () { 5332 function DefaultPlayer(player) { 5333 _classCallCheck(this, DefaultPlayer); 5334 5335 this.media = player.media; 5336 this.isVideo = player.isVideo; 5337 this.classPrefix = player.options.classPrefix; 5338 this.createIframeLayer = function () { 5339 return player.createIframeLayer(); 5340 }; 5341 this.setPoster = function (url) { 5342 return player.setPoster(url); 5343 }; 5344 return this; 5345 } 5346 5347 _createClass(DefaultPlayer, [{ 5348 key: 'play', 5349 value: function play() { 5350 this.media.play(); 5351 } 5352 }, { 5353 key: 'pause', 5354 value: function pause() { 5355 this.media.pause(); 5356 } 5357 }, { 5358 key: 'load', 5359 value: function load() { 5360 var t = this; 5361 5362 if (!t.isLoaded) { 5363 t.media.load(); 5364 } 5365 5366 t.isLoaded = true; 5367 } 5368 }, { 5369 key: 'setCurrentTime', 5370 value: function setCurrentTime(time) { 5371 this.media.setCurrentTime(time); 5372 } 5373 }, { 5374 key: 'getCurrentTime', 5375 value: function getCurrentTime() { 5376 return this.media.currentTime; 5377 } 5378 }, { 5379 key: 'getDuration', 5380 value: function getDuration() { 5381 var duration = this.media.getDuration(); 5382 if (duration === Infinity && this.media.seekable && this.media.seekable.length) { 5383 duration = this.media.seekable.end(0); 5384 } 5385 return duration; 5386 } 5387 }, { 5388 key: 'setVolume', 5389 value: function setVolume(volume) { 5390 this.media.setVolume(volume); 5391 } 5392 }, { 5393 key: 'getVolume', 5394 value: function getVolume() { 5395 return this.media.getVolume(); 5396 } 5397 }, { 5398 key: 'setMuted', 5399 value: function setMuted(value) { 5400 this.media.setMuted(value); 5401 } 5402 }, { 5403 key: 'setSrc', 5404 value: function setSrc(src) { 5405 var t = this, 5406 layer = document.getElementById(t.media.id + '-iframe-overlay'); 5407 5408 if (layer) { 5409 layer.remove(); 5410 } 5411 5412 t.media.setSrc(src); 5413 t.createIframeLayer(); 5414 if (t.media.renderer !== null && typeof t.media.renderer.getPosterUrl === 'function') { 5415 t.setPoster(t.media.renderer.getPosterUrl()); 5416 } 5417 } 5418 }, { 5419 key: 'getSrc', 5420 value: function getSrc() { 5421 return this.media.getSrc(); 5422 } 5423 }, { 5424 key: 'canPlayType', 5425 value: function canPlayType(type) { 5426 return this.media.canPlayType(type); 5427 } 5428 }, { 5429 key: 'paused', 5430 get: function get() { 5431 return this.media.paused; 5432 } 5433 }, { 5434 key: 'muted', 5435 set: function set(muted) { 5436 this.setMuted(muted); 5437 }, 5438 get: function get() { 5439 return this.media.muted; 5440 } 5441 }, { 5442 key: 'ended', 5443 get: function get() { 5444 return this.media.ended; 5445 } 5446 }, { 5447 key: 'readyState', 5448 get: function get() { 5449 return this.media.readyState; 5450 } 5451 }, { 5452 key: 'currentTime', 5453 set: function set(time) { 5454 this.setCurrentTime(time); 5455 }, 5456 get: function get() { 5457 return this.getCurrentTime(); 5458 } 5459 }, { 5460 key: 'duration', 5461 get: function get() { 5462 return this.getDuration(); 5463 } 5464 }, { 5465 key: 'remainingTime', 5466 get: function get() { 5467 return this.getDuration() - this.currentTime(); 5468 } 5469 }, { 5470 key: 'volume', 5471 set: function set(volume) { 5472 this.setVolume(volume); 5473 }, 5474 get: function get() { 5475 return this.getVolume(); 5476 } 5477 }, { 5478 key: 'src', 5479 set: function set(src) { 5480 this.setSrc(src); 5481 }, 5482 get: function get() { 5483 return this.getSrc(); 5484 } 5485 }]); 5486 5487 return DefaultPlayer; 5488 }(); 5489 5490 exports.default = DefaultPlayer; 5491 5492 5493 _window2.default.DefaultPlayer = DefaultPlayer; 5494 5495 },{"3":3}],18:[function(_dereq_,module,exports){ 5496 'use strict'; 5497 5498 var _window = _dereq_(3); 5499 5500 var _window2 = _interopRequireDefault(_window); 5501 5502 var _mejs = _dereq_(7); 5503 5504 var _mejs2 = _interopRequireDefault(_mejs); 5505 5506 var _player = _dereq_(16); 5507 5508 var _player2 = _interopRequireDefault(_player); 5509 5510 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5511 5512 if (typeof jQuery !== 'undefined') { 5513 _mejs2.default.$ = jQuery; 5514 } else if (typeof Zepto !== 'undefined') { 5515 _mejs2.default.$ = Zepto; 5516 } else if (typeof ender !== 'undefined') { 5517 _mejs2.default.$ = ender; 5518 } 5519 5520 (function ($) { 5521 if (typeof $ !== 'undefined') { 5522 $.fn.mediaelementplayer = function (options) { 5523 if (options === false) { 5524 this.each(function () { 5525 var player = $(this).data('mediaelementplayer'); 5526 if (player) { 5527 player.remove(); 5528 } 5529 $(this).removeData('mediaelementplayer'); 5530 }); 5531 } else { 5532 this.each(function () { 5533 $(this).data('mediaelementplayer', new _player2.default(this, options)); 5534 }); 5535 } 5536 return this; 5537 }; 5538 5539 $(document).ready(function () { 5540 $('.' + _mejs2.default.MepDefaults.classPrefix + 'player').mediaelementplayer(); 5541 }); 5542 } 5543 })(_mejs2.default.$); 5544 5545 },{"16":16,"3":3,"7":7}],19:[function(_dereq_,module,exports){ 5546 'use strict'; 5547 5548 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 5549 5550 var _window = _dereq_(3); 5551 5552 var _window2 = _interopRequireDefault(_window); 5553 5554 var _mejs = _dereq_(7); 5555 5556 var _mejs2 = _interopRequireDefault(_mejs); 5557 5558 var _renderer = _dereq_(8); 5559 5560 var _general = _dereq_(27); 5561 5562 var _media = _dereq_(28); 5563 5564 var _constants = _dereq_(25); 5565 5566 var _dom = _dereq_(26); 5567 5568 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5569 5570 var NativeDash = { 5571 5572 promise: null, 5573 5574 load: function load(settings) { 5575 if (typeof dashjs !== 'undefined') { 5576 NativeDash.promise = new Promise(function (resolve) { 5577 resolve(); 5578 }).then(function () { 5579 NativeDash._createPlayer(settings); 5580 }); 5581 } else { 5582 settings.options.path = typeof settings.options.path === 'string' ? settings.options.path : 'https://cdn.dashjs.org/latest/dash.all.min.js'; 5583 5584 NativeDash.promise = NativeDash.promise || (0, _dom.loadScript)(settings.options.path); 5585 NativeDash.promise.then(function () { 5586 NativeDash._createPlayer(settings); 5587 }); 5588 } 5589 5590 return NativeDash.promise; 5591 }, 5592 5593 _createPlayer: function _createPlayer(settings) { 5594 var player = dashjs.MediaPlayer().create(); 5595 _window2.default['__ready__' + settings.id](player); 5596 return player; 5597 } 5598 }; 5599 5600 var DashNativeRenderer = { 5601 name: 'native_dash', 5602 options: { 5603 prefix: 'native_dash', 5604 dash: { 5605 path: 'https://cdn.dashjs.org/latest/dash.all.min.js', 5606 debug: false, 5607 drm: {}, 5608 5609 robustnessLevel: '' 5610 } 5611 }, 5612 5613 canPlayType: function canPlayType(type) { 5614 return _constants.HAS_MSE && ['application/dash+xml'].indexOf(type.toLowerCase()) > -1; 5615 }, 5616 5617 create: function create(mediaElement, options, mediaFiles) { 5618 5619 var originalNode = mediaElement.originalNode, 5620 id = mediaElement.id + '_' + options.prefix, 5621 autoplay = originalNode.autoplay, 5622 children = originalNode.children; 5623 5624 var node = null, 5625 dashPlayer = null; 5626 5627 originalNode.removeAttribute('type'); 5628 for (var i = 0, total = children.length; i < total; i++) { 5629 children[i].removeAttribute('type'); 5630 } 5631 5632 node = originalNode.cloneNode(true); 5633 options = Object.assign(options, mediaElement.options); 5634 5635 var props = _mejs2.default.html5media.properties, 5636 events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']).filter(function (e) { 5637 return e !== 'error'; 5638 }), 5639 attachNativeEvents = function attachNativeEvents(e) { 5640 var event = (0, _general.createEvent)(e.type, mediaElement); 5641 mediaElement.dispatchEvent(event); 5642 }, 5643 assignGettersSetters = function assignGettersSetters(propName) { 5644 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 5645 5646 node['get' + capName] = function () { 5647 return dashPlayer !== null ? node[propName] : null; 5648 }; 5649 5650 node['set' + capName] = function (value) { 5651 if (_mejs2.default.html5media.readOnlyProperties.indexOf(propName) === -1) { 5652 if (propName === 'src') { 5653 var source = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src ? value.src : value; 5654 node[propName] = source; 5655 if (dashPlayer !== null) { 5656 dashPlayer.reset(); 5657 for (var _i = 0, _total = events.length; _i < _total; _i++) { 5658 node.removeEventListener(events[_i], attachNativeEvents); 5659 } 5660 dashPlayer = NativeDash._createPlayer({ 5661 options: options.dash, 5662 id: id 5663 }); 5664 5665 if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && _typeof(value.drm) === 'object') { 5666 dashPlayer.setProtectionData(value.drm); 5667 if ((0, _general.isString)(options.dash.robustnessLevel) && options.dash.robustnessLevel) { 5668 dashPlayer.getProtectionController().setRobustnessLevel(options.dash.robustnessLevel); 5669 } 5670 } 5671 dashPlayer.attachSource(source); 5672 if (autoplay) { 5673 dashPlayer.play(); 5674 } 5675 } 5676 } else { 5677 node[propName] = value; 5678 } 5679 } 5680 }; 5681 }; 5682 5683 for (var _i2 = 0, _total2 = props.length; _i2 < _total2; _i2++) { 5684 assignGettersSetters(props[_i2]); 5685 } 5686 5687 _window2.default['__ready__' + id] = function (_dashPlayer) { 5688 mediaElement.dashPlayer = dashPlayer = _dashPlayer; 5689 5690 var dashEvents = dashjs.MediaPlayer.events, 5691 assignEvents = function assignEvents(eventName) { 5692 if (eventName === 'loadedmetadata') { 5693 dashPlayer.initialize(); 5694 dashPlayer.attachView(node); 5695 dashPlayer.setAutoPlay(false); 5696 5697 if (_typeof(options.dash.drm) === 'object' && !_mejs2.default.Utils.isObjectEmpty(options.dash.drm)) { 5698 dashPlayer.setProtectionData(options.dash.drm); 5699 if ((0, _general.isString)(options.dash.robustnessLevel) && options.dash.robustnessLevel) { 5700 dashPlayer.getProtectionController().setRobustnessLevel(options.dash.robustnessLevel); 5701 } 5702 } 5703 dashPlayer.attachSource(node.getSrc()); 5704 } 5705 5706 node.addEventListener(eventName, attachNativeEvents); 5707 }; 5708 5709 for (var _i3 = 0, _total3 = events.length; _i3 < _total3; _i3++) { 5710 assignEvents(events[_i3]); 5711 } 5712 5713 var assignMdashEvents = function assignMdashEvents(e) { 5714 if (e.type.toLowerCase() === 'error') { 5715 mediaElement.generateError(e.message, node.src); 5716 console.error(e); 5717 } else { 5718 var _event = (0, _general.createEvent)(e.type, mediaElement); 5719 _event.data = e; 5720 mediaElement.dispatchEvent(_event); 5721 } 5722 }; 5723 5724 for (var eventType in dashEvents) { 5725 if (dashEvents.hasOwnProperty(eventType)) { 5726 dashPlayer.on(dashEvents[eventType], function (e) { 5727 return assignMdashEvents(e); 5728 }); 5729 } 5730 } 5731 }; 5732 5733 if (mediaFiles && mediaFiles.length > 0) { 5734 for (var _i4 = 0, _total4 = mediaFiles.length; _i4 < _total4; _i4++) { 5735 if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[_i4].type)) { 5736 node.setAttribute('src', mediaFiles[_i4].src); 5737 if (typeof mediaFiles[_i4].drm !== 'undefined') { 5738 options.dash.drm = mediaFiles[_i4].drm; 5739 } 5740 break; 5741 } 5742 } 5743 } 5744 5745 node.setAttribute('id', id); 5746 5747 originalNode.parentNode.insertBefore(node, originalNode); 5748 originalNode.autoplay = false; 5749 originalNode.style.display = 'none'; 5750 5751 node.setSize = function (width, height) { 5752 node.style.width = width + 'px'; 5753 node.style.height = height + 'px'; 5754 return node; 5755 }; 5756 5757 node.hide = function () { 5758 node.pause(); 5759 node.style.display = 'none'; 5760 return node; 5761 }; 5762 5763 node.show = function () { 5764 node.style.display = ''; 5765 return node; 5766 }; 5767 5768 node.destroy = function () { 5769 if (dashPlayer !== null) { 5770 dashPlayer.reset(); 5771 } 5772 }; 5773 5774 var event = (0, _general.createEvent)('rendererready', node); 5775 mediaElement.dispatchEvent(event); 5776 5777 mediaElement.promises.push(NativeDash.load({ 5778 options: options.dash, 5779 id: id 5780 })); 5781 5782 return node; 5783 } 5784 }; 5785 5786 _media.typeChecks.push(function (url) { 5787 return ~url.toLowerCase().indexOf('.mpd') ? 'application/dash+xml' : null; 5788 }); 5789 5790 _renderer.renderer.add(DashNativeRenderer); 5791 5792 },{"25":25,"26":26,"27":27,"28":28,"3":3,"7":7,"8":8}],20:[function(_dereq_,module,exports){ 5793 'use strict'; 5794 5795 Object.defineProperty(exports, "__esModule", { 5796 value: true 5797 }); 5798 exports.PluginDetector = undefined; 5799 5800 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 5801 5802 var _window = _dereq_(3); 5803 5804 var _window2 = _interopRequireDefault(_window); 5805 5806 var _document = _dereq_(2); 5807 5808 var _document2 = _interopRequireDefault(_document); 5809 5810 var _mejs = _dereq_(7); 5811 5812 var _mejs2 = _interopRequireDefault(_mejs); 5813 5814 var _i18n = _dereq_(5); 5815 5816 var _i18n2 = _interopRequireDefault(_i18n); 5817 5818 var _renderer = _dereq_(8); 5819 5820 var _general = _dereq_(27); 5821 5822 var _constants = _dereq_(25); 5823 5824 var _media = _dereq_(28); 5825 5826 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5827 5828 var PluginDetector = exports.PluginDetector = { 5829 plugins: [], 5830 5831 hasPluginVersion: function hasPluginVersion(plugin, v) { 5832 var pv = PluginDetector.plugins[plugin]; 5833 v[1] = v[1] || 0; 5834 v[2] = v[2] || 0; 5835 return pv[0] > v[0] || pv[0] === v[0] && pv[1] > v[1] || pv[0] === v[0] && pv[1] === v[1] && pv[2] >= v[2]; 5836 }, 5837 5838 addPlugin: function addPlugin(p, pluginName, mimeType, activeX, axDetect) { 5839 PluginDetector.plugins[p] = PluginDetector.detectPlugin(pluginName, mimeType, activeX, axDetect); 5840 }, 5841 5842 detectPlugin: function detectPlugin(pluginName, mimeType, activeX, axDetect) { 5843 5844 var version = [0, 0, 0], 5845 description = void 0, 5846 ax = void 0; 5847 5848 if (_constants.NAV.plugins !== null && _constants.NAV.plugins !== undefined && _typeof(_constants.NAV.plugins[pluginName]) === 'object') { 5849 description = _constants.NAV.plugins[pluginName].description; 5850 if (description && !(typeof _constants.NAV.mimeTypes !== 'undefined' && _constants.NAV.mimeTypes[mimeType] && !_constants.NAV.mimeTypes[mimeType].enabledPlugin)) { 5851 version = description.replace(pluginName, '').replace(/^\s+/, '').replace(/\sr/gi, '.').split('.'); 5852 for (var i = 0, total = version.length; i < total; i++) { 5853 version[i] = parseInt(version[i].match(/\d+/), 10); 5854 } 5855 } 5856 } else if (_window2.default.ActiveXObject !== undefined) { 5857 try { 5858 ax = new ActiveXObject(activeX); 5859 if (ax) { 5860 version = axDetect(ax); 5861 } 5862 } catch (e) { 5863 5864 } 5865 } 5866 return version; 5867 } 5868 }; 5869 5870 PluginDetector.addPlugin('flash', 'Shockwave Flash', 'application/x-shockwave-flash', 'ShockwaveFlash.ShockwaveFlash', function (ax) { 5871 var version = [], 5872 d = ax.GetVariable("$version"); 5873 5874 if (d) { 5875 d = d.split(" ")[1].split(","); 5876 version = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; 5877 } 5878 return version; 5879 }); 5880 5881 var FlashMediaElementRenderer = { 5882 create: function create(mediaElement, options, mediaFiles) { 5883 5884 var flash = {}; 5885 var isActive = false; 5886 5887 flash.options = options; 5888 flash.id = mediaElement.id + '_' + flash.options.prefix; 5889 flash.mediaElement = mediaElement; 5890 flash.flashState = {}; 5891 flash.flashApi = null; 5892 flash.flashApiStack = []; 5893 5894 var props = _mejs2.default.html5media.properties, 5895 assignGettersSetters = function assignGettersSetters(propName) { 5896 flash.flashState[propName] = null; 5897 5898 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 5899 5900 flash['get' + capName] = function () { 5901 if (flash.flashApi !== null) { 5902 if (typeof flash.flashApi['get_' + propName] === 'function') { 5903 var value = flash.flashApi['get_' + propName](); 5904 5905 if (propName === 'buffered') { 5906 return { 5907 start: function start() { 5908 return 0; 5909 }, 5910 end: function end() { 5911 return value; 5912 }, 5913 length: 1 5914 }; 5915 } 5916 return value; 5917 } else { 5918 return null; 5919 } 5920 } else { 5921 return null; 5922 } 5923 }; 5924 5925 flash['set' + capName] = function (value) { 5926 if (propName === 'src') { 5927 value = (0, _media.absolutizeUrl)(value); 5928 } 5929 5930 if (flash.flashApi !== null && flash.flashApi['set_' + propName] !== undefined) { 5931 try { 5932 flash.flashApi['set_' + propName](value); 5933 } catch (e) { 5934 5935 } 5936 } else { 5937 flash.flashApiStack.push({ 5938 type: 'set', 5939 propName: propName, 5940 value: value 5941 }); 5942 } 5943 }; 5944 }; 5945 5946 for (var i = 0, total = props.length; i < total; i++) { 5947 assignGettersSetters(props[i]); 5948 } 5949 5950 var methods = _mejs2.default.html5media.methods, 5951 assignMethods = function assignMethods(methodName) { 5952 flash[methodName] = function () { 5953 if (isActive) { 5954 if (flash.flashApi !== null) { 5955 if (flash.flashApi['fire_' + methodName]) { 5956 try { 5957 flash.flashApi['fire_' + methodName](); 5958 } catch (e) { 5959 5960 } 5961 } else { 5962 5963 } 5964 } else { 5965 flash.flashApiStack.push({ 5966 type: 'call', 5967 methodName: methodName 5968 }); 5969 } 5970 } 5971 }; 5972 }; 5973 methods.push('stop'); 5974 for (var _i = 0, _total = methods.length; _i < _total; _i++) { 5975 assignMethods(methods[_i]); 5976 } 5977 5978 var initEvents = ['rendererready']; 5979 5980 for (var _i2 = 0, _total2 = initEvents.length; _i2 < _total2; _i2++) { 5981 var event = (0, _general.createEvent)(initEvents[_i2], flash); 5982 mediaElement.dispatchEvent(event); 5983 } 5984 5985 _window2.default['__ready__' + flash.id] = function () { 5986 5987 flash.flashReady = true; 5988 flash.flashApi = _document2.default.getElementById('__' + flash.id); 5989 5990 if (flash.flashApiStack.length) { 5991 for (var _i3 = 0, _total3 = flash.flashApiStack.length; _i3 < _total3; _i3++) { 5992 var stackItem = flash.flashApiStack[_i3]; 5993 5994 if (stackItem.type === 'set') { 5995 var propName = stackItem.propName, 5996 capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 5997 5998 flash['set' + capName](stackItem.value); 5999 } else if (stackItem.type === 'call') { 6000 flash[stackItem.methodName](); 6001 } 6002 } 6003 } 6004 }; 6005 6006 _window2.default['__event__' + flash.id] = function (eventName, message) { 6007 var event = (0, _general.createEvent)(eventName, flash); 6008 if (message) { 6009 try { 6010 event.data = JSON.parse(message); 6011 event.details.data = JSON.parse(message); 6012 } catch (e) { 6013 event.message = message; 6014 } 6015 } 6016 6017 flash.mediaElement.dispatchEvent(event); 6018 }; 6019 6020 flash.flashWrapper = _document2.default.createElement('div'); 6021 6022 if (['always', 'sameDomain'].indexOf(flash.options.shimScriptAccess) === -1) { 6023 flash.options.shimScriptAccess = 'sameDomain'; 6024 } 6025 6026 var autoplay = mediaElement.originalNode.autoplay, 6027 flashVars = ['uid=' + flash.id, 'autoplay=' + autoplay, 'allowScriptAccess=' + flash.options.shimScriptAccess, 'preload=' + (mediaElement.originalNode.getAttribute('preload') || '')], 6028 isVideo = mediaElement.originalNode !== null && mediaElement.originalNode.tagName.toLowerCase() === 'video', 6029 flashHeight = isVideo ? mediaElement.originalNode.height : 1, 6030 flashWidth = isVideo ? mediaElement.originalNode.width : 1; 6031 6032 if (mediaElement.originalNode.getAttribute('src')) { 6033 flashVars.push('src=' + mediaElement.originalNode.getAttribute('src')); 6034 } 6035 6036 if (flash.options.enablePseudoStreaming === true) { 6037 flashVars.push('pseudostreamstart=' + flash.options.pseudoStreamingStartQueryParam); 6038 flashVars.push('pseudostreamtype=' + flash.options.pseudoStreamingType); 6039 } 6040 6041 if (flash.options.streamDelimiter) { 6042 flashVars.push('streamdelimiter=' + encodeURIComponent(flash.options.streamDelimiter)); 6043 } 6044 6045 if (flash.options.proxyType) { 6046 flashVars.push('proxytype=' + flash.options.proxyType); 6047 } 6048 6049 mediaElement.appendChild(flash.flashWrapper); 6050 mediaElement.originalNode.style.display = 'none'; 6051 6052 var settings = []; 6053 6054 if (_constants.IS_IE || _constants.IS_EDGE) { 6055 var specialIEContainer = _document2.default.createElement('div'); 6056 flash.flashWrapper.appendChild(specialIEContainer); 6057 6058 if (_constants.IS_EDGE) { 6059 settings = ['type="application/x-shockwave-flash"', 'data="' + flash.options.pluginPath + flash.options.filename + '"', 'id="__' + flash.id + '"', 'width="' + flashWidth + '"', 'height="' + flashHeight + '\'"']; 6060 } else { 6061 settings = ['classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"', 'codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"', 'id="__' + flash.id + '"', 'width="' + flashWidth + '"', 'height="' + flashHeight + '"']; 6062 } 6063 6064 if (!isVideo) { 6065 settings.push('style="clip: rect(0 0 0 0); position: absolute;"'); 6066 } 6067 6068 specialIEContainer.outerHTML = '<object ' + settings.join(' ') + '>' + ('<param name="movie" value="' + flash.options.pluginPath + flash.options.filename + '?x=' + new Date() + '" />') + ('<param name="flashvars" value="' + flashVars.join('&') + '" />') + '<param name="quality" value="high" />' + '<param name="bgcolor" value="#000000" />' + '<param name="wmode" value="transparent" />' + ('<param name="allowScriptAccess" value="' + flash.options.shimScriptAccess + '" />') + '<param name="allowFullScreen" value="true" />' + ('<div>' + _i18n2.default.t('mejs.install-flash') + '</div>') + '</object>'; 6069 } else { 6070 6071 settings = ['id="__' + flash.id + '"', 'name="__' + flash.id + '"', 'play="true"', 'loop="false"', 'quality="high"', 'bgcolor="#000000"', 'wmode="transparent"', 'allowScriptAccess="' + flash.options.shimScriptAccess + '"', 'allowFullScreen="true"', 'type="application/x-shockwave-flash"', 'pluginspage="//www.macromedia.com/go/getflashplayer"', 'src="' + flash.options.pluginPath + flash.options.filename + '"', 'flashvars="' + flashVars.join('&') + '"']; 6072 6073 if (isVideo) { 6074 settings.push('width="' + flashWidth + '"'); 6075 settings.push('height="' + flashHeight + '"'); 6076 } else { 6077 settings.push('style="position: fixed; left: -9999em; top: -9999em;"'); 6078 } 6079 6080 flash.flashWrapper.innerHTML = '<embed ' + settings.join(' ') + '>'; 6081 } 6082 6083 flash.flashNode = flash.flashWrapper.lastChild; 6084 6085 flash.hide = function () { 6086 isActive = false; 6087 if (isVideo) { 6088 flash.flashNode.style.display = 'none'; 6089 } 6090 }; 6091 flash.show = function () { 6092 isActive = true; 6093 if (isVideo) { 6094 flash.flashNode.style.display = ''; 6095 } 6096 }; 6097 flash.setSize = function (width, height) { 6098 flash.flashNode.style.width = width + 'px'; 6099 flash.flashNode.style.height = height + 'px'; 6100 6101 if (flash.flashApi !== null && typeof flash.flashApi.fire_setSize === 'function') { 6102 flash.flashApi.fire_setSize(width, height); 6103 } 6104 }; 6105 6106 flash.destroy = function () { 6107 flash.flashNode.remove(); 6108 }; 6109 6110 if (mediaFiles && mediaFiles.length > 0) { 6111 for (var _i4 = 0, _total4 = mediaFiles.length; _i4 < _total4; _i4++) { 6112 if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[_i4].type)) { 6113 flash.setSrc(mediaFiles[_i4].src); 6114 break; 6115 } 6116 } 6117 } 6118 6119 return flash; 6120 } 6121 }; 6122 6123 var hasFlash = PluginDetector.hasPluginVersion('flash', [10, 0, 0]); 6124 6125 if (hasFlash) { 6126 _media.typeChecks.push(function (url) { 6127 url = url.toLowerCase(); 6128 6129 if (url.startsWith('rtmp')) { 6130 if (~url.indexOf('.mp3')) { 6131 return 'audio/rtmp'; 6132 } else { 6133 return 'video/rtmp'; 6134 } 6135 } else if (/\.og(a|g)/i.test(url)) { 6136 return 'audio/ogg'; 6137 } else if (~url.indexOf('.m3u8')) { 6138 return 'application/x-mpegURL'; 6139 } else if (~url.indexOf('.mpd')) { 6140 return 'application/dash+xml'; 6141 } else if (~url.indexOf('.flv')) { 6142 return 'video/flv'; 6143 } else { 6144 return null; 6145 } 6146 }); 6147 6148 var FlashMediaElementVideoRenderer = { 6149 name: 'flash_video', 6150 options: { 6151 prefix: 'flash_video', 6152 filename: 'mediaelement-flash-video.swf', 6153 enablePseudoStreaming: false, 6154 6155 pseudoStreamingStartQueryParam: 'start', 6156 6157 pseudoStreamingType: 'byte', 6158 6159 proxyType: '', 6160 6161 streamDelimiter: '' 6162 }, 6163 6164 canPlayType: function canPlayType(type) { 6165 return ~['video/mp4', 'video/rtmp', 'audio/rtmp', 'rtmp/mp4', 'audio/mp4', 'video/flv', 'video/x-flv'].indexOf(type.toLowerCase()); 6166 }, 6167 6168 create: FlashMediaElementRenderer.create 6169 6170 }; 6171 _renderer.renderer.add(FlashMediaElementVideoRenderer); 6172 6173 var FlashMediaElementHlsVideoRenderer = { 6174 name: 'flash_hls', 6175 options: { 6176 prefix: 'flash_hls', 6177 filename: 'mediaelement-flash-video-hls.swf' 6178 }, 6179 6180 canPlayType: function canPlayType(type) { 6181 return ~['application/x-mpegurl', 'application/vnd.apple.mpegurl', 'audio/mpegurl', 'audio/hls', 'video/hls'].indexOf(type.toLowerCase()); 6182 }, 6183 6184 create: FlashMediaElementRenderer.create 6185 }; 6186 _renderer.renderer.add(FlashMediaElementHlsVideoRenderer); 6187 6188 var FlashMediaElementMdashVideoRenderer = { 6189 name: 'flash_dash', 6190 options: { 6191 prefix: 'flash_dash', 6192 filename: 'mediaelement-flash-video-mdash.swf' 6193 }, 6194 6195 canPlayType: function canPlayType(type) { 6196 return ~['application/dash+xml'].indexOf(type.toLowerCase()); 6197 }, 6198 6199 create: FlashMediaElementRenderer.create 6200 }; 6201 _renderer.renderer.add(FlashMediaElementMdashVideoRenderer); 6202 6203 var FlashMediaElementAudioRenderer = { 6204 name: 'flash_audio', 6205 options: { 6206 prefix: 'flash_audio', 6207 filename: 'mediaelement-flash-audio.swf' 6208 }, 6209 6210 canPlayType: function canPlayType(type) { 6211 return ~['audio/mp3'].indexOf(type.toLowerCase()); 6212 }, 6213 6214 create: FlashMediaElementRenderer.create 6215 }; 6216 _renderer.renderer.add(FlashMediaElementAudioRenderer); 6217 6218 var FlashMediaElementAudioOggRenderer = { 6219 name: 'flash_audio_ogg', 6220 options: { 6221 prefix: 'flash_audio_ogg', 6222 filename: 'mediaelement-flash-audio-ogg.swf' 6223 }, 6224 6225 canPlayType: function canPlayType(type) { 6226 return ~['audio/ogg', 'audio/oga', 'audio/ogv'].indexOf(type.toLowerCase()); 6227 }, 6228 6229 create: FlashMediaElementRenderer.create 6230 }; 6231 _renderer.renderer.add(FlashMediaElementAudioOggRenderer); 6232 } 6233 6234 },{"2":2,"25":25,"27":27,"28":28,"3":3,"5":5,"7":7,"8":8}],21:[function(_dereq_,module,exports){ 6235 'use strict'; 6236 6237 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 6238 6239 var _window = _dereq_(3); 6240 6241 var _window2 = _interopRequireDefault(_window); 6242 6243 var _mejs = _dereq_(7); 6244 6245 var _mejs2 = _interopRequireDefault(_mejs); 6246 6247 var _renderer = _dereq_(8); 6248 6249 var _general = _dereq_(27); 6250 6251 var _constants = _dereq_(25); 6252 6253 var _media = _dereq_(28); 6254 6255 var _dom = _dereq_(26); 6256 6257 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 6258 6259 var NativeFlv = { 6260 6261 promise: null, 6262 6263 load: function load(settings) { 6264 if (typeof flvjs !== 'undefined') { 6265 NativeFlv.promise = new Promise(function (resolve) { 6266 resolve(); 6267 }).then(function () { 6268 NativeFlv._createPlayer(settings); 6269 }); 6270 } else { 6271 settings.options.path = typeof settings.options.path === 'string' ? settings.options.path : 'https://cdn.jsdelivr.net/npm/flv.js@latest'; 6272 6273 NativeFlv.promise = NativeFlv.promise || (0, _dom.loadScript)(settings.options.path); 6274 NativeFlv.promise.then(function () { 6275 NativeFlv._createPlayer(settings); 6276 }); 6277 } 6278 6279 return NativeFlv.promise; 6280 }, 6281 6282 _createPlayer: function _createPlayer(settings) { 6283 flvjs.LoggingControl.enableDebug = settings.options.debug; 6284 flvjs.LoggingControl.enableVerbose = settings.options.debug; 6285 var player = flvjs.createPlayer(settings.options, settings.configs); 6286 _window2.default['__ready__' + settings.id](player); 6287 return player; 6288 } 6289 }; 6290 6291 var FlvNativeRenderer = { 6292 name: 'native_flv', 6293 options: { 6294 prefix: 'native_flv', 6295 flv: { 6296 path: 'https://cdn.jsdelivr.net/npm/flv.js@latest', 6297 6298 cors: true, 6299 debug: false 6300 } 6301 }, 6302 6303 canPlayType: function canPlayType(type) { 6304 return _constants.HAS_MSE && ['video/x-flv', 'video/flv'].indexOf(type.toLowerCase()) > -1; 6305 }, 6306 6307 create: function create(mediaElement, options, mediaFiles) { 6308 6309 var originalNode = mediaElement.originalNode, 6310 id = mediaElement.id + '_' + options.prefix; 6311 6312 var node = null, 6313 flvPlayer = null; 6314 6315 node = originalNode.cloneNode(true); 6316 options = Object.assign(options, mediaElement.options); 6317 6318 var props = _mejs2.default.html5media.properties, 6319 events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']).filter(function (e) { 6320 return e !== 'error'; 6321 }), 6322 attachNativeEvents = function attachNativeEvents(e) { 6323 var event = (0, _general.createEvent)(e.type, mediaElement); 6324 mediaElement.dispatchEvent(event); 6325 }, 6326 assignGettersSetters = function assignGettersSetters(propName) { 6327 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 6328 6329 node['get' + capName] = function () { 6330 return flvPlayer !== null ? node[propName] : null; 6331 }; 6332 6333 node['set' + capName] = function (value) { 6334 if (_mejs2.default.html5media.readOnlyProperties.indexOf(propName) === -1) { 6335 if (propName === 'src') { 6336 node[propName] = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src ? value.src : value; 6337 if (flvPlayer !== null) { 6338 var _flvOptions = {}; 6339 _flvOptions.type = 'flv'; 6340 _flvOptions.url = value; 6341 _flvOptions.cors = options.flv.cors; 6342 _flvOptions.debug = options.flv.debug; 6343 _flvOptions.path = options.flv.path; 6344 var _flvConfigs = options.flv.configs; 6345 6346 flvPlayer.destroy(); 6347 for (var i = 0, total = events.length; i < total; i++) { 6348 node.removeEventListener(events[i], attachNativeEvents); 6349 } 6350 flvPlayer = NativeFlv._createPlayer({ 6351 options: _flvOptions, 6352 configs: _flvConfigs, 6353 id: id 6354 }); 6355 flvPlayer.attachMediaElement(node); 6356 flvPlayer.load(); 6357 } 6358 } else { 6359 node[propName] = value; 6360 } 6361 } 6362 }; 6363 }; 6364 6365 for (var i = 0, total = props.length; i < total; i++) { 6366 assignGettersSetters(props[i]); 6367 } 6368 6369 _window2.default['__ready__' + id] = function (_flvPlayer) { 6370 mediaElement.flvPlayer = flvPlayer = _flvPlayer; 6371 6372 var flvEvents = flvjs.Events, 6373 assignEvents = function assignEvents(eventName) { 6374 if (eventName === 'loadedmetadata') { 6375 flvPlayer.unload(); 6376 flvPlayer.detachMediaElement(); 6377 flvPlayer.attachMediaElement(node); 6378 flvPlayer.load(); 6379 } 6380 6381 node.addEventListener(eventName, attachNativeEvents); 6382 }; 6383 6384 for (var _i = 0, _total = events.length; _i < _total; _i++) { 6385 assignEvents(events[_i]); 6386 } 6387 6388 var assignFlvEvents = function assignFlvEvents(name, data) { 6389 if (name === 'error') { 6390 var message = data[0] + ': ' + data[1] + ' ' + data[2].msg; 6391 mediaElement.generateError(message, node.src); 6392 } else { 6393 var _event = (0, _general.createEvent)(name, mediaElement); 6394 _event.data = data; 6395 mediaElement.dispatchEvent(_event); 6396 } 6397 }; 6398 6399 var _loop = function _loop(eventType) { 6400 if (flvEvents.hasOwnProperty(eventType)) { 6401 flvPlayer.on(flvEvents[eventType], function () { 6402 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { 6403 args[_key] = arguments[_key]; 6404 } 6405 6406 return assignFlvEvents(flvEvents[eventType], args); 6407 }); 6408 } 6409 }; 6410 6411 for (var eventType in flvEvents) { 6412 _loop(eventType); 6413 } 6414 }; 6415 6416 if (mediaFiles && mediaFiles.length > 0) { 6417 for (var _i2 = 0, _total2 = mediaFiles.length; _i2 < _total2; _i2++) { 6418 if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[_i2].type)) { 6419 node.setAttribute('src', mediaFiles[_i2].src); 6420 break; 6421 } 6422 } 6423 } 6424 6425 node.setAttribute('id', id); 6426 6427 originalNode.parentNode.insertBefore(node, originalNode); 6428 originalNode.autoplay = false; 6429 originalNode.style.display = 'none'; 6430 6431 var flvOptions = {}; 6432 flvOptions.type = 'flv'; 6433 flvOptions.url = node.src; 6434 flvOptions.cors = options.flv.cors; 6435 flvOptions.debug = options.flv.debug; 6436 flvOptions.path = options.flv.path; 6437 var flvConfigs = options.flv.configs; 6438 6439 node.setSize = function (width, height) { 6440 node.style.width = width + 'px'; 6441 node.style.height = height + 'px'; 6442 return node; 6443 }; 6444 6445 node.hide = function () { 6446 if (flvPlayer !== null) { 6447 flvPlayer.pause(); 6448 } 6449 node.style.display = 'none'; 6450 return node; 6451 }; 6452 6453 node.show = function () { 6454 node.style.display = ''; 6455 return node; 6456 }; 6457 6458 node.destroy = function () { 6459 if (flvPlayer !== null) { 6460 flvPlayer.destroy(); 6461 } 6462 }; 6463 6464 var event = (0, _general.createEvent)('rendererready', node); 6465 mediaElement.dispatchEvent(event); 6466 6467 mediaElement.promises.push(NativeFlv.load({ 6468 options: flvOptions, 6469 configs: flvConfigs, 6470 id: id 6471 })); 6472 6473 return node; 6474 } 6475 }; 6476 6477 _media.typeChecks.push(function (url) { 6478 return ~url.toLowerCase().indexOf('.flv') ? 'video/flv' : null; 6479 }); 6480 6481 _renderer.renderer.add(FlvNativeRenderer); 6482 6483 },{"25":25,"26":26,"27":27,"28":28,"3":3,"7":7,"8":8}],22:[function(_dereq_,module,exports){ 6484 'use strict'; 6485 6486 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; 6487 6488 var _window = _dereq_(3); 6489 6490 var _window2 = _interopRequireDefault(_window); 6491 6492 var _mejs = _dereq_(7); 6493 6494 var _mejs2 = _interopRequireDefault(_mejs); 6495 6496 var _renderer = _dereq_(8); 6497 6498 var _general = _dereq_(27); 6499 6500 var _constants = _dereq_(25); 6501 6502 var _media = _dereq_(28); 6503 6504 var _dom = _dereq_(26); 6505 6506 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 6507 6508 var NativeHls = { 6509 6510 promise: null, 6511 6512 load: function load(settings) { 6513 if (typeof Hls !== 'undefined') { 6514 NativeHls.promise = new Promise(function (resolve) { 6515 resolve(); 6516 }).then(function () { 6517 NativeHls._createPlayer(settings); 6518 }); 6519 } else { 6520 settings.options.path = typeof settings.options.path === 'string' ? settings.options.path : 'https://cdn.jsdelivr.net/npm/hls.js@latest'; 6521 6522 NativeHls.promise = NativeHls.promise || (0, _dom.loadScript)(settings.options.path); 6523 NativeHls.promise.then(function () { 6524 NativeHls._createPlayer(settings); 6525 }); 6526 } 6527 6528 return NativeHls.promise; 6529 }, 6530 6531 _createPlayer: function _createPlayer(settings) { 6532 var player = new Hls(settings.options); 6533 _window2.default['__ready__' + settings.id](player); 6534 return player; 6535 } 6536 }; 6537 6538 var HlsNativeRenderer = { 6539 name: 'native_hls', 6540 options: { 6541 prefix: 'native_hls', 6542 hls: { 6543 path: 'https://cdn.jsdelivr.net/npm/hls.js@latest', 6544 6545 autoStartLoad: false, 6546 debug: false 6547 } 6548 }, 6549 6550 canPlayType: function canPlayType(type) { 6551 return _constants.HAS_MSE && ['application/x-mpegurl', 'application/vnd.apple.mpegurl', 'audio/mpegurl', 'audio/hls', 'video/hls'].indexOf(type.toLowerCase()) > -1; 6552 }, 6553 6554 create: function create(mediaElement, options, mediaFiles) { 6555 6556 var originalNode = mediaElement.originalNode, 6557 id = mediaElement.id + '_' + options.prefix, 6558 preload = originalNode.getAttribute('preload'), 6559 autoplay = originalNode.autoplay; 6560 6561 var hlsPlayer = null, 6562 node = null, 6563 index = 0, 6564 total = mediaFiles.length; 6565 6566 node = originalNode.cloneNode(true); 6567 options = Object.assign(options, mediaElement.options); 6568 options.hls.autoStartLoad = preload && preload !== 'none' || autoplay; 6569 6570 var props = _mejs2.default.html5media.properties, 6571 events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']).filter(function (e) { 6572 return e !== 'error'; 6573 }), 6574 attachNativeEvents = function attachNativeEvents(e) { 6575 var event = (0, _general.createEvent)(e.type, mediaElement); 6576 mediaElement.dispatchEvent(event); 6577 }, 6578 assignGettersSetters = function assignGettersSetters(propName) { 6579 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 6580 6581 node['get' + capName] = function () { 6582 return hlsPlayer !== null ? node[propName] : null; 6583 }; 6584 6585 node['set' + capName] = function (value) { 6586 if (_mejs2.default.html5media.readOnlyProperties.indexOf(propName) === -1) { 6587 if (propName === 'src') { 6588 node[propName] = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src ? value.src : value; 6589 if (hlsPlayer !== null) { 6590 hlsPlayer.destroy(); 6591 for (var i = 0, _total = events.length; i < _total; i++) { 6592 node.removeEventListener(events[i], attachNativeEvents); 6593 } 6594 hlsPlayer = NativeHls._createPlayer({ 6595 options: options.hls, 6596 id: id 6597 }); 6598 hlsPlayer.loadSource(value); 6599 hlsPlayer.attachMedia(node); 6600 } 6601 } else { 6602 node[propName] = value; 6603 } 6604 } 6605 }; 6606 }; 6607 6608 for (var i = 0, _total2 = props.length; i < _total2; i++) { 6609 assignGettersSetters(props[i]); 6610 } 6611 6612 _window2.default['__ready__' + id] = function (_hlsPlayer) { 6613 mediaElement.hlsPlayer = hlsPlayer = _hlsPlayer; 6614 var hlsEvents = Hls.Events, 6615 assignEvents = function assignEvents(eventName) { 6616 if (eventName === 'loadedmetadata') { 6617 var url = mediaElement.originalNode.src; 6618 hlsPlayer.detachMedia(); 6619 hlsPlayer.loadSource(url); 6620 hlsPlayer.attachMedia(node); 6621 } 6622 6623 node.addEventListener(eventName, attachNativeEvents); 6624 }; 6625 6626 for (var _i = 0, _total3 = events.length; _i < _total3; _i++) { 6627 assignEvents(events[_i]); 6628 } 6629 6630 var recoverDecodingErrorDate = void 0, 6631 recoverSwapAudioCodecDate = void 0; 6632 var assignHlsEvents = function assignHlsEvents(name, data) { 6633 if (name === 'hlsError') { 6634 console.warn(data); 6635 data = data[1]; 6636 6637 if (data.fatal) { 6638 switch (data.type) { 6639 case 'mediaError': 6640 var now = new Date().getTime(); 6641 if (!recoverDecodingErrorDate || now - recoverDecodingErrorDate > 3000) { 6642 recoverDecodingErrorDate = new Date().getTime(); 6643 hlsPlayer.recoverMediaError(); 6644 } else if (!recoverSwapAudioCodecDate || now - recoverSwapAudioCodecDate > 3000) { 6645 recoverSwapAudioCodecDate = new Date().getTime(); 6646 console.warn('Attempting to swap Audio Codec and recover from media error'); 6647 hlsPlayer.swapAudioCodec(); 6648 hlsPlayer.recoverMediaError(); 6649 } else { 6650 var message = 'Cannot recover, last media error recovery failed'; 6651 mediaElement.generateError(message, node.src); 6652 console.error(message); 6653 } 6654 break; 6655 case 'networkError': 6656 if (data.details === 'manifestLoadError') { 6657 if (index < total && mediaFiles[index + 1] !== undefined) { 6658 node.setSrc(mediaFiles[index++].src); 6659 node.load(); 6660 node.play(); 6661 } else { 6662 var _message = 'Network error'; 6663 mediaElement.generateError(_message, mediaFiles); 6664 console.error(_message); 6665 } 6666 } else { 6667 var _message2 = 'Network error'; 6668 mediaElement.generateError(_message2, mediaFiles); 6669 console.error(_message2); 6670 } 6671 break; 6672 default: 6673 hlsPlayer.destroy(); 6674 break; 6675 } 6676 return; 6677 } 6678 } 6679 var event = (0, _general.createEvent)(name, mediaElement); 6680 event.data = data; 6681 mediaElement.dispatchEvent(event); 6682 }; 6683 6684 var _loop = function _loop(eventType) { 6685 if (hlsEvents.hasOwnProperty(eventType)) { 6686 hlsPlayer.on(hlsEvents[eventType], function () { 6687 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { 6688 args[_key] = arguments[_key]; 6689 } 6690 6691 return assignHlsEvents(hlsEvents[eventType], args); 6692 }); 6693 } 6694 }; 6695 6696 for (var eventType in hlsEvents) { 6697 _loop(eventType); 6698 } 6699 }; 6700 6701 if (total > 0) { 6702 for (; index < total; index++) { 6703 if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[index].type)) { 6704 node.setAttribute('src', mediaFiles[index].src); 6705 break; 6706 } 6707 } 6708 } 6709 6710 if (preload !== 'auto' && !autoplay) { 6711 node.addEventListener('play', function () { 6712 if (hlsPlayer !== null) { 6713 hlsPlayer.startLoad(); 6714 } 6715 }); 6716 6717 node.addEventListener('pause', function () { 6718 if (hlsPlayer !== null) { 6719 hlsPlayer.stopLoad(); 6720 } 6721 }); 6722 } 6723 6724 node.setAttribute('id', id); 6725 6726 originalNode.parentNode.insertBefore(node, originalNode); 6727 originalNode.autoplay = false; 6728 originalNode.style.display = 'none'; 6729 6730 node.setSize = function (width, height) { 6731 node.style.width = width + 'px'; 6732 node.style.height = height + 'px'; 6733 return node; 6734 }; 6735 6736 node.hide = function () { 6737 node.pause(); 6738 node.style.display = 'none'; 6739 return node; 6740 }; 6741 6742 node.show = function () { 6743 node.style.display = ''; 6744 return node; 6745 }; 6746 6747 node.destroy = function () { 6748 if (hlsPlayer !== null) { 6749 hlsPlayer.stopLoad(); 6750 hlsPlayer.destroy(); 6751 } 6752 }; 6753 6754 var event = (0, _general.createEvent)('rendererready', node); 6755 mediaElement.dispatchEvent(event); 6756 6757 mediaElement.promises.push(NativeHls.load({ 6758 options: options.hls, 6759 id: id 6760 })); 6761 6762 return node; 6763 } 6764 }; 6765 6766 _media.typeChecks.push(function (url) { 6767 return ~url.toLowerCase().indexOf('.m3u8') ? 'application/x-mpegURL' : null; 6768 }); 6769 6770 _renderer.renderer.add(HlsNativeRenderer); 6771 6772 },{"25":25,"26":26,"27":27,"28":28,"3":3,"7":7,"8":8}],23:[function(_dereq_,module,exports){ 6773 'use strict'; 6774 6775 var _window = _dereq_(3); 6776 6777 var _window2 = _interopRequireDefault(_window); 6778 6779 var _document = _dereq_(2); 6780 6781 var _document2 = _interopRequireDefault(_document); 6782 6783 var _mejs = _dereq_(7); 6784 6785 var _mejs2 = _interopRequireDefault(_mejs); 6786 6787 var _renderer = _dereq_(8); 6788 6789 var _general = _dereq_(27); 6790 6791 var _constants = _dereq_(25); 6792 6793 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 6794 6795 var HtmlMediaElement = { 6796 name: 'html5', 6797 options: { 6798 prefix: 'html5' 6799 }, 6800 6801 canPlayType: function canPlayType(type) { 6802 6803 var mediaElement = _document2.default.createElement('video'); 6804 6805 if (_constants.IS_ANDROID && /\/mp(3|4)$/i.test(type) || ~['application/x-mpegurl', 'vnd.apple.mpegurl', 'audio/mpegurl', 'audio/hls', 'video/hls'].indexOf(type.toLowerCase()) && _constants.SUPPORTS_NATIVE_HLS) { 6806 return 'yes'; 6807 } else if (mediaElement.canPlayType) { 6808 return mediaElement.canPlayType(type.toLowerCase()).replace(/no/, ''); 6809 } else { 6810 return ''; 6811 } 6812 }, 6813 6814 create: function create(mediaElement, options, mediaFiles) { 6815 6816 var id = mediaElement.id + '_' + options.prefix; 6817 var isActive = false; 6818 6819 var node = null; 6820 6821 if (mediaElement.originalNode === undefined || mediaElement.originalNode === null) { 6822 node = _document2.default.createElement('audio'); 6823 mediaElement.appendChild(node); 6824 } else { 6825 node = mediaElement.originalNode; 6826 } 6827 6828 node.setAttribute('id', id); 6829 6830 var props = _mejs2.default.html5media.properties, 6831 assignGettersSetters = function assignGettersSetters(propName) { 6832 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 6833 6834 node['get' + capName] = function () { 6835 return node[propName]; 6836 }; 6837 6838 node['set' + capName] = function (value) { 6839 if (_mejs2.default.html5media.readOnlyProperties.indexOf(propName) === -1) { 6840 node[propName] = value; 6841 } 6842 }; 6843 }; 6844 6845 for (var i = 0, _total = props.length; i < _total; i++) { 6846 assignGettersSetters(props[i]); 6847 } 6848 6849 var events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']).filter(function (e) { 6850 return e !== 'error'; 6851 }), 6852 assignEvents = function assignEvents(eventName) { 6853 node.addEventListener(eventName, function (e) { 6854 if (isActive) { 6855 var _event = (0, _general.createEvent)(e.type, e.target); 6856 mediaElement.dispatchEvent(_event); 6857 } 6858 }); 6859 }; 6860 6861 for (var _i = 0, _total2 = events.length; _i < _total2; _i++) { 6862 assignEvents(events[_i]); 6863 } 6864 6865 node.setSize = function (width, height) { 6866 node.style.width = width + 'px'; 6867 node.style.height = height + 'px'; 6868 return node; 6869 }; 6870 6871 node.hide = function () { 6872 isActive = false; 6873 node.style.display = 'none'; 6874 6875 return node; 6876 }; 6877 6878 node.show = function () { 6879 isActive = true; 6880 node.style.display = ''; 6881 6882 return node; 6883 }; 6884 6885 var index = 0, 6886 total = mediaFiles.length; 6887 if (total > 0) { 6888 for (; index < total; index++) { 6889 if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[index].type)) { 6890 node.setAttribute('src', mediaFiles[index].src); 6891 break; 6892 } 6893 } 6894 } 6895 6896 node.addEventListener('error', function (e) { 6897 if (e && e.target && e.target.error && e.target.error.code === 4 && isActive) { 6898 if (index < total && mediaFiles[index + 1] !== undefined) { 6899 node.src = mediaFiles[index++].src; 6900 node.load(); 6901 node.play(); 6902 } else { 6903 mediaElement.generateError('Media error: Format(s) not supported or source(s) not found', mediaFiles); 6904 } 6905 } 6906 }); 6907 6908 var event = (0, _general.createEvent)('rendererready', node); 6909 mediaElement.dispatchEvent(event); 6910 6911 return node; 6912 } 6913 }; 6914 6915 _window2.default.HtmlMediaElement = _mejs2.default.HtmlMediaElement = HtmlMediaElement; 6916 6917 _renderer.renderer.add(HtmlMediaElement); 6918 6919 },{"2":2,"25":25,"27":27,"3":3,"7":7,"8":8}],24:[function(_dereq_,module,exports){ 6920 'use strict'; 6921 6922 var _window = _dereq_(3); 6923 6924 var _window2 = _interopRequireDefault(_window); 6925 6926 var _document = _dereq_(2); 6927 6928 var _document2 = _interopRequireDefault(_document); 6929 6930 var _mejs = _dereq_(7); 6931 6932 var _mejs2 = _interopRequireDefault(_mejs); 6933 6934 var _renderer = _dereq_(8); 6935 6936 var _general = _dereq_(27); 6937 6938 var _media = _dereq_(28); 6939 6940 var _dom = _dereq_(26); 6941 6942 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 6943 6944 var YouTubeApi = { 6945 isIframeStarted: false, 6946 6947 isIframeLoaded: false, 6948 6949 iframeQueue: [], 6950 6951 enqueueIframe: function enqueueIframe(settings) { 6952 YouTubeApi.isLoaded = typeof YT !== 'undefined' && YT.loaded; 6953 6954 if (YouTubeApi.isLoaded) { 6955 YouTubeApi.createIframe(settings); 6956 } else { 6957 YouTubeApi.loadIframeApi(); 6958 YouTubeApi.iframeQueue.push(settings); 6959 } 6960 }, 6961 6962 loadIframeApi: function loadIframeApi() { 6963 if (!YouTubeApi.isIframeStarted) { 6964 (0, _dom.loadScript)('https://www.youtube.com/player_api'); 6965 YouTubeApi.isIframeStarted = true; 6966 } 6967 }, 6968 6969 iFrameReady: function iFrameReady() { 6970 6971 YouTubeApi.isLoaded = true; 6972 YouTubeApi.isIframeLoaded = true; 6973 6974 while (YouTubeApi.iframeQueue.length > 0) { 6975 var settings = YouTubeApi.iframeQueue.pop(); 6976 YouTubeApi.createIframe(settings); 6977 } 6978 }, 6979 6980 createIframe: function createIframe(settings) { 6981 return new YT.Player(settings.containerId, settings); 6982 }, 6983 6984 getYouTubeId: function getYouTubeId(url) { 6985 6986 var youTubeId = ''; 6987 6988 if (url.indexOf('?') > 0) { 6989 youTubeId = YouTubeApi.getYouTubeIdFromParam(url); 6990 6991 if (youTubeId === '') { 6992 youTubeId = YouTubeApi.getYouTubeIdFromUrl(url); 6993 } 6994 } else { 6995 youTubeId = YouTubeApi.getYouTubeIdFromUrl(url); 6996 } 6997 6998 var id = youTubeId.substring(youTubeId.lastIndexOf('/') + 1); 6999 youTubeId = id.split('?'); 7000 return youTubeId[0]; 7001 }, 7002 7003 getYouTubeIdFromParam: function getYouTubeIdFromParam(url) { 7004 7005 if (url === undefined || url === null || !url.trim().length) { 7006 return null; 7007 } 7008 7009 var parts = url.split('?'), 7010 parameters = parts[1].split('&'); 7011 7012 var youTubeId = ''; 7013 7014 for (var i = 0, total = parameters.length; i < total; i++) { 7015 var paramParts = parameters[i].split('='); 7016 if (paramParts[0] === 'v') { 7017 youTubeId = paramParts[1]; 7018 break; 7019 } 7020 } 7021 7022 return youTubeId; 7023 }, 7024 7025 getYouTubeIdFromUrl: function getYouTubeIdFromUrl(url) { 7026 7027 if (url === undefined || url === null || !url.trim().length) { 7028 return null; 7029 } 7030 7031 var parts = url.split('?'); 7032 url = parts[0]; 7033 return url.substring(url.lastIndexOf('/') + 1); 7034 }, 7035 7036 getYouTubeNoCookieUrl: function getYouTubeNoCookieUrl(url) { 7037 if (url === undefined || url === null || !url.trim().length || url.indexOf('//www.youtube') === -1) { 7038 return url; 7039 } 7040 7041 var parts = url.split('/'); 7042 parts[2] = parts[2].replace('.com', '-nocookie.com'); 7043 return parts.join('/'); 7044 } 7045 }; 7046 7047 var YouTubeIframeRenderer = { 7048 name: 'youtube_iframe', 7049 7050 options: { 7051 prefix: 'youtube_iframe', 7052 7053 youtube: { 7054 autoplay: 0, 7055 controls: 0, 7056 disablekb: 1, 7057 end: 0, 7058 loop: 0, 7059 modestbranding: 0, 7060 playsinline: 0, 7061 rel: 0, 7062 showinfo: 0, 7063 start: 0, 7064 iv_load_policy: 3, 7065 7066 nocookie: false, 7067 7068 imageQuality: null 7069 } 7070 }, 7071 7072 canPlayType: function canPlayType(type) { 7073 return ~['video/youtube', 'video/x-youtube'].indexOf(type.toLowerCase()); 7074 }, 7075 7076 create: function create(mediaElement, options, mediaFiles) { 7077 7078 var youtube = {}, 7079 apiStack = [], 7080 readyState = 4; 7081 7082 var youTubeApi = null, 7083 paused = true, 7084 ended = false, 7085 youTubeIframe = null, 7086 volume = 1; 7087 7088 youtube.options = options; 7089 youtube.id = mediaElement.id + '_' + options.prefix; 7090 youtube.mediaElement = mediaElement; 7091 7092 var props = _mejs2.default.html5media.properties, 7093 assignGettersSetters = function assignGettersSetters(propName) { 7094 7095 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 7096 7097 youtube['get' + capName] = function () { 7098 if (youTubeApi !== null) { 7099 var value = null; 7100 7101 switch (propName) { 7102 case 'currentTime': 7103 return youTubeApi.getCurrentTime(); 7104 case 'duration': 7105 return youTubeApi.getDuration(); 7106 case 'volume': 7107 volume = youTubeApi.getVolume() / 100; 7108 return volume; 7109 case 'playbackRate': 7110 return youTubeApi.getPlaybackRate(); 7111 case 'paused': 7112 return paused; 7113 case 'ended': 7114 return ended; 7115 case 'muted': 7116 return youTubeApi.isMuted(); 7117 case 'buffered': 7118 var percentLoaded = youTubeApi.getVideoLoadedFraction(), 7119 duration = youTubeApi.getDuration(); 7120 return { 7121 start: function start() { 7122 return 0; 7123 }, 7124 end: function end() { 7125 return percentLoaded * duration; 7126 }, 7127 length: 1 7128 }; 7129 case 'src': 7130 return youTubeApi.getVideoUrl(); 7131 case 'readyState': 7132 return readyState; 7133 } 7134 7135 return value; 7136 } else { 7137 return null; 7138 } 7139 }; 7140 7141 youtube['set' + capName] = function (value) { 7142 if (youTubeApi !== null) { 7143 switch (propName) { 7144 case 'src': 7145 var url = typeof value === 'string' ? value : value[0].src, 7146 _videoId = YouTubeApi.getYouTubeId(url); 7147 7148 if (mediaElement.originalNode.autoplay) { 7149 youTubeApi.loadVideoById(_videoId); 7150 } else { 7151 youTubeApi.cueVideoById(_videoId); 7152 } 7153 break; 7154 case 'currentTime': 7155 youTubeApi.seekTo(value); 7156 break; 7157 case 'muted': 7158 if (value) { 7159 youTubeApi.mute(); 7160 } else { 7161 youTubeApi.unMute(); 7162 } 7163 setTimeout(function () { 7164 var event = (0, _general.createEvent)('volumechange', youtube); 7165 mediaElement.dispatchEvent(event); 7166 }, 50); 7167 break; 7168 case 'volume': 7169 volume = value; 7170 youTubeApi.setVolume(value * 100); 7171 setTimeout(function () { 7172 var event = (0, _general.createEvent)('volumechange', youtube); 7173 mediaElement.dispatchEvent(event); 7174 }, 50); 7175 break; 7176 case 'playbackRate': 7177 youTubeApi.setPlaybackRate(value); 7178 setTimeout(function () { 7179 var event = (0, _general.createEvent)('ratechange', youtube); 7180 mediaElement.dispatchEvent(event); 7181 }, 50); 7182 break; 7183 case 'readyState': 7184 var event = (0, _general.createEvent)('canplay', youtube); 7185 mediaElement.dispatchEvent(event); 7186 break; 7187 default: 7188 7189 break; 7190 } 7191 } else { 7192 apiStack.push({ type: 'set', propName: propName, value: value }); 7193 } 7194 }; 7195 }; 7196 7197 for (var i = 0, total = props.length; i < total; i++) { 7198 assignGettersSetters(props[i]); 7199 } 7200 7201 var methods = _mejs2.default.html5media.methods, 7202 assignMethods = function assignMethods(methodName) { 7203 youtube[methodName] = function () { 7204 if (youTubeApi !== null) { 7205 switch (methodName) { 7206 case 'play': 7207 paused = false; 7208 return youTubeApi.playVideo(); 7209 case 'pause': 7210 paused = true; 7211 return youTubeApi.pauseVideo(); 7212 case 'load': 7213 return null; 7214 } 7215 } else { 7216 apiStack.push({ type: 'call', methodName: methodName }); 7217 } 7218 }; 7219 }; 7220 7221 for (var _i = 0, _total = methods.length; _i < _total; _i++) { 7222 assignMethods(methods[_i]); 7223 } 7224 7225 var errorHandler = function errorHandler(error) { 7226 var message = ''; 7227 switch (error.data) { 7228 case 2: 7229 message = 'The request contains an invalid parameter value. Verify that video ID has 11 characters and that contains no invalid characters, such as exclamation points or asterisks.'; 7230 break; 7231 case 5: 7232 message = 'The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.'; 7233 break; 7234 case 100: 7235 message = 'The video requested was not found. Either video has been removed or has been marked as private.'; 7236 break; 7237 case 101: 7238 case 105: 7239 message = 'The owner of the requested video does not allow it to be played in embedded players.'; 7240 break; 7241 default: 7242 message = 'Unknown error.'; 7243 break; 7244 } 7245 mediaElement.generateError('Code ' + error.data + ': ' + message, mediaFiles); 7246 }; 7247 7248 var youtubeContainer = _document2.default.createElement('div'); 7249 youtubeContainer.id = youtube.id; 7250 7251 if (youtube.options.youtube.nocookie) { 7252 mediaElement.originalNode.src = YouTubeApi.getYouTubeNoCookieUrl(mediaFiles[0].src); 7253 } 7254 7255 mediaElement.originalNode.parentNode.insertBefore(youtubeContainer, mediaElement.originalNode); 7256 mediaElement.originalNode.style.display = 'none'; 7257 7258 var isAudio = mediaElement.originalNode.tagName.toLowerCase() === 'audio', 7259 height = isAudio ? '1' : mediaElement.originalNode.height, 7260 width = isAudio ? '1' : mediaElement.originalNode.width, 7261 videoId = YouTubeApi.getYouTubeId(mediaFiles[0].src), 7262 youtubeSettings = { 7263 id: youtube.id, 7264 containerId: youtubeContainer.id, 7265 videoId: videoId, 7266 height: height, 7267 width: width, 7268 host: youtube.options.youtube && youtube.options.youtube.nocookie ? 'https://www.youtube-nocookie.com' : undefined, 7269 playerVars: Object.assign({ 7270 controls: 0, 7271 rel: 0, 7272 disablekb: 1, 7273 showinfo: 0, 7274 modestbranding: 0, 7275 html5: 1, 7276 iv_load_policy: 3 7277 }, youtube.options.youtube), 7278 origin: _window2.default.location.host, 7279 events: { 7280 onReady: function onReady(e) { 7281 mediaElement.youTubeApi = youTubeApi = e.target; 7282 mediaElement.youTubeState = { 7283 paused: true, 7284 ended: false 7285 }; 7286 7287 if (apiStack.length) { 7288 for (var _i2 = 0, _total2 = apiStack.length; _i2 < _total2; _i2++) { 7289 7290 var stackItem = apiStack[_i2]; 7291 7292 if (stackItem.type === 'set') { 7293 var propName = stackItem.propName, 7294 capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 7295 7296 youtube['set' + capName](stackItem.value); 7297 } else if (stackItem.type === 'call') { 7298 youtube[stackItem.methodName](); 7299 } 7300 } 7301 } 7302 7303 youTubeIframe = youTubeApi.getIframe(); 7304 7305 if (mediaElement.originalNode.muted) { 7306 youTubeApi.mute(); 7307 } 7308 7309 var events = ['mouseover', 'mouseout'], 7310 assignEvents = function assignEvents(e) { 7311 var newEvent = (0, _general.createEvent)(e.type, youtube); 7312 mediaElement.dispatchEvent(newEvent); 7313 }; 7314 7315 for (var _i3 = 0, _total3 = events.length; _i3 < _total3; _i3++) { 7316 youTubeIframe.addEventListener(events[_i3], assignEvents, false); 7317 } 7318 7319 var initEvents = ['rendererready', 'loadedmetadata', 'loadeddata', 'canplay']; 7320 7321 for (var _i4 = 0, _total4 = initEvents.length; _i4 < _total4; _i4++) { 7322 var event = (0, _general.createEvent)(initEvents[_i4], youtube); 7323 mediaElement.dispatchEvent(event); 7324 } 7325 }, 7326 onStateChange: function onStateChange(e) { 7327 var events = []; 7328 7329 switch (e.data) { 7330 case -1: 7331 events = ['loadedmetadata']; 7332 paused = true; 7333 ended = false; 7334 break; 7335 case 0: 7336 events = ['ended']; 7337 paused = false; 7338 ended = !youtube.options.youtube.loop; 7339 if (!youtube.options.youtube.loop) { 7340 youtube.stopInterval(); 7341 } 7342 break; 7343 case 1: 7344 events = ['play', 'playing']; 7345 paused = false; 7346 ended = false; 7347 youtube.startInterval(); 7348 break; 7349 case 2: 7350 events = ['pause']; 7351 paused = true; 7352 ended = false; 7353 youtube.stopInterval(); 7354 break; 7355 case 3: 7356 events = ['progress']; 7357 ended = false; 7358 break; 7359 case 5: 7360 events = ['loadeddata', 'loadedmetadata', 'canplay']; 7361 paused = true; 7362 ended = false; 7363 break; 7364 } 7365 7366 for (var _i5 = 0, _total5 = events.length; _i5 < _total5; _i5++) { 7367 var event = (0, _general.createEvent)(events[_i5], youtube); 7368 mediaElement.dispatchEvent(event); 7369 } 7370 }, 7371 onError: function onError(e) { 7372 return errorHandler(e); 7373 } 7374 } 7375 }; 7376 7377 if (isAudio || mediaElement.originalNode.hasAttribute('playsinline')) { 7378 youtubeSettings.playerVars.playsinline = 1; 7379 } 7380 7381 if (mediaElement.originalNode.controls) { 7382 youtubeSettings.playerVars.controls = 1; 7383 } 7384 if (mediaElement.originalNode.autoplay) { 7385 youtubeSettings.playerVars.autoplay = 1; 7386 } 7387 if (mediaElement.originalNode.loop) { 7388 youtubeSettings.playerVars.loop = 1; 7389 } 7390 7391 if ((youtubeSettings.playerVars.loop && parseInt(youtubeSettings.playerVars.loop, 10) === 1 || mediaElement.originalNode.src.indexOf('loop=') > -1) && !youtubeSettings.playerVars.playlist && mediaElement.originalNode.src.indexOf('playlist=') === -1) { 7392 youtubeSettings.playerVars.playlist = YouTubeApi.getYouTubeId(mediaElement.originalNode.src); 7393 } 7394 7395 YouTubeApi.enqueueIframe(youtubeSettings); 7396 7397 youtube.onEvent = function (eventName, player, _youTubeState) { 7398 if (_youTubeState !== null && _youTubeState !== undefined) { 7399 mediaElement.youTubeState = _youTubeState; 7400 } 7401 }; 7402 7403 youtube.setSize = function (width, height) { 7404 if (youTubeApi !== null) { 7405 youTubeApi.setSize(width, height); 7406 } 7407 }; 7408 youtube.hide = function () { 7409 youtube.stopInterval(); 7410 youtube.pause(); 7411 if (youTubeIframe) { 7412 youTubeIframe.style.display = 'none'; 7413 } 7414 }; 7415 youtube.show = function () { 7416 if (youTubeIframe) { 7417 youTubeIframe.style.display = ''; 7418 } 7419 }; 7420 youtube.destroy = function () { 7421 youTubeApi.destroy(); 7422 }; 7423 youtube.interval = null; 7424 7425 youtube.startInterval = function () { 7426 youtube.interval = setInterval(function () { 7427 var event = (0, _general.createEvent)('timeupdate', youtube); 7428 mediaElement.dispatchEvent(event); 7429 }, 250); 7430 }; 7431 youtube.stopInterval = function () { 7432 if (youtube.interval) { 7433 clearInterval(youtube.interval); 7434 } 7435 }; 7436 youtube.getPosterUrl = function () { 7437 var quality = options.youtube.imageQuality, 7438 resolutions = ['default', 'hqdefault', 'mqdefault', 'sddefault', 'maxresdefault'], 7439 id = YouTubeApi.getYouTubeId(mediaElement.originalNode.src); 7440 return quality && resolutions.indexOf(quality) > -1 && id ? 'https://img.youtube.com/vi/' + id + '/' + quality + '.jpg' : ''; 7441 }; 7442 7443 return youtube; 7444 } 7445 }; 7446 7447 _window2.default.onYouTubePlayerAPIReady = function () { 7448 YouTubeApi.iFrameReady(); 7449 }; 7450 7451 _media.typeChecks.push(function (url) { 7452 return (/\/\/(www\.youtube|youtu\.?be)/i.test(url) ? 'video/x-youtube' : null 7453 ); 7454 }); 7455 7456 _renderer.renderer.add(YouTubeIframeRenderer); 7457 7458 },{"2":2,"26":26,"27":27,"28":28,"3":3,"7":7,"8":8}],25:[function(_dereq_,module,exports){ 7459 'use strict'; 7460 7461 Object.defineProperty(exports, "__esModule", { 7462 value: true 7463 }); 7464 exports.cancelFullScreen = exports.requestFullScreen = exports.isFullScreen = exports.FULLSCREEN_EVENT_NAME = exports.HAS_NATIVE_FULLSCREEN_ENABLED = exports.HAS_TRUE_NATIVE_FULLSCREEN = exports.HAS_IOS_FULLSCREEN = exports.HAS_MS_NATIVE_FULLSCREEN = exports.HAS_MOZ_NATIVE_FULLSCREEN = exports.HAS_WEBKIT_NATIVE_FULLSCREEN = exports.HAS_NATIVE_FULLSCREEN = exports.SUPPORTS_NATIVE_HLS = exports.SUPPORT_PASSIVE_EVENT = exports.SUPPORT_POINTER_EVENTS = exports.HAS_MSE = exports.IS_STOCK_ANDROID = exports.IS_SAFARI = exports.IS_FIREFOX = exports.IS_CHROME = exports.IS_EDGE = exports.IS_IE = exports.IS_ANDROID = exports.IS_IOS = exports.IS_IPOD = exports.IS_IPHONE = exports.IS_IPAD = exports.UA = exports.NAV = undefined; 7465 7466 var _window = _dereq_(3); 7467 7468 var _window2 = _interopRequireDefault(_window); 7469 7470 var _document = _dereq_(2); 7471 7472 var _document2 = _interopRequireDefault(_document); 7473 7474 var _mejs = _dereq_(7); 7475 7476 var _mejs2 = _interopRequireDefault(_mejs); 7477 7478 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 7479 7480 var NAV = exports.NAV = _window2.default.navigator; 7481 var UA = exports.UA = NAV.userAgent.toLowerCase(); 7482 var IS_IPAD = exports.IS_IPAD = /ipad/i.test(UA) && !_window2.default.MSStream; 7483 var IS_IPHONE = exports.IS_IPHONE = /iphone/i.test(UA) && !_window2.default.MSStream; 7484 var IS_IPOD = exports.IS_IPOD = /ipod/i.test(UA) && !_window2.default.MSStream; 7485 var IS_IOS = exports.IS_IOS = /ipad|iphone|ipod/i.test(UA) && !_window2.default.MSStream; 7486 var IS_ANDROID = exports.IS_ANDROID = /android/i.test(UA); 7487 var IS_IE = exports.IS_IE = /(trident|microsoft)/i.test(NAV.appName); 7488 var IS_EDGE = exports.IS_EDGE = 'msLaunchUri' in NAV && !('documentMode' in _document2.default); 7489 var IS_CHROME = exports.IS_CHROME = /chrome/i.test(UA); 7490 var IS_FIREFOX = exports.IS_FIREFOX = /firefox/i.test(UA); 7491 var IS_SAFARI = exports.IS_SAFARI = /safari/i.test(UA) && !IS_CHROME; 7492 var IS_STOCK_ANDROID = exports.IS_STOCK_ANDROID = /^mozilla\/\d+\.\d+\s\(linux;\su;/i.test(UA); 7493 var HAS_MSE = exports.HAS_MSE = 'MediaSource' in _window2.default; 7494 var SUPPORT_POINTER_EVENTS = exports.SUPPORT_POINTER_EVENTS = function () { 7495 var element = _document2.default.createElement('x'), 7496 documentElement = _document2.default.documentElement, 7497 getComputedStyle = _window2.default.getComputedStyle; 7498 7499 if (!('pointerEvents' in element.style)) { 7500 return false; 7501 } 7502 7503 element.style.pointerEvents = 'auto'; 7504 element.style.pointerEvents = 'x'; 7505 documentElement.appendChild(element); 7506 var supports = getComputedStyle && (getComputedStyle(element, '') || {}).pointerEvents === 'auto'; 7507 element.remove(); 7508 return !!supports; 7509 }(); 7510 7511 var SUPPORT_PASSIVE_EVENT = exports.SUPPORT_PASSIVE_EVENT = function () { 7512 var supportsPassive = false; 7513 try { 7514 var opts = Object.defineProperty({}, 'passive', { 7515 get: function get() { 7516 supportsPassive = true; 7517 } 7518 }); 7519 _window2.default.addEventListener('test', null, opts); 7520 } catch (e) {} 7521 7522 return supportsPassive; 7523 }(); 7524 7525 var html5Elements = ['source', 'track', 'audio', 'video']; 7526 var video = void 0; 7527 7528 for (var i = 0, total = html5Elements.length; i < total; i++) { 7529 video = _document2.default.createElement(html5Elements[i]); 7530 } 7531 7532 var SUPPORTS_NATIVE_HLS = exports.SUPPORTS_NATIVE_HLS = IS_SAFARI || IS_IE && /edge/i.test(UA); 7533 7534 var hasiOSFullScreen = video.webkitEnterFullscreen !== undefined; 7535 7536 var hasNativeFullscreen = video.requestFullscreen !== undefined; 7537 7538 if (hasiOSFullScreen && /mac os x 10_5/i.test(UA)) { 7539 hasNativeFullscreen = false; 7540 hasiOSFullScreen = false; 7541 } 7542 7543 var hasWebkitNativeFullScreen = video.webkitRequestFullScreen !== undefined; 7544 var hasMozNativeFullScreen = video.mozRequestFullScreen !== undefined; 7545 var hasMsNativeFullScreen = video.msRequestFullscreen !== undefined; 7546 var hasTrueNativeFullScreen = hasWebkitNativeFullScreen || hasMozNativeFullScreen || hasMsNativeFullScreen; 7547 var nativeFullScreenEnabled = hasTrueNativeFullScreen; 7548 var fullScreenEventName = ''; 7549 var isFullScreen = void 0, 7550 requestFullScreen = void 0, 7551 cancelFullScreen = void 0; 7552 7553 if (hasMozNativeFullScreen) { 7554 nativeFullScreenEnabled = _document2.default.mozFullScreenEnabled; 7555 } else if (hasMsNativeFullScreen) { 7556 nativeFullScreenEnabled = _document2.default.msFullscreenEnabled; 7557 } 7558 7559 if (IS_CHROME) { 7560 hasiOSFullScreen = false; 7561 } 7562 7563 if (hasTrueNativeFullScreen) { 7564 if (hasWebkitNativeFullScreen) { 7565 fullScreenEventName = 'webkitfullscreenchange'; 7566 } else if (hasMozNativeFullScreen) { 7567 fullScreenEventName = 'fullscreenchange'; 7568 } else if (hasMsNativeFullScreen) { 7569 fullScreenEventName = 'MSFullscreenChange'; 7570 } 7571 7572 exports.isFullScreen = isFullScreen = function isFullScreen() { 7573 if (hasMozNativeFullScreen) { 7574 return _document2.default.mozFullScreen; 7575 } else if (hasWebkitNativeFullScreen) { 7576 return _document2.default.webkitIsFullScreen; 7577 } else if (hasMsNativeFullScreen) { 7578 return _document2.default.msFullscreenElement !== null; 7579 } 7580 }; 7581 7582 exports.requestFullScreen = requestFullScreen = function requestFullScreen(el) { 7583 if (hasWebkitNativeFullScreen) { 7584 el.webkitRequestFullScreen(); 7585 } else if (hasMozNativeFullScreen) { 7586 el.mozRequestFullScreen(); 7587 } else if (hasMsNativeFullScreen) { 7588 el.msRequestFullscreen(); 7589 } 7590 }; 7591 7592 exports.cancelFullScreen = cancelFullScreen = function cancelFullScreen() { 7593 if (hasWebkitNativeFullScreen) { 7594 _document2.default.webkitCancelFullScreen(); 7595 } else if (hasMozNativeFullScreen) { 7596 _document2.default.mozCancelFullScreen(); 7597 } else if (hasMsNativeFullScreen) { 7598 _document2.default.msExitFullscreen(); 7599 } 7600 }; 7601 } 7602 7603 var HAS_NATIVE_FULLSCREEN = exports.HAS_NATIVE_FULLSCREEN = hasNativeFullscreen; 7604 var HAS_WEBKIT_NATIVE_FULLSCREEN = exports.HAS_WEBKIT_NATIVE_FULLSCREEN = hasWebkitNativeFullScreen; 7605 var HAS_MOZ_NATIVE_FULLSCREEN = exports.HAS_MOZ_NATIVE_FULLSCREEN = hasMozNativeFullScreen; 7606 var HAS_MS_NATIVE_FULLSCREEN = exports.HAS_MS_NATIVE_FULLSCREEN = hasMsNativeFullScreen; 7607 var HAS_IOS_FULLSCREEN = exports.HAS_IOS_FULLSCREEN = hasiOSFullScreen; 7608 var HAS_TRUE_NATIVE_FULLSCREEN = exports.HAS_TRUE_NATIVE_FULLSCREEN = hasTrueNativeFullScreen; 7609 var HAS_NATIVE_FULLSCREEN_ENABLED = exports.HAS_NATIVE_FULLSCREEN_ENABLED = nativeFullScreenEnabled; 7610 var FULLSCREEN_EVENT_NAME = exports.FULLSCREEN_EVENT_NAME = fullScreenEventName; 7611 exports.isFullScreen = isFullScreen; 7612 exports.requestFullScreen = requestFullScreen; 7613 exports.cancelFullScreen = cancelFullScreen; 7614 7615 7616 _mejs2.default.Features = _mejs2.default.Features || {}; 7617 _mejs2.default.Features.isiPad = IS_IPAD; 7618 _mejs2.default.Features.isiPod = IS_IPOD; 7619 _mejs2.default.Features.isiPhone = IS_IPHONE; 7620 _mejs2.default.Features.isiOS = _mejs2.default.Features.isiPhone || _mejs2.default.Features.isiPad; 7621 _mejs2.default.Features.isAndroid = IS_ANDROID; 7622 _mejs2.default.Features.isIE = IS_IE; 7623 _mejs2.default.Features.isEdge = IS_EDGE; 7624 _mejs2.default.Features.isChrome = IS_CHROME; 7625 _mejs2.default.Features.isFirefox = IS_FIREFOX; 7626 _mejs2.default.Features.isSafari = IS_SAFARI; 7627 _mejs2.default.Features.isStockAndroid = IS_STOCK_ANDROID; 7628 _mejs2.default.Features.hasMSE = HAS_MSE; 7629 _mejs2.default.Features.supportsNativeHLS = SUPPORTS_NATIVE_HLS; 7630 _mejs2.default.Features.supportsPointerEvents = SUPPORT_POINTER_EVENTS; 7631 _mejs2.default.Features.supportsPassiveEvent = SUPPORT_PASSIVE_EVENT; 7632 _mejs2.default.Features.hasiOSFullScreen = HAS_IOS_FULLSCREEN; 7633 _mejs2.default.Features.hasNativeFullscreen = HAS_NATIVE_FULLSCREEN; 7634 _mejs2.default.Features.hasWebkitNativeFullScreen = HAS_WEBKIT_NATIVE_FULLSCREEN; 7635 _mejs2.default.Features.hasMozNativeFullScreen = HAS_MOZ_NATIVE_FULLSCREEN; 7636 _mejs2.default.Features.hasMsNativeFullScreen = HAS_MS_NATIVE_FULLSCREEN; 7637 _mejs2.default.Features.hasTrueNativeFullScreen = HAS_TRUE_NATIVE_FULLSCREEN; 7638 _mejs2.default.Features.nativeFullScreenEnabled = HAS_NATIVE_FULLSCREEN_ENABLED; 7639 _mejs2.default.Features.fullScreenEventName = FULLSCREEN_EVENT_NAME; 7640 _mejs2.default.Features.isFullScreen = isFullScreen; 7641 _mejs2.default.Features.requestFullScreen = requestFullScreen; 7642 _mejs2.default.Features.cancelFullScreen = cancelFullScreen; 7643 7644 },{"2":2,"3":3,"7":7}],26:[function(_dereq_,module,exports){ 7645 'use strict'; 7646 7647 Object.defineProperty(exports, "__esModule", { 7648 value: true 7649 }); 7650 exports.removeClass = exports.addClass = exports.hasClass = undefined; 7651 exports.loadScript = loadScript; 7652 exports.offset = offset; 7653 exports.toggleClass = toggleClass; 7654 exports.fadeOut = fadeOut; 7655 exports.fadeIn = fadeIn; 7656 exports.siblings = siblings; 7657 exports.visible = visible; 7658 exports.ajax = ajax; 7659 7660 var _window = _dereq_(3); 7661 7662 var _window2 = _interopRequireDefault(_window); 7663 7664 var _document = _dereq_(2); 7665 7666 var _document2 = _interopRequireDefault(_document); 7667 7668 var _mejs = _dereq_(7); 7669 7670 var _mejs2 = _interopRequireDefault(_mejs); 7671 7672 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 7673 7674 function loadScript(url) { 7675 return new Promise(function (resolve, reject) { 7676 var script = _document2.default.createElement('script'); 7677 script.src = url; 7678 script.async = true; 7679 script.onload = function () { 7680 script.remove(); 7681 resolve(); 7682 }; 7683 script.onerror = function () { 7684 script.remove(); 7685 reject(); 7686 }; 7687 _document2.default.head.appendChild(script); 7688 }); 7689 } 7690 7691 function offset(el) { 7692 var rect = el.getBoundingClientRect(), 7693 scrollLeft = _window2.default.pageXOffset || _document2.default.documentElement.scrollLeft, 7694 scrollTop = _window2.default.pageYOffset || _document2.default.documentElement.scrollTop; 7695 return { top: rect.top + scrollTop, left: rect.left + scrollLeft }; 7696 } 7697 7698 var hasClassMethod = void 0, 7699 addClassMethod = void 0, 7700 removeClassMethod = void 0; 7701 7702 if ('classList' in _document2.default.documentElement) { 7703 hasClassMethod = function hasClassMethod(el, className) { 7704 return el.classList !== undefined && el.classList.contains(className); 7705 }; 7706 addClassMethod = function addClassMethod(el, className) { 7707 return el.classList.add(className); 7708 }; 7709 removeClassMethod = function removeClassMethod(el, className) { 7710 return el.classList.remove(className); 7711 }; 7712 } else { 7713 hasClassMethod = function hasClassMethod(el, className) { 7714 return new RegExp('\\b' + className + '\\b').test(el.className); 7715 }; 7716 addClassMethod = function addClassMethod(el, className) { 7717 if (!hasClass(el, className)) { 7718 el.className += ' ' + className; 7719 } 7720 }; 7721 removeClassMethod = function removeClassMethod(el, className) { 7722 el.className = el.className.replace(new RegExp('\\b' + className + '\\b', 'g'), ''); 7723 }; 7724 } 7725 7726 var hasClass = exports.hasClass = hasClassMethod; 7727 var addClass = exports.addClass = addClassMethod; 7728 var removeClass = exports.removeClass = removeClassMethod; 7729 7730 function toggleClass(el, className) { 7731 hasClass(el, className) ? removeClass(el, className) : addClass(el, className); 7732 } 7733 7734 function fadeOut(el) { 7735 var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400; 7736 var callback = arguments[2]; 7737 7738 if (!el.style.opacity) { 7739 el.style.opacity = 1; 7740 } 7741 7742 var start = null; 7743 _window2.default.requestAnimationFrame(function animate(timestamp) { 7744 start = start || timestamp; 7745 var progress = timestamp - start; 7746 var opacity = parseFloat(1 - progress / duration, 2); 7747 el.style.opacity = opacity < 0 ? 0 : opacity; 7748 if (progress > duration) { 7749 if (callback && typeof callback === 'function') { 7750 callback(); 7751 } 7752 } else { 7753 _window2.default.requestAnimationFrame(animate); 7754 } 7755 }); 7756 } 7757 7758 function fadeIn(el) { 7759 var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400; 7760 var callback = arguments[2]; 7761 7762 if (!el.style.opacity) { 7763 el.style.opacity = 0; 7764 } 7765 7766 var start = null; 7767 _window2.default.requestAnimationFrame(function animate(timestamp) { 7768 start = start || timestamp; 7769 var progress = timestamp - start; 7770 var opacity = parseFloat(progress / duration, 2); 7771 el.style.opacity = opacity > 1 ? 1 : opacity; 7772 if (progress > duration) { 7773 if (callback && typeof callback === 'function') { 7774 callback(); 7775 } 7776 } else { 7777 _window2.default.requestAnimationFrame(animate); 7778 } 7779 }); 7780 } 7781 7782 function siblings(el, filter) { 7783 var siblings = []; 7784 el = el.parentNode.firstChild; 7785 do { 7786 if (!filter || filter(el)) { 7787 siblings.push(el); 7788 } 7789 } while (el = el.nextSibling); 7790 return siblings; 7791 } 7792 7793 function visible(elem) { 7794 if (elem.getClientRects !== undefined && elem.getClientRects === 'function') { 7795 return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length); 7796 } 7797 return !!(elem.offsetWidth || elem.offsetHeight); 7798 } 7799 7800 function ajax(url, dataType, success, error) { 7801 var xhr = _window2.default.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); 7802 7803 var type = 'application/x-www-form-urlencoded; charset=UTF-8', 7804 completed = false, 7805 accept = '*/'.concat('*'); 7806 7807 switch (dataType) { 7808 case 'text': 7809 type = 'text/plain'; 7810 break; 7811 case 'json': 7812 type = 'application/json, text/javascript'; 7813 break; 7814 case 'html': 7815 type = 'text/html'; 7816 break; 7817 case 'xml': 7818 type = 'application/xml, text/xml'; 7819 break; 7820 } 7821 7822 if (type !== 'application/x-www-form-urlencoded') { 7823 accept = type + ', */*; q=0.01'; 7824 } 7825 7826 if (xhr) { 7827 xhr.open('GET', url, true); 7828 xhr.setRequestHeader('Accept', accept); 7829 xhr.onreadystatechange = function () { 7830 if (completed) { 7831 return; 7832 } 7833 7834 if (xhr.readyState === 4) { 7835 if (xhr.status === 200) { 7836 completed = true; 7837 var data = void 0; 7838 switch (dataType) { 7839 case 'json': 7840 data = JSON.parse(xhr.responseText); 7841 break; 7842 case 'xml': 7843 data = xhr.responseXML; 7844 break; 7845 default: 7846 data = xhr.responseText; 7847 break; 7848 } 7849 success(data); 7850 } else if (typeof error === 'function') { 7851 error(xhr.status); 7852 } 7853 } 7854 }; 7855 7856 xhr.send(); 7857 } 7858 } 7859 7860 _mejs2.default.Utils = _mejs2.default.Utils || {}; 7861 _mejs2.default.Utils.offset = offset; 7862 _mejs2.default.Utils.hasClass = hasClass; 7863 _mejs2.default.Utils.addClass = addClass; 7864 _mejs2.default.Utils.removeClass = removeClass; 7865 _mejs2.default.Utils.toggleClass = toggleClass; 7866 _mejs2.default.Utils.fadeIn = fadeIn; 7867 _mejs2.default.Utils.fadeOut = fadeOut; 7868 _mejs2.default.Utils.siblings = siblings; 7869 _mejs2.default.Utils.visible = visible; 7870 _mejs2.default.Utils.ajax = ajax; 7871 _mejs2.default.Utils.loadScript = loadScript; 7872 7873 },{"2":2,"3":3,"7":7}],27:[function(_dereq_,module,exports){ 7874 'use strict'; 7875 7876 Object.defineProperty(exports, "__esModule", { 7877 value: true 7878 }); 7879 exports.escapeHTML = escapeHTML; 7880 exports.debounce = debounce; 7881 exports.isObjectEmpty = isObjectEmpty; 7882 exports.splitEvents = splitEvents; 7883 exports.createEvent = createEvent; 7884 exports.isNodeAfter = isNodeAfter; 7885 exports.isString = isString; 7886 7887 var _mejs = _dereq_(7); 7888 7889 var _mejs2 = _interopRequireDefault(_mejs); 7890 7891 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 7892 7893 function escapeHTML(input) { 7894 7895 if (typeof input !== 'string') { 7896 throw new Error('Argument passed must be a string'); 7897 } 7898 7899 var map = { 7900 '&': '&', 7901 '<': '<', 7902 '>': '>', 7903 '"': '"' 7904 }; 7905 7906 return input.replace(/[&<>"]/g, function (c) { 7907 return map[c]; 7908 }); 7909 } 7910 7911 function debounce(func, wait) { 7912 var _this = this, 7913 _arguments = arguments; 7914 7915 var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 7916 7917 7918 if (typeof func !== 'function') { 7919 throw new Error('First argument must be a function'); 7920 } 7921 7922 if (typeof wait !== 'number') { 7923 throw new Error('Second argument must be a numeric value'); 7924 } 7925 7926 var timeout = void 0; 7927 return function () { 7928 var context = _this, 7929 args = _arguments; 7930 var later = function later() { 7931 timeout = null; 7932 if (!immediate) { 7933 func.apply(context, args); 7934 } 7935 }; 7936 var callNow = immediate && !timeout; 7937 clearTimeout(timeout); 7938 timeout = setTimeout(later, wait); 7939 7940 if (callNow) { 7941 func.apply(context, args); 7942 } 7943 }; 7944 } 7945 7946 function isObjectEmpty(instance) { 7947 return Object.getOwnPropertyNames(instance).length <= 0; 7948 } 7949 7950 function splitEvents(events, id) { 7951 var rwindow = /^((after|before)print|(before)?unload|hashchange|message|o(ff|n)line|page(hide|show)|popstate|resize|storage)\b/; 7952 7953 var ret = { d: [], w: [] }; 7954 (events || '').split(' ').forEach(function (v) { 7955 var eventName = '' + v + (id ? '.' + id : ''); 7956 7957 if (eventName.startsWith('.')) { 7958 ret.d.push(eventName); 7959 ret.w.push(eventName); 7960 } else { 7961 ret[rwindow.test(v) ? 'w' : 'd'].push(eventName); 7962 } 7963 }); 7964 7965 ret.d = ret.d.join(' '); 7966 ret.w = ret.w.join(' '); 7967 return ret; 7968 } 7969 7970 function createEvent(eventName, target) { 7971 7972 if (typeof eventName !== 'string') { 7973 throw new Error('Event name must be a string'); 7974 } 7975 7976 var eventFrags = eventName.match(/([a-z]+\.([a-z]+))/i), 7977 detail = { 7978 target: target 7979 }; 7980 7981 if (eventFrags !== null) { 7982 eventName = eventFrags[1]; 7983 detail.namespace = eventFrags[2]; 7984 } 7985 7986 return new window.CustomEvent(eventName, { 7987 detail: detail 7988 }); 7989 } 7990 7991 function isNodeAfter(sourceNode, targetNode) { 7992 7993 return !!(sourceNode && targetNode && sourceNode.compareDocumentPosition(targetNode) & 2); 7994 } 7995 7996 function isString(value) { 7997 return typeof value === 'string'; 7998 } 7999 8000 _mejs2.default.Utils = _mejs2.default.Utils || {}; 8001 _mejs2.default.Utils.escapeHTML = escapeHTML; 8002 _mejs2.default.Utils.debounce = debounce; 8003 _mejs2.default.Utils.isObjectEmpty = isObjectEmpty; 8004 _mejs2.default.Utils.splitEvents = splitEvents; 8005 _mejs2.default.Utils.createEvent = createEvent; 8006 _mejs2.default.Utils.isNodeAfter = isNodeAfter; 8007 _mejs2.default.Utils.isString = isString; 8008 8009 },{"7":7}],28:[function(_dereq_,module,exports){ 8010 'use strict'; 8011 8012 Object.defineProperty(exports, "__esModule", { 8013 value: true 8014 }); 8015 exports.typeChecks = undefined; 8016 exports.absolutizeUrl = absolutizeUrl; 8017 exports.formatType = formatType; 8018 exports.getMimeFromType = getMimeFromType; 8019 exports.getTypeFromFile = getTypeFromFile; 8020 exports.getExtension = getExtension; 8021 exports.normalizeExtension = normalizeExtension; 8022 8023 var _mejs = _dereq_(7); 8024 8025 var _mejs2 = _interopRequireDefault(_mejs); 8026 8027 var _general = _dereq_(27); 8028 8029 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8030 8031 var typeChecks = exports.typeChecks = []; 8032 8033 function absolutizeUrl(url) { 8034 8035 if (typeof url !== 'string') { 8036 throw new Error('`url` argument must be a string'); 8037 } 8038 8039 var el = document.createElement('div'); 8040 el.innerHTML = '<a href="' + (0, _general.escapeHTML)(url) + '">x</a>'; 8041 return el.firstChild.href; 8042 } 8043 8044 function formatType(url) { 8045 var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 8046 8047 return url && !type ? getTypeFromFile(url) : type; 8048 } 8049 8050 function getMimeFromType(type) { 8051 8052 if (typeof type !== 'string') { 8053 throw new Error('`type` argument must be a string'); 8054 } 8055 8056 return type && type.indexOf(';') > -1 ? type.substr(0, type.indexOf(';')) : type; 8057 } 8058 8059 function getTypeFromFile(url) { 8060 8061 if (typeof url !== 'string') { 8062 throw new Error('`url` argument must be a string'); 8063 } 8064 8065 for (var i = 0, total = typeChecks.length; i < total; i++) { 8066 var type = typeChecks[i](url); 8067 8068 if (type) { 8069 return type; 8070 } 8071 } 8072 8073 var ext = getExtension(url), 8074 normalizedExt = normalizeExtension(ext); 8075 8076 var mime = 'video/mp4'; 8077 8078 if (normalizedExt) { 8079 if (~['mp4', 'm4v', 'ogg', 'ogv', 'webm', 'flv', 'mpeg'].indexOf(normalizedExt)) { 8080 mime = 'video/' + normalizedExt; 8081 } else if ('mov' === normalizedExt) { 8082 mime = 'video/quicktime'; 8083 } else if (~['mp3', 'oga', 'wav', 'mid', 'midi'].indexOf(normalizedExt)) { 8084 mime = 'audio/' + normalizedExt; 8085 } 8086 } 8087 8088 return mime; 8089 } 8090 8091 function getExtension(url) { 8092 8093 if (typeof url !== 'string') { 8094 throw new Error('`url` argument must be a string'); 8095 } 8096 8097 var baseUrl = url.split('?')[0], 8098 baseName = baseUrl.split('\\').pop().split('/').pop(); 8099 return ~baseName.indexOf('.') ? baseName.substring(baseName.lastIndexOf('.') + 1) : ''; 8100 } 8101 8102 function normalizeExtension(extension) { 8103 8104 if (typeof extension !== 'string') { 8105 throw new Error('`extension` argument must be a string'); 8106 } 8107 8108 switch (extension) { 8109 case 'mp4': 8110 case 'm4v': 8111 return 'mp4'; 8112 case 'webm': 8113 case 'webma': 8114 case 'webmv': 8115 return 'webm'; 8116 case 'ogg': 8117 case 'oga': 8118 case 'ogv': 8119 return 'ogg'; 8120 default: 8121 return extension; 8122 } 8123 } 8124 8125 _mejs2.default.Utils = _mejs2.default.Utils || {}; 8126 _mejs2.default.Utils.typeChecks = typeChecks; 8127 _mejs2.default.Utils.absolutizeUrl = absolutizeUrl; 8128 _mejs2.default.Utils.formatType = formatType; 8129 _mejs2.default.Utils.getMimeFromType = getMimeFromType; 8130 _mejs2.default.Utils.getTypeFromFile = getTypeFromFile; 8131 _mejs2.default.Utils.getExtension = getExtension; 8132 _mejs2.default.Utils.normalizeExtension = normalizeExtension; 8133 8134 },{"27":27,"7":7}],29:[function(_dereq_,module,exports){ 8135 'use strict'; 8136 8137 var _document = _dereq_(2); 8138 8139 var _document2 = _interopRequireDefault(_document); 8140 8141 var _promisePolyfill = _dereq_(4); 8142 8143 var _promisePolyfill2 = _interopRequireDefault(_promisePolyfill); 8144 8145 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8146 8147 (function (arr) { 8148 arr.forEach(function (item) { 8149 if (item.hasOwnProperty('remove')) { 8150 return; 8151 } 8152 Object.defineProperty(item, 'remove', { 8153 configurable: true, 8154 enumerable: true, 8155 writable: true, 8156 value: function remove() { 8157 this.parentNode.removeChild(this); 8158 } 8159 }); 8160 }); 8161 })([Element.prototype, CharacterData.prototype, DocumentType.prototype]); 8162 8163 (function () { 8164 8165 if (typeof window.CustomEvent === 'function') { 8166 return false; 8167 } 8168 8169 function CustomEvent(event, params) { 8170 params = params || { bubbles: false, cancelable: false, detail: undefined }; 8171 var evt = _document2.default.createEvent('CustomEvent'); 8172 evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); 8173 return evt; 8174 } 8175 8176 CustomEvent.prototype = window.Event.prototype; 8177 window.CustomEvent = CustomEvent; 8178 })(); 8179 8180 if (typeof Object.assign !== 'function') { 8181 Object.assign = function (target) { 8182 8183 if (target === null || target === undefined) { 8184 throw new TypeError('Cannot convert undefined or null to object'); 8185 } 8186 8187 var to = Object(target); 8188 8189 for (var index = 1, total = arguments.length; index < total; index++) { 8190 var nextSource = arguments[index]; 8191 8192 if (nextSource !== null) { 8193 for (var nextKey in nextSource) { 8194 if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { 8195 to[nextKey] = nextSource[nextKey]; 8196 } 8197 } 8198 } 8199 } 8200 return to; 8201 }; 8202 } 8203 8204 if (!String.prototype.startsWith) { 8205 String.prototype.startsWith = function (searchString, position) { 8206 position = position || 0; 8207 return this.substr(position, searchString.length) === searchString; 8208 }; 8209 } 8210 8211 if (!Element.prototype.matches) { 8212 Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector || function (s) { 8213 var matches = (this.document || this.ownerDocument).querySelectorAll(s), 8214 i = matches.length - 1; 8215 while (--i >= 0 && matches.item(i) !== this) {} 8216 return i > -1; 8217 }; 8218 } 8219 8220 if (window.Element && !Element.prototype.closest) { 8221 Element.prototype.closest = function (s) { 8222 var matches = (this.document || this.ownerDocument).querySelectorAll(s), 8223 i = void 0, 8224 el = this; 8225 do { 8226 i = matches.length; 8227 while (--i >= 0 && matches.item(i) !== el) {} 8228 } while (i < 0 && (el = el.parentElement)); 8229 return el; 8230 }; 8231 } 8232 8233 (function () { 8234 var lastTime = 0; 8235 var vendors = ['ms', 'moz', 'webkit', 'o']; 8236 for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { 8237 window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; 8238 window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame']; 8239 } 8240 8241 if (!window.requestAnimationFrame) window.requestAnimationFrame = function (callback) { 8242 var currTime = new Date().getTime(); 8243 var timeToCall = Math.max(0, 16 - (currTime - lastTime)); 8244 var id = window.setTimeout(function () { 8245 callback(currTime + timeToCall); 8246 }, timeToCall); 8247 lastTime = currTime + timeToCall; 8248 return id; 8249 }; 8250 8251 if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function (id) { 8252 clearTimeout(id); 8253 }; 8254 })(); 8255 8256 if (/firefox/i.test(navigator.userAgent)) { 8257 var getComputedStyle = window.getComputedStyle; 8258 window.getComputedStyle = function (el, pseudoEl) { 8259 var t = getComputedStyle(el, pseudoEl); 8260 return t === null ? { getPropertyValue: function getPropertyValue() {} } : t; 8261 }; 8262 } 8263 8264 if (!window.Promise) { 8265 window.Promise = _promisePolyfill2.default; 8266 } 8267 8268 (function (constructor) { 8269 if (constructor && constructor.prototype && constructor.prototype.children === null) { 8270 Object.defineProperty(constructor.prototype, 'children', { 8271 get: function get() { 8272 var i = 0, 8273 node = void 0, 8274 nodes = this.childNodes, 8275 children = []; 8276 while (node = nodes[i++]) { 8277 if (node.nodeType === 1) { 8278 children.push(node); 8279 } 8280 } 8281 return children; 8282 } 8283 }); 8284 } 8285 })(window.Node || window.Element); 8286 8287 },{"2":2,"4":4}],30:[function(_dereq_,module,exports){ 8288 'use strict'; 8289 8290 Object.defineProperty(exports, "__esModule", { 8291 value: true 8292 }); 8293 exports.isDropFrame = isDropFrame; 8294 exports.secondsToTimeCode = secondsToTimeCode; 8295 exports.timeCodeToSeconds = timeCodeToSeconds; 8296 exports.calculateTimeFormat = calculateTimeFormat; 8297 exports.convertSMPTEtoSeconds = convertSMPTEtoSeconds; 8298 8299 var _mejs = _dereq_(7); 8300 8301 var _mejs2 = _interopRequireDefault(_mejs); 8302 8303 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8304 8305 function isDropFrame() { 8306 var fps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 25; 8307 8308 return !(fps % 1 === 0); 8309 } 8310 function secondsToTimeCode(time) { 8311 var forceHours = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 8312 var showFrameCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 8313 var fps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 25; 8314 var secondsDecimalLength = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; 8315 var timeFormat = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 'hh:mm:ss'; 8316 8317 8318 time = !time || typeof time !== 'number' || time < 0 ? 0 : time; 8319 8320 var dropFrames = Math.round(fps * 0.066666), 8321 timeBase = Math.round(fps), 8322 framesPer24Hours = Math.round(fps * 3600) * 24, 8323 framesPer10Minutes = Math.round(fps * 600), 8324 frameSep = isDropFrame(fps) ? ';' : ':', 8325 hours = void 0, 8326 minutes = void 0, 8327 seconds = void 0, 8328 frames = void 0, 8329 f = Math.round(time * fps); 8330 8331 if (isDropFrame(fps)) { 8332 8333 if (f < 0) { 8334 f = framesPer24Hours + f; 8335 } 8336 8337 f = f % framesPer24Hours; 8338 8339 var d = Math.floor(f / framesPer10Minutes); 8340 var m = f % framesPer10Minutes; 8341 f = f + dropFrames * 9 * d; 8342 if (m > dropFrames) { 8343 f = f + dropFrames * Math.floor((m - dropFrames) / Math.round(timeBase * 60 - dropFrames)); 8344 } 8345 8346 var timeBaseDivision = Math.floor(f / timeBase); 8347 8348 hours = Math.floor(Math.floor(timeBaseDivision / 60) / 60); 8349 minutes = Math.floor(timeBaseDivision / 60) % 60; 8350 8351 if (showFrameCount) { 8352 seconds = timeBaseDivision % 60; 8353 } else { 8354 seconds = Math.floor(f / timeBase % 60).toFixed(secondsDecimalLength); 8355 } 8356 } else { 8357 hours = Math.floor(time / 3600) % 24; 8358 minutes = Math.floor(time / 60) % 60; 8359 if (showFrameCount) { 8360 seconds = Math.floor(time % 60); 8361 } else { 8362 seconds = Math.floor(time % 60).toFixed(secondsDecimalLength); 8363 } 8364 } 8365 hours = hours <= 0 ? 0 : hours; 8366 minutes = minutes <= 0 ? 0 : minutes; 8367 seconds = seconds <= 0 ? 0 : seconds; 8368 8369 seconds = seconds === 60 ? 0 : seconds; 8370 minutes = minutes === 60 ? 0 : minutes; 8371 8372 var timeFormatFrags = timeFormat.split(':'); 8373 var timeFormatSettings = {}; 8374 for (var i = 0, total = timeFormatFrags.length; i < total; ++i) { 8375 var unique = ''; 8376 for (var j = 0, t = timeFormatFrags[i].length; j < t; j++) { 8377 if (unique.indexOf(timeFormatFrags[i][j]) < 0) { 8378 unique += timeFormatFrags[i][j]; 8379 } 8380 } 8381 if (~['f', 's', 'm', 'h'].indexOf(unique)) { 8382 timeFormatSettings[unique] = timeFormatFrags[i].length; 8383 } 8384 } 8385 8386 var result = forceHours || hours > 0 ? (hours < 10 && timeFormatSettings.h > 1 ? '0' + hours : hours) + ':' : ''; 8387 result += (minutes < 10 && timeFormatSettings.m > 1 ? '0' + minutes : minutes) + ':'; 8388 result += '' + (seconds < 10 && timeFormatSettings.s > 1 ? '0' + seconds : seconds); 8389 8390 if (showFrameCount) { 8391 frames = (f % timeBase).toFixed(0); 8392 frames = frames <= 0 ? 0 : frames; 8393 result += frames < 10 && timeFormatSettings.f ? frameSep + '0' + frames : '' + frameSep + frames; 8394 } 8395 8396 return result; 8397 } 8398 8399 function timeCodeToSeconds(time) { 8400 var fps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25; 8401 8402 8403 if (typeof time !== 'string') { 8404 throw new TypeError('Time must be a string'); 8405 } 8406 8407 if (time.indexOf(';') > 0) { 8408 time = time.replace(';', ':'); 8409 } 8410 8411 if (!/\d{2}(\:\d{2}){0,3}/i.test(time)) { 8412 throw new TypeError('Time code must have the format `00:00:00`'); 8413 } 8414 8415 var parts = time.split(':'); 8416 8417 var output = void 0, 8418 hours = 0, 8419 minutes = 0, 8420 seconds = 0, 8421 frames = 0, 8422 totalMinutes = 0, 8423 dropFrames = Math.round(fps * 0.066666), 8424 timeBase = Math.round(fps), 8425 hFrames = timeBase * 3600, 8426 mFrames = timeBase * 60; 8427 8428 switch (parts.length) { 8429 default: 8430 case 1: 8431 seconds = parseInt(parts[0], 10); 8432 break; 8433 case 2: 8434 minutes = parseInt(parts[0], 10); 8435 seconds = parseInt(parts[1], 10); 8436 break; 8437 case 3: 8438 hours = parseInt(parts[0], 10); 8439 minutes = parseInt(parts[1], 10); 8440 seconds = parseInt(parts[2], 10); 8441 break; 8442 case 4: 8443 hours = parseInt(parts[0], 10); 8444 minutes = parseInt(parts[1], 10); 8445 seconds = parseInt(parts[2], 10); 8446 frames = parseInt(parts[3], 10); 8447 break; 8448 } 8449 8450 if (isDropFrame(fps)) { 8451 totalMinutes = 60 * hours + minutes; 8452 output = hFrames * hours + mFrames * minutes + timeBase * seconds + frames - dropFrames * (totalMinutes - Math.floor(totalMinutes / 10)); 8453 } else { 8454 output = (hFrames * hours + mFrames * minutes + fps * seconds + frames) / fps; 8455 } 8456 8457 return parseFloat(output.toFixed(3)); 8458 } 8459 8460 function calculateTimeFormat(time, options) { 8461 var fps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 25; 8462 8463 8464 time = !time || typeof time !== 'number' || time < 0 ? 0 : time; 8465 8466 var hours = Math.floor(time / 3600) % 24, 8467 minutes = Math.floor(time / 60) % 60, 8468 seconds = Math.floor(time % 60), 8469 frames = Math.floor((time % 1 * fps).toFixed(3)), 8470 lis = [[frames, 'f'], [seconds, 's'], [minutes, 'm'], [hours, 'h']]; 8471 8472 var format = options.timeFormat, 8473 firstTwoPlaces = format[1] === format[0], 8474 separatorIndex = firstTwoPlaces ? 2 : 1, 8475 separator = format.length < separatorIndex ? format[separatorIndex] : ':', 8476 firstChar = format[0], 8477 required = false; 8478 8479 for (var i = 0, len = lis.length; i < len; i++) { 8480 if (~format.indexOf(lis[i][1])) { 8481 required = true; 8482 } else if (required) { 8483 var hasNextValue = false; 8484 for (var j = i; j < len; j++) { 8485 if (lis[j][0] > 0) { 8486 hasNextValue = true; 8487 break; 8488 } 8489 } 8490 8491 if (!hasNextValue) { 8492 break; 8493 } 8494 8495 if (!firstTwoPlaces) { 8496 format = firstChar + format; 8497 } 8498 format = lis[i][1] + separator + format; 8499 if (firstTwoPlaces) { 8500 format = lis[i][1] + format; 8501 } 8502 firstChar = lis[i][1]; 8503 } 8504 } 8505 8506 options.timeFormat = format; 8507 } 8508 8509 function convertSMPTEtoSeconds(SMPTE) { 8510 8511 if (typeof SMPTE !== 'string') { 8512 throw new TypeError('Argument must be a string value'); 8513 } 8514 8515 SMPTE = SMPTE.replace(',', '.'); 8516 8517 var decimalLen = ~SMPTE.indexOf('.') ? SMPTE.split('.')[1].length : 0; 8518 8519 var secs = 0, 8520 multiplier = 1; 8521 8522 SMPTE = SMPTE.split(':').reverse(); 8523 8524 for (var i = 0, total = SMPTE.length; i < total; i++) { 8525 multiplier = 1; 8526 if (i > 0) { 8527 multiplier = Math.pow(60, i); 8528 } 8529 secs += Number(SMPTE[i]) * multiplier; 8530 } 8531 return Number(secs.toFixed(decimalLen)); 8532 } 8533 8534 _mejs2.default.Utils = _mejs2.default.Utils || {}; 8535 _mejs2.default.Utils.secondsToTimeCode = secondsToTimeCode; 8536 _mejs2.default.Utils.timeCodeToSeconds = timeCodeToSeconds; 8537 _mejs2.default.Utils.calculateTimeFormat = calculateTimeFormat; 8538 _mejs2.default.Utils.convertSMPTEtoSeconds = convertSMPTEtoSeconds; 8539 8540 },{"7":7}]},{},[29,6,5,15,23,20,19,21,22,24,16,18,17,9,10,11,12,13,14]);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Dec 21 08:20:01 2024 | Cross-referenced by PHPXref |