[ Index ] |
PHP Cross Reference of WordPress |
[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.16'; 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.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 trackText = $(trackText).filter('tt'); 2947 var container = trackText.firstChild, 2948 lines = container.querySelectorAll('p'), 2949 styleNode = trackText.getElementById('' + container.attr('style')), 2950 entries = []; 2951 2952 var styles = void 0; 2953 2954 if (styleNode.length) { 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.eq(_i16).attr('begin')) { 2975 _temp.start = (0, _time.convertSMPTEtoSeconds)(lines.eq(_i16).attr('begin')); 2976 } 2977 if (!_temp.start && lines.eq(_i16 - 1).attr('end')) { 2978 _temp.start = (0, _time.convertSMPTEtoSeconds)(lines.eq(_i16 - 1).attr('end')); 2979 } 2980 if (lines.eq(_i16).attr('end')) { 2981 _temp.stop = (0, _time.convertSMPTEtoSeconds)(lines.eq(_i16).attr('end')); 2982 } 2983 if (!_temp.stop && lines.eq(_i16 + 1).attr('begin')) { 2984 _temp.stop = (0, _time.convertSMPTEtoSeconds)(lines.eq(_i16 + 1).attr('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.eq(_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 positionVolumeHandle(media.volume); 3228 (0, _dom.removeClass)(mute, t.options.classPrefix + 'unmute'); 3229 (0, _dom.addClass)(mute, t.options.classPrefix + 'mute'); 3230 } 3231 }; 3232 3233 player.getElement(player.container).addEventListener('keydown', function (e) { 3234 var hasFocus = !!e.target.closest('.' + t.options.classPrefix + 'container'); 3235 if (!hasFocus && mode === 'vertical') { 3236 volumeSlider.style.display = 'none'; 3237 } 3238 }); 3239 3240 mute.addEventListener('mouseenter', function (e) { 3241 if (e.target === mute) { 3242 volumeSlider.style.display = 'block'; 3243 mouseIsOver = true; 3244 e.preventDefault(); 3245 e.stopPropagation(); 3246 } 3247 }); 3248 mute.addEventListener('focusin', function () { 3249 volumeSlider.style.display = 'block'; 3250 mouseIsOver = true; 3251 }); 3252 3253 mute.addEventListener('focusout', function (e) { 3254 if ((!e.relatedTarget || e.relatedTarget && !e.relatedTarget.matches('.' + t.options.classPrefix + 'volume-slider')) && mode === 'vertical') { 3255 volumeSlider.style.display = 'none'; 3256 } 3257 }); 3258 mute.addEventListener('mouseleave', function () { 3259 mouseIsOver = false; 3260 if (!mouseIsDown && mode === 'vertical') { 3261 volumeSlider.style.display = 'none'; 3262 } 3263 }); 3264 mute.addEventListener('focusout', function () { 3265 mouseIsOver = false; 3266 }); 3267 mute.addEventListener('keydown', function (e) { 3268 if (t.options.enableKeyboard && t.options.keyActions.length) { 3269 var keyCode = e.which || e.keyCode || 0, 3270 volume = media.volume; 3271 3272 switch (keyCode) { 3273 case 38: 3274 volume = Math.min(volume + 0.1, 1); 3275 break; 3276 case 40: 3277 volume = Math.max(0, volume - 0.1); 3278 break; 3279 default: 3280 return true; 3281 } 3282 3283 mouseIsDown = false; 3284 positionVolumeHandle(volume); 3285 media.setVolume(volume); 3286 3287 e.preventDefault(); 3288 e.stopPropagation(); 3289 } 3290 }); 3291 mute.querySelector('button').addEventListener('click', function () { 3292 media.setMuted(!media.muted); 3293 var event = (0, _general.createEvent)('volumechange', media); 3294 media.dispatchEvent(event); 3295 }); 3296 3297 volumeSlider.addEventListener('dragstart', function () { 3298 return false; 3299 }); 3300 3301 volumeSlider.addEventListener('mouseover', function () { 3302 mouseIsOver = true; 3303 }); 3304 volumeSlider.addEventListener('focusin', function () { 3305 volumeSlider.style.display = 'block'; 3306 mouseIsOver = true; 3307 }); 3308 volumeSlider.addEventListener('focusout', function () { 3309 mouseIsOver = false; 3310 if (!mouseIsDown && mode === 'vertical') { 3311 volumeSlider.style.display = 'none'; 3312 } 3313 }); 3314 volumeSlider.addEventListener('mousedown', function (e) { 3315 handleVolumeMove(e); 3316 t.globalBind('mousemove.vol', function (event) { 3317 var target = event.target; 3318 if (mouseIsDown && (target === volumeSlider || target.closest(mode === 'vertical' ? '.' + t.options.classPrefix + 'volume-slider' : '.' + t.options.classPrefix + 'horizontal-volume-slider'))) { 3319 handleVolumeMove(event); 3320 } 3321 }); 3322 t.globalBind('mouseup.vol', function () { 3323 mouseIsDown = false; 3324 if (!mouseIsOver && mode === 'vertical') { 3325 volumeSlider.style.display = 'none'; 3326 } 3327 }); 3328 mouseIsDown = true; 3329 e.preventDefault(); 3330 e.stopPropagation(); 3331 }); 3332 3333 media.addEventListener('volumechange', function (e) { 3334 if (!mouseIsDown) { 3335 toggleMute(); 3336 } 3337 updateVolumeSlider(e); 3338 }); 3339 3340 var rendered = false; 3341 media.addEventListener('rendererready', function () { 3342 if (!modified) { 3343 setTimeout(function () { 3344 rendered = true; 3345 if (player.options.startVolume === 0 || media.originalNode.muted) { 3346 media.setMuted(true); 3347 player.options.startVolume = 0; 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 media.setVolume(player.options.startVolume); 3362 t.setControlsSize(); 3363 } 3364 rendered = false; 3365 }, 250); 3366 }); 3367 3368 if (player.options.startVolume === 0 || media.originalNode.muted) { 3369 media.setMuted(true); 3370 player.options.startVolume = 0; 3371 toggleMute(); 3372 } 3373 3374 t.getElement(t.container).addEventListener('controlsresize', function () { 3375 toggleMute(); 3376 }); 3377 } 3378 }); 3379 3380 },{"16":16,"2":2,"25":25,"26":26,"27":27,"5":5}],15:[function(_dereq_,module,exports){ 3381 'use strict'; 3382 3383 Object.defineProperty(exports, "__esModule", { 3384 value: true 3385 }); 3386 var EN = exports.EN = { 3387 'mejs.plural-form': 1, 3388 3389 'mejs.download-file': 'Download File', 3390 3391 '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/', 3392 3393 'mejs.fullscreen': 'Fullscreen', 3394 3395 'mejs.play': 'Play', 3396 'mejs.pause': 'Pause', 3397 3398 'mejs.time-slider': 'Time Slider', 3399 'mejs.time-help-text': 'Use Left/Right Arrow keys to advance one second, Up/Down arrows to advance ten seconds.', 3400 'mejs.live-broadcast': 'Live Broadcast', 3401 3402 'mejs.volume-help-text': 'Use Up/Down Arrow keys to increase or decrease volume.', 3403 'mejs.unmute': 'Unmute', 3404 'mejs.mute': 'Mute', 3405 'mejs.volume-slider': 'Volume Slider', 3406 3407 'mejs.video-player': 'Video Player', 3408 'mejs.audio-player': 'Audio Player', 3409 3410 'mejs.captions-subtitles': 'Captions/Subtitles', 3411 'mejs.captions-chapters': 'Chapters', 3412 'mejs.none': 'None', 3413 'mejs.afrikaans': 'Afrikaans', 3414 'mejs.albanian': 'Albanian', 3415 'mejs.arabic': 'Arabic', 3416 'mejs.belarusian': 'Belarusian', 3417 'mejs.bulgarian': 'Bulgarian', 3418 'mejs.catalan': 'Catalan', 3419 'mejs.chinese': 'Chinese', 3420 'mejs.chinese-simplified': 'Chinese (Simplified)', 3421 'mejs.chinese-traditional': 'Chinese (Traditional)', 3422 'mejs.croatian': 'Croatian', 3423 'mejs.czech': 'Czech', 3424 'mejs.danish': 'Danish', 3425 'mejs.dutch': 'Dutch', 3426 'mejs.english': 'English', 3427 'mejs.estonian': 'Estonian', 3428 'mejs.filipino': 'Filipino', 3429 'mejs.finnish': 'Finnish', 3430 'mejs.french': 'French', 3431 'mejs.galician': 'Galician', 3432 'mejs.german': 'German', 3433 'mejs.greek': 'Greek', 3434 'mejs.haitian-creole': 'Haitian Creole', 3435 'mejs.hebrew': 'Hebrew', 3436 'mejs.hindi': 'Hindi', 3437 'mejs.hungarian': 'Hungarian', 3438 'mejs.icelandic': 'Icelandic', 3439 'mejs.indonesian': 'Indonesian', 3440 'mejs.irish': 'Irish', 3441 'mejs.italian': 'Italian', 3442 'mejs.japanese': 'Japanese', 3443 'mejs.korean': 'Korean', 3444 'mejs.latvian': 'Latvian', 3445 'mejs.lithuanian': 'Lithuanian', 3446 'mejs.macedonian': 'Macedonian', 3447 'mejs.malay': 'Malay', 3448 'mejs.maltese': 'Maltese', 3449 'mejs.norwegian': 'Norwegian', 3450 'mejs.persian': 'Persian', 3451 'mejs.polish': 'Polish', 3452 'mejs.portuguese': 'Portuguese', 3453 'mejs.romanian': 'Romanian', 3454 'mejs.russian': 'Russian', 3455 'mejs.serbian': 'Serbian', 3456 'mejs.slovak': 'Slovak', 3457 'mejs.slovenian': 'Slovenian', 3458 'mejs.spanish': 'Spanish', 3459 'mejs.swahili': 'Swahili', 3460 'mejs.swedish': 'Swedish', 3461 'mejs.tagalog': 'Tagalog', 3462 'mejs.thai': 'Thai', 3463 'mejs.turkish': 'Turkish', 3464 'mejs.ukrainian': 'Ukrainian', 3465 'mejs.vietnamese': 'Vietnamese', 3466 'mejs.welsh': 'Welsh', 3467 'mejs.yiddish': 'Yiddish' 3468 }; 3469 3470 },{}],16:[function(_dereq_,module,exports){ 3471 'use strict'; 3472 3473 Object.defineProperty(exports, "__esModule", { 3474 value: true 3475 }); 3476 exports.config = undefined; 3477 3478 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; }; 3479 3480 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; }; }(); 3481 3482 var _window = _dereq_(3); 3483 3484 var _window2 = _interopRequireDefault(_window); 3485 3486 var _document = _dereq_(2); 3487 3488 var _document2 = _interopRequireDefault(_document); 3489 3490 var _mejs = _dereq_(7); 3491 3492 var _mejs2 = _interopRequireDefault(_mejs); 3493 3494 var _mediaelement = _dereq_(6); 3495 3496 var _mediaelement2 = _interopRequireDefault(_mediaelement); 3497 3498 var _default = _dereq_(17); 3499 3500 var _default2 = _interopRequireDefault(_default); 3501 3502 var _i18n = _dereq_(5); 3503 3504 var _i18n2 = _interopRequireDefault(_i18n); 3505 3506 var _constants = _dereq_(25); 3507 3508 var _general = _dereq_(27); 3509 3510 var _time = _dereq_(30); 3511 3512 var _media = _dereq_(28); 3513 3514 var _dom = _dereq_(26); 3515 3516 var dom = _interopRequireWildcard(_dom); 3517 3518 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; } } 3519 3520 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3521 3522 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 3523 3524 _mejs2.default.mepIndex = 0; 3525 3526 _mejs2.default.players = {}; 3527 3528 var config = exports.config = { 3529 poster: '', 3530 3531 showPosterWhenEnded: false, 3532 3533 showPosterWhenPaused: false, 3534 3535 defaultVideoWidth: 480, 3536 3537 defaultVideoHeight: 270, 3538 3539 videoWidth: -1, 3540 3541 videoHeight: -1, 3542 3543 defaultAudioWidth: 400, 3544 3545 defaultAudioHeight: 40, 3546 3547 defaultSeekBackwardInterval: function defaultSeekBackwardInterval(media) { 3548 return media.getDuration() * 0.05; 3549 }, 3550 3551 defaultSeekForwardInterval: function defaultSeekForwardInterval(media) { 3552 return media.getDuration() * 0.05; 3553 }, 3554 3555 setDimensions: true, 3556 3557 audioWidth: -1, 3558 3559 audioHeight: -1, 3560 3561 loop: false, 3562 3563 autoRewind: true, 3564 3565 enableAutosize: true, 3566 3567 timeFormat: '', 3568 3569 alwaysShowHours: false, 3570 3571 showTimecodeFrameCount: false, 3572 3573 framesPerSecond: 25, 3574 3575 alwaysShowControls: false, 3576 3577 hideVideoControlsOnLoad: false, 3578 3579 hideVideoControlsOnPause: false, 3580 3581 clickToPlayPause: true, 3582 3583 controlsTimeoutDefault: 1500, 3584 3585 controlsTimeoutMouseEnter: 2500, 3586 3587 controlsTimeoutMouseLeave: 1000, 3588 3589 iPadUseNativeControls: false, 3590 3591 iPhoneUseNativeControls: false, 3592 3593 AndroidUseNativeControls: false, 3594 3595 features: ['playpause', 'current', 'progress', 'duration', 'tracks', 'volume', 'fullscreen'], 3596 3597 useDefaultControls: false, 3598 3599 isVideo: true, 3600 3601 stretching: 'auto', 3602 3603 classPrefix: 'mejs__', 3604 3605 enableKeyboard: true, 3606 3607 pauseOtherPlayers: true, 3608 3609 secondsDecimalLength: 0, 3610 3611 customError: null, 3612 3613 keyActions: [{ 3614 keys: [32, 179], 3615 action: function action(player) { 3616 3617 if (!_constants.IS_FIREFOX) { 3618 if (player.paused || player.ended) { 3619 player.play(); 3620 } else { 3621 player.pause(); 3622 } 3623 } 3624 } 3625 }] 3626 }; 3627 3628 _mejs2.default.MepDefaults = config; 3629 3630 var MediaElementPlayer = function () { 3631 function MediaElementPlayer(node, o) { 3632 _classCallCheck(this, MediaElementPlayer); 3633 3634 var t = this, 3635 element = typeof node === 'string' ? _document2.default.getElementById(node) : node; 3636 3637 if (!(t instanceof MediaElementPlayer)) { 3638 return new MediaElementPlayer(element, o); 3639 } 3640 3641 t.node = t.media = element; 3642 3643 if (!t.node) { 3644 return; 3645 } 3646 3647 if (t.media.player) { 3648 return t.media.player; 3649 } 3650 3651 t.hasFocus = false; 3652 3653 t.controlsAreVisible = true; 3654 3655 t.controlsEnabled = true; 3656 3657 t.controlsTimer = null; 3658 3659 t.currentMediaTime = 0; 3660 3661 t.proxy = null; 3662 3663 if (o === undefined) { 3664 var options = t.node.getAttribute('data-mejsoptions'); 3665 o = options ? JSON.parse(options) : {}; 3666 } 3667 3668 t.options = Object.assign({}, config, o); 3669 3670 if (t.options.loop && !t.media.getAttribute('loop')) { 3671 t.media.loop = true; 3672 t.node.loop = true; 3673 } else if (t.media.loop) { 3674 t.options.loop = true; 3675 } 3676 3677 if (!t.options.timeFormat) { 3678 t.options.timeFormat = 'mm:ss'; 3679 if (t.options.alwaysShowHours) { 3680 t.options.timeFormat = 'hh:mm:ss'; 3681 } 3682 if (t.options.showTimecodeFrameCount) { 3683 t.options.timeFormat += ':ff'; 3684 } 3685 } 3686 3687 (0, _time.calculateTimeFormat)(0, t.options, t.options.framesPerSecond || 25); 3688 3689 t.id = 'mep_' + _mejs2.default.mepIndex++; 3690 3691 _mejs2.default.players[t.id] = t; 3692 3693 t.init(); 3694 3695 return t; 3696 } 3697 3698 _createClass(MediaElementPlayer, [{ 3699 key: 'getElement', 3700 value: function getElement(element) { 3701 return element; 3702 } 3703 }, { 3704 key: 'init', 3705 value: function init() { 3706 var t = this, 3707 playerOptions = Object.assign({}, t.options, { 3708 success: function success(media, domNode) { 3709 t._meReady(media, domNode); 3710 }, 3711 error: function error(e) { 3712 t._handleError(e); 3713 } 3714 }), 3715 tagName = t.node.tagName.toLowerCase(); 3716 3717 t.isDynamic = tagName !== 'audio' && tagName !== 'video' && tagName !== 'iframe'; 3718 t.isVideo = t.isDynamic ? t.options.isVideo : tagName !== 'audio' && t.options.isVideo; 3719 t.mediaFiles = null; 3720 t.trackFiles = null; 3721 3722 if (_constants.IS_IPAD && t.options.iPadUseNativeControls || _constants.IS_IPHONE && t.options.iPhoneUseNativeControls) { 3723 t.node.setAttribute('controls', true); 3724 3725 if (_constants.IS_IPAD && t.node.getAttribute('autoplay')) { 3726 t.play(); 3727 } 3728 } else if ((t.isVideo || !t.isVideo && (t.options.features.length || t.options.useDefaultControls)) && !(_constants.IS_ANDROID && t.options.AndroidUseNativeControls)) { 3729 t.node.removeAttribute('controls'); 3730 var videoPlayerTitle = t.isVideo ? _i18n2.default.t('mejs.video-player') : _i18n2.default.t('mejs.audio-player'); 3731 3732 var offscreen = _document2.default.createElement('span'); 3733 offscreen.className = t.options.classPrefix + 'offscreen'; 3734 offscreen.innerText = videoPlayerTitle; 3735 t.media.parentNode.insertBefore(offscreen, t.media); 3736 3737 t.container = _document2.default.createElement('div'); 3738 t.getElement(t.container).id = t.id; 3739 t.getElement(t.container).className = t.options.classPrefix + 'container ' + t.options.classPrefix + 'container-keyboard-inactive ' + t.media.className; 3740 t.getElement(t.container).tabIndex = 0; 3741 t.getElement(t.container).setAttribute('role', 'application'); 3742 t.getElement(t.container).setAttribute('aria-label', videoPlayerTitle); 3743 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>'; 3744 t.getElement(t.container).addEventListener('focus', function (e) { 3745 if (!t.controlsAreVisible && !t.hasFocus && t.controlsEnabled) { 3746 t.showControls(true); 3747 3748 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', 3749 button = t.getElement(t.container).querySelector(btnSelector); 3750 3751 button.focus(); 3752 } 3753 }); 3754 t.node.parentNode.insertBefore(t.getElement(t.container), t.node); 3755 3756 if (!t.options.features.length && !t.options.useDefaultControls) { 3757 t.getElement(t.container).style.background = 'transparent'; 3758 t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'controls').style.display = 'none'; 3759 } 3760 3761 if (t.isVideo && t.options.stretching === 'fill' && !dom.hasClass(t.getElement(t.container).parentNode, t.options.classPrefix + 'fill-container')) { 3762 t.outerContainer = t.media.parentNode; 3763 3764 var wrapper = _document2.default.createElement('div'); 3765 wrapper.className = t.options.classPrefix + 'fill-container'; 3766 t.getElement(t.container).parentNode.insertBefore(wrapper, t.getElement(t.container)); 3767 wrapper.appendChild(t.getElement(t.container)); 3768 } 3769 3770 if (_constants.IS_ANDROID) { 3771 dom.addClass(t.getElement(t.container), t.options.classPrefix + 'android'); 3772 } 3773 if (_constants.IS_IOS) { 3774 dom.addClass(t.getElement(t.container), t.options.classPrefix + 'ios'); 3775 } 3776 if (_constants.IS_IPAD) { 3777 dom.addClass(t.getElement(t.container), t.options.classPrefix + 'ipad'); 3778 } 3779 if (_constants.IS_IPHONE) { 3780 dom.addClass(t.getElement(t.container), t.options.classPrefix + 'iphone'); 3781 } 3782 dom.addClass(t.getElement(t.container), t.isVideo ? t.options.classPrefix + 'video' : t.options.classPrefix + 'audio'); 3783 3784 t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'mediaelement').appendChild(t.node); 3785 3786 t.media.player = t; 3787 3788 t.controls = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'controls'); 3789 t.layers = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'layers'); 3790 3791 var tagType = t.isVideo ? 'video' : 'audio', 3792 capsTagName = tagType.substring(0, 1).toUpperCase() + tagType.substring(1); 3793 3794 if (t.options[tagType + 'Width'] > 0 || t.options[tagType + 'Width'].toString().indexOf('%') > -1) { 3795 t.width = t.options[tagType + 'Width']; 3796 } else if (t.node.style.width !== '' && t.node.style.width !== null) { 3797 t.width = t.node.style.width; 3798 } else if (t.node.getAttribute('width')) { 3799 t.width = t.node.getAttribute('width'); 3800 } else { 3801 t.width = t.options['default' + capsTagName + 'Width']; 3802 } 3803 3804 if (t.options[tagType + 'Height'] > 0 || t.options[tagType + 'Height'].toString().indexOf('%') > -1) { 3805 t.height = t.options[tagType + 'Height']; 3806 } else if (t.node.style.height !== '' && t.node.style.height !== null) { 3807 t.height = t.node.style.height; 3808 } else if (t.node.getAttribute('height')) { 3809 t.height = t.node.getAttribute('height'); 3810 } else { 3811 t.height = t.options['default' + capsTagName + 'Height']; 3812 } 3813 3814 t.initialAspectRatio = t.height >= t.width ? t.width / t.height : t.height / t.width; 3815 3816 t.setPlayerSize(t.width, t.height); 3817 3818 playerOptions.pluginWidth = t.width; 3819 playerOptions.pluginHeight = t.height; 3820 } else if (!t.isVideo && !t.options.features.length && !t.options.useDefaultControls) { 3821 t.node.style.display = 'none'; 3822 } 3823 3824 _mejs2.default.MepDefaults = playerOptions; 3825 3826 new _mediaelement2.default(t.media, playerOptions, t.mediaFiles); 3827 3828 if (t.getElement(t.container) !== undefined && t.options.features.length && t.controlsAreVisible && !t.options.hideVideoControlsOnLoad) { 3829 var event = (0, _general.createEvent)('controlsshown', t.getElement(t.container)); 3830 t.getElement(t.container).dispatchEvent(event); 3831 } 3832 } 3833 }, { 3834 key: 'showControls', 3835 value: function showControls(doAnimation) { 3836 var t = this; 3837 3838 doAnimation = doAnimation === undefined || doAnimation; 3839 3840 if (t.controlsAreVisible || !t.isVideo) { 3841 return; 3842 } 3843 3844 if (doAnimation) { 3845 (function () { 3846 dom.fadeIn(t.getElement(t.controls), 200, function () { 3847 dom.removeClass(t.getElement(t.controls), t.options.classPrefix + 'offscreen'); 3848 var event = (0, _general.createEvent)('controlsshown', t.getElement(t.container)); 3849 t.getElement(t.container).dispatchEvent(event); 3850 }); 3851 3852 var controls = t.getElement(t.container).querySelectorAll('.' + t.options.classPrefix + 'control'); 3853 3854 var _loop = function _loop(i, total) { 3855 dom.fadeIn(controls[i], 200, function () { 3856 dom.removeClass(controls[i], t.options.classPrefix + 'offscreen'); 3857 }); 3858 }; 3859 3860 for (var i = 0, total = controls.length; i < total; i++) { 3861 _loop(i, total); 3862 } 3863 })(); 3864 } else { 3865 dom.removeClass(t.getElement(t.controls), t.options.classPrefix + 'offscreen'); 3866 t.getElement(t.controls).style.display = ''; 3867 t.getElement(t.controls).style.opacity = 1; 3868 3869 var controls = t.getElement(t.container).querySelectorAll('.' + t.options.classPrefix + 'control'); 3870 for (var i = 0, total = controls.length; i < total; i++) { 3871 dom.removeClass(controls[i], t.options.classPrefix + 'offscreen'); 3872 controls[i].style.display = ''; 3873 } 3874 3875 var event = (0, _general.createEvent)('controlsshown', t.getElement(t.container)); 3876 t.getElement(t.container).dispatchEvent(event); 3877 } 3878 3879 t.controlsAreVisible = true; 3880 t.setControlsSize(); 3881 } 3882 }, { 3883 key: 'hideControls', 3884 value: function hideControls(doAnimation, forceHide) { 3885 var t = this; 3886 3887 doAnimation = doAnimation === undefined || doAnimation; 3888 3889 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)) { 3890 return; 3891 } 3892 3893 if (doAnimation) { 3894 (function () { 3895 dom.fadeOut(t.getElement(t.controls), 200, function () { 3896 dom.addClass(t.getElement(t.controls), t.options.classPrefix + 'offscreen'); 3897 t.getElement(t.controls).style.display = ''; 3898 var event = (0, _general.createEvent)('controlshidden', t.getElement(t.container)); 3899 t.getElement(t.container).dispatchEvent(event); 3900 }); 3901 3902 var controls = t.getElement(t.container).querySelectorAll('.' + t.options.classPrefix + 'control'); 3903 3904 var _loop2 = function _loop2(i, total) { 3905 dom.fadeOut(controls[i], 200, function () { 3906 dom.addClass(controls[i], t.options.classPrefix + 'offscreen'); 3907 controls[i].style.display = ''; 3908 }); 3909 }; 3910 3911 for (var i = 0, total = controls.length; i < total; i++) { 3912 _loop2(i, total); 3913 } 3914 })(); 3915 } else { 3916 dom.addClass(t.getElement(t.controls), t.options.classPrefix + 'offscreen'); 3917 t.getElement(t.controls).style.display = ''; 3918 t.getElement(t.controls).style.opacity = 0; 3919 3920 var controls = t.getElement(t.container).querySelectorAll('.' + t.options.classPrefix + 'control'); 3921 for (var i = 0, total = controls.length; i < total; i++) { 3922 dom.addClass(controls[i], t.options.classPrefix + 'offscreen'); 3923 controls[i].style.display = ''; 3924 } 3925 3926 var event = (0, _general.createEvent)('controlshidden', t.getElement(t.container)); 3927 t.getElement(t.container).dispatchEvent(event); 3928 } 3929 3930 t.controlsAreVisible = false; 3931 } 3932 }, { 3933 key: 'startControlsTimer', 3934 value: function startControlsTimer(timeout) { 3935 var t = this; 3936 3937 timeout = typeof timeout !== 'undefined' ? timeout : t.options.controlsTimeoutDefault; 3938 3939 t.killControlsTimer('start'); 3940 3941 t.controlsTimer = setTimeout(function () { 3942 t.hideControls(); 3943 t.killControlsTimer('hide'); 3944 }, timeout); 3945 } 3946 }, { 3947 key: 'killControlsTimer', 3948 value: function killControlsTimer() { 3949 var t = this; 3950 3951 if (t.controlsTimer !== null) { 3952 clearTimeout(t.controlsTimer); 3953 delete t.controlsTimer; 3954 t.controlsTimer = null; 3955 } 3956 } 3957 }, { 3958 key: 'disableControls', 3959 value: function disableControls() { 3960 var t = this; 3961 3962 t.killControlsTimer(); 3963 t.controlsEnabled = false; 3964 t.hideControls(false, true); 3965 } 3966 }, { 3967 key: 'enableControls', 3968 value: function enableControls() { 3969 var t = this; 3970 3971 t.controlsEnabled = true; 3972 t.showControls(false); 3973 } 3974 }, { 3975 key: '_setDefaultPlayer', 3976 value: function _setDefaultPlayer() { 3977 var t = this; 3978 if (t.proxy) { 3979 t.proxy.pause(); 3980 } 3981 t.proxy = new _default2.default(t); 3982 t.media.addEventListener('loadedmetadata', function () { 3983 if (t.getCurrentTime() > 0 && t.currentMediaTime > 0) { 3984 t.setCurrentTime(t.currentMediaTime); 3985 if (!_constants.IS_IOS && !_constants.IS_ANDROID) { 3986 t.play(); 3987 } 3988 } 3989 }); 3990 } 3991 }, { 3992 key: '_meReady', 3993 value: function _meReady(media, domNode) { 3994 var t = this, 3995 autoplayAttr = domNode.getAttribute('autoplay'), 3996 autoplay = !(autoplayAttr === undefined || autoplayAttr === null || autoplayAttr === 'false'), 3997 isNative = media.rendererName !== null && /(native|html5)/i.test(t.media.rendererName); 3998 3999 if (t.getElement(t.controls)) { 4000 t.enableControls(); 4001 } 4002 4003 if (t.getElement(t.container) && t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'overlay-play')) { 4004 t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'overlay-play').style.display = ''; 4005 } 4006 4007 if (t.created) { 4008 return; 4009 } 4010 4011 t.created = true; 4012 t.media = media; 4013 t.domNode = domNode; 4014 4015 if (!(_constants.IS_ANDROID && t.options.AndroidUseNativeControls) && !(_constants.IS_IPAD && t.options.iPadUseNativeControls) && !(_constants.IS_IPHONE && t.options.iPhoneUseNativeControls)) { 4016 if (!t.isVideo && !t.options.features.length && !t.options.useDefaultControls) { 4017 if (autoplay && isNative) { 4018 t.play(); 4019 } 4020 4021 if (t.options.success) { 4022 4023 if (typeof t.options.success === 'string') { 4024 _window2.default[t.options.success](t.media, t.domNode, t); 4025 } else { 4026 t.options.success(t.media, t.domNode, t); 4027 } 4028 } 4029 4030 return; 4031 } 4032 4033 t.featurePosition = {}; 4034 4035 t._setDefaultPlayer(); 4036 4037 t.buildposter(t, t.getElement(t.controls), t.getElement(t.layers), t.media); 4038 t.buildkeyboard(t, t.getElement(t.controls), t.getElement(t.layers), t.media); 4039 t.buildoverlays(t, t.getElement(t.controls), t.getElement(t.layers), t.media); 4040 4041 if (t.options.useDefaultControls) { 4042 var defaultControls = ['playpause', 'current', 'progress', 'duration', 'tracks', 'volume', 'fullscreen']; 4043 t.options.features = defaultControls.concat(t.options.features.filter(function (item) { 4044 return defaultControls.indexOf(item) === -1; 4045 })); 4046 } 4047 4048 t.buildfeatures(t, t.getElement(t.controls), t.getElement(t.layers), t.media); 4049 4050 var event = (0, _general.createEvent)('controlsready', t.getElement(t.container)); 4051 t.getElement(t.container).dispatchEvent(event); 4052 4053 t.setPlayerSize(t.width, t.height); 4054 t.setControlsSize(); 4055 4056 if (t.isVideo) { 4057 t.clickToPlayPauseCallback = function () { 4058 4059 if (t.options.clickToPlayPause) { 4060 var button = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'overlay-button'), 4061 pressed = button.getAttribute('aria-pressed'); 4062 4063 if (t.paused && pressed) { 4064 t.pause(); 4065 } else if (t.paused) { 4066 t.play(); 4067 } else { 4068 t.pause(); 4069 } 4070 4071 button.setAttribute('aria-pressed', !pressed); 4072 t.getElement(t.container).focus(); 4073 } 4074 }; 4075 4076 t.createIframeLayer(); 4077 4078 t.media.addEventListener('click', t.clickToPlayPauseCallback); 4079 4080 if ((_constants.IS_ANDROID || _constants.IS_IOS) && !t.options.alwaysShowControls) { 4081 t.node.addEventListener('touchstart', function () { 4082 if (t.controlsAreVisible) { 4083 t.hideControls(false); 4084 } else { 4085 if (t.controlsEnabled) { 4086 t.showControls(false); 4087 } 4088 } 4089 }, _constants.SUPPORT_PASSIVE_EVENT ? { passive: true } : false); 4090 } else { 4091 t.getElement(t.container).addEventListener('mouseenter', function () { 4092 if (t.controlsEnabled) { 4093 if (!t.options.alwaysShowControls) { 4094 t.killControlsTimer('enter'); 4095 t.showControls(); 4096 t.startControlsTimer(t.options.controlsTimeoutMouseEnter); 4097 } 4098 } 4099 }); 4100 t.getElement(t.container).addEventListener('mousemove', function () { 4101 if (t.controlsEnabled) { 4102 if (!t.controlsAreVisible) { 4103 t.showControls(); 4104 } 4105 if (!t.options.alwaysShowControls) { 4106 t.startControlsTimer(t.options.controlsTimeoutMouseEnter); 4107 } 4108 } 4109 }); 4110 t.getElement(t.container).addEventListener('mouseleave', function () { 4111 if (t.controlsEnabled) { 4112 if (!t.paused && !t.options.alwaysShowControls) { 4113 t.startControlsTimer(t.options.controlsTimeoutMouseLeave); 4114 } 4115 } 4116 }); 4117 } 4118 4119 if (t.options.hideVideoControlsOnLoad) { 4120 t.hideControls(false); 4121 } 4122 4123 if (t.options.enableAutosize) { 4124 t.media.addEventListener('loadedmetadata', function (e) { 4125 var target = e !== undefined ? e.detail.target || e.target : t.media; 4126 if (t.options.videoHeight <= 0 && !t.domNode.getAttribute('height') && !t.domNode.style.height && target !== null && !isNaN(target.videoHeight)) { 4127 t.setPlayerSize(target.videoWidth, target.videoHeight); 4128 t.setControlsSize(); 4129 t.media.setSize(target.videoWidth, target.videoHeight); 4130 } 4131 }); 4132 } 4133 } 4134 4135 t.media.addEventListener('play', function () { 4136 t.hasFocus = true; 4137 4138 for (var playerIndex in _mejs2.default.players) { 4139 if (_mejs2.default.players.hasOwnProperty(playerIndex)) { 4140 var p = _mejs2.default.players[playerIndex]; 4141 4142 if (p.id !== t.id && t.options.pauseOtherPlayers && !p.paused && !p.ended && p.options.ignorePauseOtherPlayersOption !== true) { 4143 p.pause(); 4144 p.hasFocus = false; 4145 } 4146 } 4147 } 4148 4149 if (!(_constants.IS_ANDROID || _constants.IS_IOS) && !t.options.alwaysShowControls && t.isVideo) { 4150 t.hideControls(); 4151 } 4152 }); 4153 4154 t.media.addEventListener('ended', function () { 4155 if (t.options.autoRewind) { 4156 try { 4157 t.setCurrentTime(0); 4158 4159 setTimeout(function () { 4160 var loadingElement = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'overlay-loading'); 4161 if (loadingElement && loadingElement.parentNode) { 4162 loadingElement.parentNode.style.display = 'none'; 4163 } 4164 }, 20); 4165 } catch (exp) { 4166 4167 } 4168 } 4169 4170 if (typeof t.media.renderer.stop === 'function') { 4171 t.media.renderer.stop(); 4172 } else { 4173 t.pause(); 4174 } 4175 4176 if (t.setProgressRail) { 4177 t.setProgressRail(); 4178 } 4179 if (t.setCurrentRail) { 4180 t.setCurrentRail(); 4181 } 4182 4183 if (t.options.loop) { 4184 t.play(); 4185 } else if (!t.options.alwaysShowControls && t.controlsEnabled) { 4186 t.showControls(); 4187 } 4188 }); 4189 4190 t.media.addEventListener('loadedmetadata', function () { 4191 4192 (0, _time.calculateTimeFormat)(t.getDuration(), t.options, t.options.framesPerSecond || 25); 4193 4194 if (t.updateDuration) { 4195 t.updateDuration(); 4196 } 4197 if (t.updateCurrent) { 4198 t.updateCurrent(); 4199 } 4200 4201 if (!t.isFullScreen) { 4202 t.setPlayerSize(t.width, t.height); 4203 t.setControlsSize(); 4204 } 4205 }); 4206 4207 var duration = null; 4208 t.media.addEventListener('timeupdate', function () { 4209 if (!isNaN(t.getDuration()) && duration !== t.getDuration()) { 4210 duration = t.getDuration(); 4211 (0, _time.calculateTimeFormat)(duration, t.options, t.options.framesPerSecond || 25); 4212 4213 if (t.updateDuration) { 4214 t.updateDuration(); 4215 } 4216 if (t.updateCurrent) { 4217 t.updateCurrent(); 4218 } 4219 4220 t.setControlsSize(); 4221 } 4222 }); 4223 4224 t.getElement(t.container).addEventListener('click', function (e) { 4225 dom.addClass(e.currentTarget, t.options.classPrefix + 'container-keyboard-inactive'); 4226 }); 4227 4228 t.getElement(t.container).addEventListener('focusin', function (e) { 4229 dom.removeClass(e.currentTarget, t.options.classPrefix + 'container-keyboard-inactive'); 4230 if (t.isVideo && !_constants.IS_ANDROID && !_constants.IS_IOS && t.controlsEnabled && !t.options.alwaysShowControls) { 4231 t.killControlsTimer('enter'); 4232 t.showControls(); 4233 t.startControlsTimer(t.options.controlsTimeoutMouseEnter); 4234 } 4235 }); 4236 4237 t.getElement(t.container).addEventListener('focusout', function (e) { 4238 setTimeout(function () { 4239 if (e.relatedTarget) { 4240 if (t.keyboardAction && !e.relatedTarget.closest('.' + t.options.classPrefix + 'container')) { 4241 t.keyboardAction = false; 4242 if (t.isVideo && !t.options.alwaysShowControls && !t.paused) { 4243 t.startControlsTimer(t.options.controlsTimeoutMouseLeave); 4244 } 4245 } 4246 } 4247 }, 0); 4248 }); 4249 4250 setTimeout(function () { 4251 t.setPlayerSize(t.width, t.height); 4252 t.setControlsSize(); 4253 }, 0); 4254 4255 t.globalResizeCallback = function () { 4256 if (!(t.isFullScreen || _constants.HAS_TRUE_NATIVE_FULLSCREEN && _document2.default.webkitIsFullScreen)) { 4257 t.setPlayerSize(t.width, t.height); 4258 } 4259 4260 t.setControlsSize(); 4261 }; 4262 4263 t.globalBind('resize', t.globalResizeCallback); 4264 } 4265 4266 if (autoplay && isNative) { 4267 t.play(); 4268 } 4269 4270 if (t.options.success) { 4271 if (typeof t.options.success === 'string') { 4272 _window2.default[t.options.success](t.media, t.domNode, t); 4273 } else { 4274 t.options.success(t.media, t.domNode, t); 4275 } 4276 } 4277 } 4278 }, { 4279 key: '_handleError', 4280 value: function _handleError(e, media, node) { 4281 var t = this, 4282 play = t.getElement(t.layers).querySelector('.' + t.options.classPrefix + 'overlay-play'); 4283 4284 if (play) { 4285 play.style.display = 'none'; 4286 } 4287 4288 if (t.options.error) { 4289 t.options.error(e, media, node); 4290 } 4291 4292 if (t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'cannotplay')) { 4293 t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'cannotplay').remove(); 4294 } 4295 4296 var errorContainer = _document2.default.createElement('div'); 4297 errorContainer.className = t.options.classPrefix + 'cannotplay'; 4298 errorContainer.style.width = '100%'; 4299 errorContainer.style.height = '100%'; 4300 4301 var errorContent = typeof t.options.customError === 'function' ? t.options.customError(t.media, t.media.originalNode) : t.options.customError, 4302 imgError = ''; 4303 4304 if (!errorContent) { 4305 var poster = t.media.originalNode.getAttribute('poster'); 4306 if (poster) { 4307 imgError = '<img src="' + poster + '" alt="' + _mejs2.default.i18n.t('mejs.download-file') + '">'; 4308 } 4309 4310 if (e.message) { 4311 errorContent = '<p>' + e.message + '</p>'; 4312 } 4313 4314 if (e.urls) { 4315 for (var i = 0, total = e.urls.length; i < total; i++) { 4316 var url = e.urls[i]; 4317 errorContent += '<a href="' + url.src + '" data-type="' + url.type + '"><span>' + _mejs2.default.i18n.t('mejs.download-file') + ': ' + url.src + '</span></a>'; 4318 } 4319 } 4320 } 4321 4322 if (errorContent && t.getElement(t.layers).querySelector('.' + t.options.classPrefix + 'overlay-error')) { 4323 errorContainer.innerHTML = errorContent; 4324 t.getElement(t.layers).querySelector('.' + t.options.classPrefix + 'overlay-error').innerHTML = '' + imgError + errorContainer.outerHTML; 4325 t.getElement(t.layers).querySelector('.' + t.options.classPrefix + 'overlay-error').parentNode.style.display = 'block'; 4326 } 4327 4328 if (t.controlsEnabled) { 4329 t.disableControls(); 4330 } 4331 } 4332 }, { 4333 key: 'setPlayerSize', 4334 value: function setPlayerSize(width, height) { 4335 var t = this; 4336 4337 if (!t.options.setDimensions) { 4338 return false; 4339 } 4340 4341 if (typeof width !== 'undefined') { 4342 t.width = width; 4343 } 4344 4345 if (typeof height !== 'undefined') { 4346 t.height = height; 4347 } 4348 4349 switch (t.options.stretching) { 4350 case 'fill': 4351 if (t.isVideo) { 4352 t.setFillMode(); 4353 } else { 4354 t.setDimensions(t.width, t.height); 4355 } 4356 break; 4357 case 'responsive': 4358 t.setResponsiveMode(); 4359 break; 4360 case 'none': 4361 t.setDimensions(t.width, t.height); 4362 break; 4363 4364 default: 4365 if (t.hasFluidMode() === true) { 4366 t.setResponsiveMode(); 4367 } else { 4368 t.setDimensions(t.width, t.height); 4369 } 4370 break; 4371 } 4372 } 4373 }, { 4374 key: 'hasFluidMode', 4375 value: function hasFluidMode() { 4376 var t = this; 4377 4378 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%'; 4379 } 4380 }, { 4381 key: 'setResponsiveMode', 4382 value: function setResponsiveMode() { 4383 var t = this, 4384 parent = function () { 4385 4386 var parentEl = void 0, 4387 el = t.getElement(t.container); 4388 4389 while (el) { 4390 try { 4391 if (_constants.IS_FIREFOX && el.tagName.toLowerCase() === 'html' && _window2.default.self !== _window2.default.top && _window2.default.frameElement !== null) { 4392 return _window2.default.frameElement; 4393 } else { 4394 parentEl = el.parentElement; 4395 } 4396 } catch (e) { 4397 parentEl = el.parentElement; 4398 } 4399 4400 if (parentEl && dom.visible(parentEl)) { 4401 return parentEl; 4402 } 4403 el = parentEl; 4404 } 4405 4406 return null; 4407 }(), 4408 parentStyles = parent ? getComputedStyle(parent, null) : getComputedStyle(_document2.default.body, null), 4409 nativeWidth = function () { 4410 if (t.isVideo) { 4411 if (t.node.videoWidth && t.node.videoWidth > 0) { 4412 return t.node.videoWidth; 4413 } else if (t.node.getAttribute('width')) { 4414 return t.node.getAttribute('width'); 4415 } else { 4416 return t.options.defaultVideoWidth; 4417 } 4418 } else { 4419 return t.options.defaultAudioWidth; 4420 } 4421 }(), 4422 nativeHeight = function () { 4423 if (t.isVideo) { 4424 if (t.node.videoHeight && t.node.videoHeight > 0) { 4425 return t.node.videoHeight; 4426 } else if (t.node.getAttribute('height')) { 4427 return t.node.getAttribute('height'); 4428 } else { 4429 return t.options.defaultVideoHeight; 4430 } 4431 } else { 4432 return t.options.defaultAudioHeight; 4433 } 4434 }(), 4435 aspectRatio = function () { 4436 var ratio = 1; 4437 if (!t.isVideo) { 4438 return ratio; 4439 } 4440 4441 if (t.node.videoWidth && t.node.videoWidth > 0 && t.node.videoHeight && t.node.videoHeight > 0) { 4442 ratio = t.height >= t.width ? t.node.videoWidth / t.node.videoHeight : t.node.videoHeight / t.node.videoWidth; 4443 } else { 4444 ratio = t.initialAspectRatio; 4445 } 4446 4447 if (isNaN(ratio) || ratio < 0.01 || ratio > 100) { 4448 ratio = 1; 4449 } 4450 4451 return ratio; 4452 }(), 4453 parentHeight = parseFloat(parentStyles.height); 4454 4455 var newHeight = void 0, 4456 parentWidth = parseFloat(parentStyles.width); 4457 4458 if (t.isVideo) { 4459 if (t.height === '100%') { 4460 newHeight = parseFloat(parentWidth * nativeHeight / nativeWidth, 10); 4461 } else { 4462 newHeight = t.height >= t.width ? parseFloat(parentWidth / aspectRatio, 10) : parseFloat(parentWidth * aspectRatio, 10); 4463 } 4464 } else { 4465 newHeight = nativeHeight; 4466 } 4467 4468 if (isNaN(newHeight)) { 4469 newHeight = parentHeight; 4470 } 4471 4472 if (t.getElement(t.container).parentNode.length > 0 && t.getElement(t.container).parentNode.tagName.toLowerCase() === 'body') { 4473 parentWidth = _window2.default.innerWidth || _document2.default.documentElement.clientWidth || _document2.default.body.clientWidth; 4474 newHeight = _window2.default.innerHeight || _document2.default.documentElement.clientHeight || _document2.default.body.clientHeight; 4475 } 4476 4477 if (newHeight && parentWidth) { 4478 t.getElement(t.container).style.width = parentWidth + 'px'; 4479 t.getElement(t.container).style.height = newHeight + 'px'; 4480 4481 t.node.style.width = '100%'; 4482 t.node.style.height = '100%'; 4483 4484 if (t.isVideo && t.media.setSize) { 4485 t.media.setSize(parentWidth, newHeight); 4486 } 4487 4488 var layerChildren = t.getElement(t.layers).children; 4489 for (var i = 0, total = layerChildren.length; i < total; i++) { 4490 layerChildren[i].style.width = '100%'; 4491 layerChildren[i].style.height = '100%'; 4492 } 4493 } 4494 } 4495 }, { 4496 key: 'setFillMode', 4497 value: function setFillMode() { 4498 var t = this; 4499 var isIframe = _window2.default.self !== _window2.default.top && _window2.default.frameElement !== null; 4500 var parent = function () { 4501 var parentEl = void 0, 4502 el = t.getElement(t.container); 4503 4504 while (el) { 4505 try { 4506 if (_constants.IS_FIREFOX && el.tagName.toLowerCase() === 'html' && _window2.default.self !== _window2.default.top && _window2.default.frameElement !== null) { 4507 return _window2.default.frameElement; 4508 } else { 4509 parentEl = el.parentElement; 4510 } 4511 } catch (e) { 4512 parentEl = el.parentElement; 4513 } 4514 4515 if (parentEl && dom.visible(parentEl)) { 4516 return parentEl; 4517 } 4518 el = parentEl; 4519 } 4520 4521 return null; 4522 }(); 4523 var parentStyles = parent ? getComputedStyle(parent, null) : getComputedStyle(_document2.default.body, null); 4524 4525 if (t.node.style.height !== 'none' && t.node.style.height !== t.height) { 4526 t.node.style.height = 'auto'; 4527 } 4528 if (t.node.style.maxWidth !== 'none' && t.node.style.maxWidth !== t.width) { 4529 t.node.style.maxWidth = 'none'; 4530 } 4531 4532 if (t.node.style.maxHeight !== 'none' && t.node.style.maxHeight !== t.height) { 4533 t.node.style.maxHeight = 'none'; 4534 } 4535 4536 if (t.node.currentStyle) { 4537 if (t.node.currentStyle.height === '100%') { 4538 t.node.currentStyle.height = 'auto'; 4539 } 4540 if (t.node.currentStyle.maxWidth === '100%') { 4541 t.node.currentStyle.maxWidth = 'none'; 4542 } 4543 if (t.node.currentStyle.maxHeight === '100%') { 4544 t.node.currentStyle.maxHeight = 'none'; 4545 } 4546 } 4547 4548 if (!isIframe && !parseFloat(parentStyles.width)) { 4549 parent.style.width = t.media.offsetWidth + 'px'; 4550 } 4551 4552 if (!isIframe && !parseFloat(parentStyles.height)) { 4553 parent.style.height = t.media.offsetHeight + 'px'; 4554 } 4555 4556 parentStyles = getComputedStyle(parent); 4557 4558 var parentWidth = parseFloat(parentStyles.width), 4559 parentHeight = parseFloat(parentStyles.height); 4560 4561 t.setDimensions('100%', '100%'); 4562 4563 var poster = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'poster>img'); 4564 if (poster) { 4565 poster.style.display = ''; 4566 } 4567 4568 var targetElement = t.getElement(t.container).querySelectorAll('object, embed, iframe, video'), 4569 initHeight = t.height, 4570 initWidth = t.width, 4571 scaleX1 = parentWidth, 4572 scaleY1 = initHeight * parentWidth / initWidth, 4573 scaleX2 = initWidth * parentHeight / initHeight, 4574 scaleY2 = parentHeight, 4575 bScaleOnWidth = scaleX2 > parentWidth === false, 4576 finalWidth = bScaleOnWidth ? Math.floor(scaleX1) : Math.floor(scaleX2), 4577 finalHeight = bScaleOnWidth ? Math.floor(scaleY1) : Math.floor(scaleY2), 4578 width = bScaleOnWidth ? parentWidth + 'px' : finalWidth + 'px', 4579 height = bScaleOnWidth ? finalHeight + 'px' : parentHeight + 'px'; 4580 4581 for (var i = 0, total = targetElement.length; i < total; i++) { 4582 targetElement[i].style.height = height; 4583 targetElement[i].style.width = width; 4584 if (t.media.setSize) { 4585 t.media.setSize(width, height); 4586 } 4587 4588 targetElement[i].style.marginLeft = Math.floor((parentWidth - finalWidth) / 2) + 'px'; 4589 targetElement[i].style.marginTop = 0; 4590 } 4591 } 4592 }, { 4593 key: 'setDimensions', 4594 value: function setDimensions(width, height) { 4595 var t = this; 4596 4597 width = (0, _general.isString)(width) && width.indexOf('%') > -1 ? width : parseFloat(width) + 'px'; 4598 height = (0, _general.isString)(height) && height.indexOf('%') > -1 ? height : parseFloat(height) + 'px'; 4599 4600 t.getElement(t.container).style.width = width; 4601 t.getElement(t.container).style.height = height; 4602 4603 var layers = t.getElement(t.layers).children; 4604 for (var i = 0, total = layers.length; i < total; i++) { 4605 layers[i].style.width = width; 4606 layers[i].style.height = height; 4607 } 4608 } 4609 }, { 4610 key: 'setControlsSize', 4611 value: function setControlsSize() { 4612 var t = this; 4613 4614 if (!dom.visible(t.getElement(t.container))) { 4615 return; 4616 } 4617 4618 if (t.rail && dom.visible(t.rail)) { 4619 var totalStyles = t.total ? getComputedStyle(t.total, null) : null, 4620 totalMargin = totalStyles ? parseFloat(totalStyles.marginLeft) + parseFloat(totalStyles.marginRight) : 0, 4621 railStyles = getComputedStyle(t.rail), 4622 railMargin = parseFloat(railStyles.marginLeft) + parseFloat(railStyles.marginRight); 4623 4624 var siblingsWidth = 0; 4625 4626 var siblings = dom.siblings(t.rail, function (el) { 4627 return el !== t.rail; 4628 }), 4629 total = siblings.length; 4630 for (var i = 0; i < total; i++) { 4631 siblingsWidth += siblings[i].offsetWidth; 4632 } 4633 4634 siblingsWidth += totalMargin + (totalMargin === 0 ? railMargin * 2 : railMargin) + 1; 4635 4636 t.getElement(t.container).style.minWidth = siblingsWidth + 'px'; 4637 4638 var event = (0, _general.createEvent)('controlsresize', t.getElement(t.container)); 4639 t.getElement(t.container).dispatchEvent(event); 4640 } else { 4641 var children = t.getElement(t.controls).children; 4642 var minWidth = 0; 4643 4644 for (var _i = 0, _total = children.length; _i < _total; _i++) { 4645 minWidth += children[_i].offsetWidth; 4646 } 4647 4648 t.getElement(t.container).style.minWidth = minWidth + 'px'; 4649 } 4650 } 4651 }, { 4652 key: 'addControlElement', 4653 value: function addControlElement(element, key) { 4654 4655 var t = this; 4656 4657 if (t.featurePosition[key] !== undefined) { 4658 var child = t.getElement(t.controls).children[t.featurePosition[key] - 1]; 4659 child.parentNode.insertBefore(element, child.nextSibling); 4660 } else { 4661 t.getElement(t.controls).appendChild(element); 4662 var children = t.getElement(t.controls).children; 4663 for (var i = 0, total = children.length; i < total; i++) { 4664 if (element === children[i]) { 4665 t.featurePosition[key] = i; 4666 break; 4667 } 4668 } 4669 } 4670 } 4671 }, { 4672 key: 'createIframeLayer', 4673 value: function createIframeLayer() { 4674 var t = this; 4675 4676 if (t.isVideo && t.media.rendererName !== null && t.media.rendererName.indexOf('iframe') > -1 && !_document2.default.getElementById(t.media.id + '-iframe-overlay')) { 4677 4678 var layer = _document2.default.createElement('div'), 4679 target = _document2.default.getElementById(t.media.id + '_' + t.media.rendererName); 4680 4681 layer.id = t.media.id + '-iframe-overlay'; 4682 layer.className = t.options.classPrefix + 'iframe-overlay'; 4683 layer.addEventListener('click', function (e) { 4684 if (t.options.clickToPlayPause) { 4685 if (t.paused) { 4686 t.play(); 4687 } else { 4688 t.pause(); 4689 } 4690 4691 e.preventDefault(); 4692 e.stopPropagation(); 4693 } 4694 }); 4695 4696 target.parentNode.insertBefore(layer, target); 4697 } 4698 } 4699 }, { 4700 key: 'resetSize', 4701 value: function resetSize() { 4702 var t = this; 4703 4704 setTimeout(function () { 4705 t.setPlayerSize(t.width, t.height); 4706 t.setControlsSize(); 4707 }, 50); 4708 } 4709 }, { 4710 key: 'setPoster', 4711 value: function setPoster(url) { 4712 var t = this; 4713 4714 if (t.getElement(t.container)) { 4715 var posterDiv = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'poster'); 4716 4717 if (!posterDiv) { 4718 posterDiv = _document2.default.createElement('div'); 4719 posterDiv.className = t.options.classPrefix + 'poster ' + t.options.classPrefix + 'layer'; 4720 t.getElement(t.layers).appendChild(posterDiv); 4721 } 4722 4723 var posterImg = posterDiv.querySelector('img'); 4724 4725 if (!posterImg && url) { 4726 posterImg = _document2.default.createElement('img'); 4727 posterImg.className = t.options.classPrefix + 'poster-img'; 4728 posterImg.width = '100%'; 4729 posterImg.height = '100%'; 4730 posterDiv.style.display = ''; 4731 posterDiv.appendChild(posterImg); 4732 } 4733 4734 if (url) { 4735 posterImg.setAttribute('src', url); 4736 posterDiv.style.backgroundImage = 'url("' + url + '")'; 4737 posterDiv.style.display = ''; 4738 } else if (posterImg) { 4739 posterDiv.style.backgroundImage = 'none'; 4740 posterDiv.style.display = 'none'; 4741 posterImg.remove(); 4742 } else { 4743 posterDiv.style.display = 'none'; 4744 } 4745 } else if (_constants.IS_IPAD && t.options.iPadUseNativeControls || _constants.IS_IPHONE && t.options.iPhoneUseNativeControls || _constants.IS_ANDROID && t.options.AndroidUseNativeControls) { 4746 t.media.originalNode.poster = url; 4747 } 4748 } 4749 }, { 4750 key: 'changeSkin', 4751 value: function changeSkin(className) { 4752 var t = this; 4753 4754 t.getElement(t.container).className = t.options.classPrefix + 'container ' + className; 4755 t.setPlayerSize(t.width, t.height); 4756 t.setControlsSize(); 4757 } 4758 }, { 4759 key: 'globalBind', 4760 value: function globalBind(events, callback) { 4761 var t = this, 4762 doc = t.node ? t.node.ownerDocument : _document2.default; 4763 4764 events = (0, _general.splitEvents)(events, t.id); 4765 if (events.d) { 4766 var eventList = events.d.split(' '); 4767 for (var i = 0, total = eventList.length; i < total; i++) { 4768 eventList[i].split('.').reduce(function (part, e) { 4769 doc.addEventListener(e, callback, false); 4770 return e; 4771 }, ''); 4772 } 4773 } 4774 if (events.w) { 4775 var _eventList = events.w.split(' '); 4776 for (var _i2 = 0, _total2 = _eventList.length; _i2 < _total2; _i2++) { 4777 _eventList[_i2].split('.').reduce(function (part, e) { 4778 _window2.default.addEventListener(e, callback, false); 4779 return e; 4780 }, ''); 4781 } 4782 } 4783 } 4784 }, { 4785 key: 'globalUnbind', 4786 value: function globalUnbind(events, callback) { 4787 var t = this, 4788 doc = t.node ? t.node.ownerDocument : _document2.default; 4789 4790 events = (0, _general.splitEvents)(events, t.id); 4791 if (events.d) { 4792 var eventList = events.d.split(' '); 4793 for (var i = 0, total = eventList.length; i < total; i++) { 4794 eventList[i].split('.').reduce(function (part, e) { 4795 doc.removeEventListener(e, callback, false); 4796 return e; 4797 }, ''); 4798 } 4799 } 4800 if (events.w) { 4801 var _eventList2 = events.w.split(' '); 4802 for (var _i3 = 0, _total3 = _eventList2.length; _i3 < _total3; _i3++) { 4803 _eventList2[_i3].split('.').reduce(function (part, e) { 4804 _window2.default.removeEventListener(e, callback, false); 4805 return e; 4806 }, ''); 4807 } 4808 } 4809 } 4810 }, { 4811 key: 'buildfeatures', 4812 value: function buildfeatures(player, controls, layers, media) { 4813 var t = this; 4814 4815 for (var i = 0, total = t.options.features.length; i < total; i++) { 4816 var feature = t.options.features[i]; 4817 if (t['build' + feature]) { 4818 try { 4819 t['build' + feature](player, controls, layers, media); 4820 } catch (e) { 4821 console.error('error building ' + feature, e); 4822 } 4823 } 4824 } 4825 } 4826 }, { 4827 key: 'buildposter', 4828 value: function buildposter(player, controls, layers, media) { 4829 var t = this, 4830 poster = _document2.default.createElement('div'); 4831 4832 poster.className = t.options.classPrefix + 'poster ' + t.options.classPrefix + 'layer'; 4833 layers.appendChild(poster); 4834 4835 var posterUrl = media.originalNode.getAttribute('poster'); 4836 4837 if (player.options.poster !== '') { 4838 if (posterUrl && _constants.IS_IOS) { 4839 media.originalNode.removeAttribute('poster'); 4840 } 4841 posterUrl = player.options.poster; 4842 } 4843 4844 if (posterUrl) { 4845 t.setPoster(posterUrl); 4846 } else if (t.media.renderer !== null && typeof t.media.renderer.getPosterUrl === 'function') { 4847 t.setPoster(t.media.renderer.getPosterUrl()); 4848 } else { 4849 poster.style.display = 'none'; 4850 } 4851 4852 media.addEventListener('play', function () { 4853 poster.style.display = 'none'; 4854 }); 4855 4856 media.addEventListener('playing', function () { 4857 poster.style.display = 'none'; 4858 }); 4859 4860 if (player.options.showPosterWhenEnded && player.options.autoRewind) { 4861 media.addEventListener('ended', function () { 4862 poster.style.display = ''; 4863 }); 4864 } 4865 4866 media.addEventListener('error', function () { 4867 poster.style.display = 'none'; 4868 }); 4869 4870 if (player.options.showPosterWhenPaused) { 4871 media.addEventListener('pause', function () { 4872 if (!player.ended) { 4873 poster.style.display = ''; 4874 } 4875 }); 4876 } 4877 } 4878 }, { 4879 key: 'buildoverlays', 4880 value: function buildoverlays(player, controls, layers, media) { 4881 4882 if (!player.isVideo) { 4883 return; 4884 } 4885 4886 var t = this, 4887 loading = _document2.default.createElement('div'), 4888 error = _document2.default.createElement('div'), 4889 bigPlay = _document2.default.createElement('div'); 4890 4891 loading.style.display = 'none'; 4892 loading.className = t.options.classPrefix + 'overlay ' + t.options.classPrefix + 'layer'; 4893 loading.innerHTML = '<div class="' + t.options.classPrefix + 'overlay-loading">' + ('<span class="' + t.options.classPrefix + 'overlay-loading-bg-img"></span>') + '</div>'; 4894 layers.appendChild(loading); 4895 4896 error.style.display = 'none'; 4897 error.className = t.options.classPrefix + 'overlay ' + t.options.classPrefix + 'layer'; 4898 error.innerHTML = '<div class="' + t.options.classPrefix + 'overlay-error"></div>'; 4899 layers.appendChild(error); 4900 4901 bigPlay.className = t.options.classPrefix + 'overlay ' + t.options.classPrefix + 'layer ' + t.options.classPrefix + 'overlay-play'; 4902 bigPlay.innerHTML = '<div class="' + t.options.classPrefix + 'overlay-button" role="button" tabindex="0" ' + ('aria-label="' + _i18n2.default.t('mejs.play') + '" aria-pressed="false"></div>'); 4903 bigPlay.addEventListener('click', function () { 4904 if (t.options.clickToPlayPause) { 4905 4906 var button = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'overlay-button'), 4907 pressed = button.getAttribute('aria-pressed'); 4908 4909 if (t.paused) { 4910 t.play(); 4911 } else { 4912 t.pause(); 4913 } 4914 4915 button.setAttribute('aria-pressed', !!pressed); 4916 t.getElement(t.container).focus(); 4917 } 4918 }); 4919 4920 bigPlay.addEventListener('keydown', function (e) { 4921 var keyPressed = e.keyCode || e.which || 0; 4922 4923 if (keyPressed === 13 || _constants.IS_FIREFOX && keyPressed === 32) { 4924 var event = (0, _general.createEvent)('click', bigPlay); 4925 bigPlay.dispatchEvent(event); 4926 return false; 4927 } 4928 }); 4929 4930 layers.appendChild(bigPlay); 4931 4932 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'))) { 4933 bigPlay.style.display = 'none'; 4934 } 4935 4936 var hasError = false; 4937 4938 media.addEventListener('play', function () { 4939 bigPlay.style.display = 'none'; 4940 loading.style.display = 'none'; 4941 error.style.display = 'none'; 4942 hasError = false; 4943 }); 4944 media.addEventListener('playing', function () { 4945 bigPlay.style.display = 'none'; 4946 loading.style.display = 'none'; 4947 error.style.display = 'none'; 4948 hasError = false; 4949 }); 4950 media.addEventListener('seeking', function () { 4951 bigPlay.style.display = 'none'; 4952 loading.style.display = ''; 4953 hasError = false; 4954 }); 4955 media.addEventListener('seeked', function () { 4956 bigPlay.style.display = t.paused && !_constants.IS_STOCK_ANDROID ? '' : 'none'; 4957 loading.style.display = 'none'; 4958 hasError = false; 4959 }); 4960 media.addEventListener('pause', function () { 4961 loading.style.display = 'none'; 4962 if (!_constants.IS_STOCK_ANDROID && !hasError) { 4963 bigPlay.style.display = ''; 4964 } 4965 hasError = false; 4966 }); 4967 media.addEventListener('waiting', function () { 4968 loading.style.display = ''; 4969 hasError = false; 4970 }); 4971 4972 media.addEventListener('loadeddata', function () { 4973 loading.style.display = ''; 4974 4975 if (_constants.IS_ANDROID) { 4976 media.canplayTimeout = setTimeout(function () { 4977 if (_document2.default.createEvent) { 4978 var evt = _document2.default.createEvent('HTMLEvents'); 4979 evt.initEvent('canplay', true, true); 4980 return media.dispatchEvent(evt); 4981 } 4982 }, 300); 4983 } 4984 hasError = false; 4985 }); 4986 media.addEventListener('canplay', function () { 4987 loading.style.display = 'none'; 4988 4989 clearTimeout(media.canplayTimeout); 4990 hasError = false; 4991 }); 4992 4993 media.addEventListener('error', function (e) { 4994 t._handleError(e, t.media, t.node); 4995 loading.style.display = 'none'; 4996 bigPlay.style.display = 'none'; 4997 hasError = true; 4998 }); 4999 5000 media.addEventListener('loadedmetadata', function () { 5001 if (!t.controlsEnabled) { 5002 t.enableControls(); 5003 } 5004 }); 5005 5006 media.addEventListener('keydown', function (e) { 5007 t.onkeydown(player, media, e); 5008 hasError = false; 5009 }); 5010 } 5011 }, { 5012 key: 'buildkeyboard', 5013 value: function buildkeyboard(player, controls, layers, media) { 5014 5015 var t = this; 5016 5017 t.getElement(t.container).addEventListener('keydown', function () { 5018 t.keyboardAction = true; 5019 }); 5020 5021 t.globalKeydownCallback = function (event) { 5022 var container = _document2.default.activeElement.closest('.' + t.options.classPrefix + 'container'), 5023 target = t.media.closest('.' + t.options.classPrefix + 'container'); 5024 t.hasFocus = !!(container && target && container.id === target.id); 5025 return t.onkeydown(player, media, event); 5026 }; 5027 5028 t.globalClickCallback = function (event) { 5029 t.hasFocus = !!event.target.closest('.' + t.options.classPrefix + 'container'); 5030 }; 5031 5032 t.globalBind('keydown', t.globalKeydownCallback); 5033 5034 t.globalBind('click', t.globalClickCallback); 5035 } 5036 }, { 5037 key: 'onkeydown', 5038 value: function onkeydown(player, media, e) { 5039 5040 if (player.hasFocus && player.options.enableKeyboard) { 5041 for (var i = 0, total = player.options.keyActions.length; i < total; i++) { 5042 var keyAction = player.options.keyActions[i]; 5043 5044 for (var j = 0, jl = keyAction.keys.length; j < jl; j++) { 5045 if (e.keyCode === keyAction.keys[j]) { 5046 keyAction.action(player, media, e.keyCode, e); 5047 e.preventDefault(); 5048 e.stopPropagation(); 5049 return; 5050 } 5051 } 5052 } 5053 } 5054 5055 return true; 5056 } 5057 }, { 5058 key: 'play', 5059 value: function play() { 5060 this.proxy.play(); 5061 } 5062 }, { 5063 key: 'pause', 5064 value: function pause() { 5065 this.proxy.pause(); 5066 } 5067 }, { 5068 key: 'load', 5069 value: function load() { 5070 this.proxy.load(); 5071 } 5072 }, { 5073 key: 'setCurrentTime', 5074 value: function setCurrentTime(time) { 5075 this.proxy.setCurrentTime(time); 5076 } 5077 }, { 5078 key: 'getCurrentTime', 5079 value: function getCurrentTime() { 5080 return this.proxy.currentTime; 5081 } 5082 }, { 5083 key: 'getDuration', 5084 value: function getDuration() { 5085 return this.proxy.duration; 5086 } 5087 }, { 5088 key: 'setVolume', 5089 value: function setVolume(volume) { 5090 this.proxy.volume = volume; 5091 } 5092 }, { 5093 key: 'getVolume', 5094 value: function getVolume() { 5095 return this.proxy.getVolume(); 5096 } 5097 }, { 5098 key: 'setMuted', 5099 value: function setMuted(value) { 5100 this.proxy.setMuted(value); 5101 } 5102 }, { 5103 key: 'setSrc', 5104 value: function setSrc(src) { 5105 if (!this.controlsEnabled) { 5106 this.enableControls(); 5107 } 5108 this.proxy.setSrc(src); 5109 } 5110 }, { 5111 key: 'getSrc', 5112 value: function getSrc() { 5113 return this.proxy.getSrc(); 5114 } 5115 }, { 5116 key: 'canPlayType', 5117 value: function canPlayType(type) { 5118 return this.proxy.canPlayType(type); 5119 } 5120 }, { 5121 key: 'remove', 5122 value: function remove() { 5123 var t = this, 5124 rendererName = t.media.rendererName, 5125 src = t.media.originalNode.src; 5126 5127 for (var featureIndex in t.options.features) { 5128 var feature = t.options.features[featureIndex]; 5129 if (t['clean' + feature]) { 5130 try { 5131 t['clean' + feature](t, t.getElement(t.layers), t.getElement(t.controls), t.media); 5132 } catch (e) { 5133 console.error('error cleaning ' + feature, e); 5134 } 5135 } 5136 } 5137 5138 var nativeWidth = t.node.getAttribute('width'), 5139 nativeHeight = t.node.getAttribute('height'); 5140 5141 if (nativeWidth) { 5142 if (nativeWidth.indexOf('%') === -1) { 5143 nativeWidth = nativeWidth + 'px'; 5144 } 5145 } else { 5146 nativeWidth = 'auto'; 5147 } 5148 5149 if (nativeHeight) { 5150 if (nativeHeight.indexOf('%') === -1) { 5151 nativeHeight = nativeHeight + 'px'; 5152 } 5153 } else { 5154 nativeHeight = 'auto'; 5155 } 5156 5157 t.node.style.width = nativeWidth; 5158 t.node.style.height = nativeHeight; 5159 5160 t.setPlayerSize(0, 0); 5161 5162 if (!t.isDynamic) { 5163 (function () { 5164 t.node.setAttribute('controls', true); 5165 t.node.setAttribute('id', t.node.getAttribute('id').replace('_' + rendererName, '').replace('_from_mejs', '')); 5166 var poster = t.getElement(t.container).querySelector('.' + t.options.classPrefix + 'poster>img'); 5167 if (poster) { 5168 t.node.setAttribute('poster', poster.src); 5169 } 5170 5171 delete t.node.autoplay; 5172 5173 t.node.setAttribute('src', ''); 5174 if (t.media.canPlayType((0, _media.getTypeFromFile)(src)) !== '') { 5175 t.node.setAttribute('src', src); 5176 } 5177 5178 if (rendererName && rendererName.indexOf('iframe') > -1) { 5179 var layer = _document2.default.getElementById(t.media.id + '-iframe-overlay'); 5180 layer.remove(); 5181 } 5182 5183 var node = t.node.cloneNode(); 5184 node.style.display = ''; 5185 t.getElement(t.container).parentNode.insertBefore(node, t.getElement(t.container)); 5186 t.node.remove(); 5187 5188 if (t.mediaFiles) { 5189 for (var i = 0, total = t.mediaFiles.length; i < total; i++) { 5190 var source = _document2.default.createElement('source'); 5191 source.setAttribute('src', t.mediaFiles[i].src); 5192 source.setAttribute('type', t.mediaFiles[i].type); 5193 node.appendChild(source); 5194 } 5195 } 5196 if (t.trackFiles) { 5197 var _loop3 = function _loop3(_i4, _total4) { 5198 var track = t.trackFiles[_i4]; 5199 var newTrack = _document2.default.createElement('track'); 5200 newTrack.kind = track.kind; 5201 newTrack.label = track.label; 5202 newTrack.srclang = track.srclang; 5203 newTrack.src = track.src; 5204 5205 node.appendChild(newTrack); 5206 newTrack.addEventListener('load', function () { 5207 this.mode = 'showing'; 5208 node.textTracks[_i4].mode = 'showing'; 5209 }); 5210 }; 5211 5212 for (var _i4 = 0, _total4 = t.trackFiles.length; _i4 < _total4; _i4++) { 5213 _loop3(_i4, _total4); 5214 } 5215 } 5216 5217 delete t.node; 5218 delete t.mediaFiles; 5219 delete t.trackFiles; 5220 })(); 5221 } else { 5222 t.getElement(t.container).parentNode.insertBefore(t.node, t.getElement(t.container)); 5223 } 5224 5225 if (t.media.renderer && typeof t.media.renderer.destroy === 'function') { 5226 t.media.renderer.destroy(); 5227 } 5228 5229 delete _mejs2.default.players[t.id]; 5230 5231 if (_typeof(t.getElement(t.container)) === 'object') { 5232 var offscreen = t.getElement(t.container).parentNode.querySelector('.' + t.options.classPrefix + 'offscreen'); 5233 offscreen.remove(); 5234 t.getElement(t.container).remove(); 5235 } 5236 t.globalUnbind('resize', t.globalResizeCallback); 5237 t.globalUnbind('keydown', t.globalKeydownCallback); 5238 t.globalUnbind('click', t.globalClickCallback); 5239 5240 delete t.media.player; 5241 } 5242 }, { 5243 key: 'paused', 5244 get: function get() { 5245 return this.proxy.paused; 5246 } 5247 }, { 5248 key: 'muted', 5249 get: function get() { 5250 return this.proxy.muted; 5251 }, 5252 set: function set(muted) { 5253 this.setMuted(muted); 5254 } 5255 }, { 5256 key: 'ended', 5257 get: function get() { 5258 return this.proxy.ended; 5259 } 5260 }, { 5261 key: 'readyState', 5262 get: function get() { 5263 return this.proxy.readyState; 5264 } 5265 }, { 5266 key: 'currentTime', 5267 set: function set(time) { 5268 this.setCurrentTime(time); 5269 }, 5270 get: function get() { 5271 return this.getCurrentTime(); 5272 } 5273 }, { 5274 key: 'duration', 5275 get: function get() { 5276 return this.getDuration(); 5277 } 5278 }, { 5279 key: 'volume', 5280 set: function set(volume) { 5281 this.setVolume(volume); 5282 }, 5283 get: function get() { 5284 return this.getVolume(); 5285 } 5286 }, { 5287 key: 'src', 5288 set: function set(src) { 5289 this.setSrc(src); 5290 }, 5291 get: function get() { 5292 return this.getSrc(); 5293 } 5294 }]); 5295 5296 return MediaElementPlayer; 5297 }(); 5298 5299 _window2.default.MediaElementPlayer = MediaElementPlayer; 5300 _mejs2.default.MediaElementPlayer = MediaElementPlayer; 5301 5302 exports.default = MediaElementPlayer; 5303 5304 },{"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){ 5305 'use strict'; 5306 5307 Object.defineProperty(exports, "__esModule", { 5308 value: true 5309 }); 5310 5311 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; }; }(); 5312 5313 var _window = _dereq_(3); 5314 5315 var _window2 = _interopRequireDefault(_window); 5316 5317 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5318 5319 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 5320 5321 var DefaultPlayer = function () { 5322 function DefaultPlayer(player) { 5323 _classCallCheck(this, DefaultPlayer); 5324 5325 this.media = player.media; 5326 this.isVideo = player.isVideo; 5327 this.classPrefix = player.options.classPrefix; 5328 this.createIframeLayer = function () { 5329 return player.createIframeLayer(); 5330 }; 5331 this.setPoster = function (url) { 5332 return player.setPoster(url); 5333 }; 5334 return this; 5335 } 5336 5337 _createClass(DefaultPlayer, [{ 5338 key: 'play', 5339 value: function play() { 5340 this.media.play(); 5341 } 5342 }, { 5343 key: 'pause', 5344 value: function pause() { 5345 this.media.pause(); 5346 } 5347 }, { 5348 key: 'load', 5349 value: function load() { 5350 var t = this; 5351 5352 if (!t.isLoaded) { 5353 t.media.load(); 5354 } 5355 5356 t.isLoaded = true; 5357 } 5358 }, { 5359 key: 'setCurrentTime', 5360 value: function setCurrentTime(time) { 5361 this.media.setCurrentTime(time); 5362 } 5363 }, { 5364 key: 'getCurrentTime', 5365 value: function getCurrentTime() { 5366 return this.media.currentTime; 5367 } 5368 }, { 5369 key: 'getDuration', 5370 value: function getDuration() { 5371 var duration = this.media.getDuration(); 5372 if (duration === Infinity && this.media.seekable && this.media.seekable.length) { 5373 duration = this.media.seekable.end(0); 5374 } 5375 return duration; 5376 } 5377 }, { 5378 key: 'setVolume', 5379 value: function setVolume(volume) { 5380 this.media.setVolume(volume); 5381 } 5382 }, { 5383 key: 'getVolume', 5384 value: function getVolume() { 5385 return this.media.getVolume(); 5386 } 5387 }, { 5388 key: 'setMuted', 5389 value: function setMuted(value) { 5390 this.media.setMuted(value); 5391 } 5392 }, { 5393 key: 'setSrc', 5394 value: function setSrc(src) { 5395 var t = this, 5396 layer = document.getElementById(t.media.id + '-iframe-overlay'); 5397 5398 if (layer) { 5399 layer.remove(); 5400 } 5401 5402 t.media.setSrc(src); 5403 t.createIframeLayer(); 5404 if (t.media.renderer !== null && typeof t.media.renderer.getPosterUrl === 'function') { 5405 t.setPoster(t.media.renderer.getPosterUrl()); 5406 } 5407 } 5408 }, { 5409 key: 'getSrc', 5410 value: function getSrc() { 5411 return this.media.getSrc(); 5412 } 5413 }, { 5414 key: 'canPlayType', 5415 value: function canPlayType(type) { 5416 return this.media.canPlayType(type); 5417 } 5418 }, { 5419 key: 'paused', 5420 get: function get() { 5421 return this.media.paused; 5422 } 5423 }, { 5424 key: 'muted', 5425 set: function set(muted) { 5426 this.setMuted(muted); 5427 }, 5428 get: function get() { 5429 return this.media.muted; 5430 } 5431 }, { 5432 key: 'ended', 5433 get: function get() { 5434 return this.media.ended; 5435 } 5436 }, { 5437 key: 'readyState', 5438 get: function get() { 5439 return this.media.readyState; 5440 } 5441 }, { 5442 key: 'currentTime', 5443 set: function set(time) { 5444 this.setCurrentTime(time); 5445 }, 5446 get: function get() { 5447 return this.getCurrentTime(); 5448 } 5449 }, { 5450 key: 'duration', 5451 get: function get() { 5452 return this.getDuration(); 5453 } 5454 }, { 5455 key: 'remainingTime', 5456 get: function get() { 5457 return this.getDuration() - this.currentTime(); 5458 } 5459 }, { 5460 key: 'volume', 5461 set: function set(volume) { 5462 this.setVolume(volume); 5463 }, 5464 get: function get() { 5465 return this.getVolume(); 5466 } 5467 }, { 5468 key: 'src', 5469 set: function set(src) { 5470 this.setSrc(src); 5471 }, 5472 get: function get() { 5473 return this.getSrc(); 5474 } 5475 }]); 5476 5477 return DefaultPlayer; 5478 }(); 5479 5480 exports.default = DefaultPlayer; 5481 5482 5483 _window2.default.DefaultPlayer = DefaultPlayer; 5484 5485 },{"3":3}],18:[function(_dereq_,module,exports){ 5486 'use strict'; 5487 5488 var _window = _dereq_(3); 5489 5490 var _window2 = _interopRequireDefault(_window); 5491 5492 var _mejs = _dereq_(7); 5493 5494 var _mejs2 = _interopRequireDefault(_mejs); 5495 5496 var _player = _dereq_(16); 5497 5498 var _player2 = _interopRequireDefault(_player); 5499 5500 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5501 5502 if (typeof jQuery !== 'undefined') { 5503 _mejs2.default.$ = jQuery; 5504 } else if (typeof Zepto !== 'undefined') { 5505 _mejs2.default.$ = Zepto; 5506 } else if (typeof ender !== 'undefined') { 5507 _mejs2.default.$ = ender; 5508 } 5509 5510 (function ($) { 5511 if (typeof $ !== 'undefined') { 5512 $.fn.mediaelementplayer = function (options) { 5513 if (options === false) { 5514 this.each(function () { 5515 var player = $(this).data('mediaelementplayer'); 5516 if (player) { 5517 player.remove(); 5518 } 5519 $(this).removeData('mediaelementplayer'); 5520 }); 5521 } else { 5522 this.each(function () { 5523 $(this).data('mediaelementplayer', new _player2.default(this, options)); 5524 }); 5525 } 5526 return this; 5527 }; 5528 5529 $(document).ready(function () { 5530 $('.' + _mejs2.default.MepDefaults.classPrefix + 'player').mediaelementplayer(); 5531 }); 5532 } 5533 })(_mejs2.default.$); 5534 5535 },{"16":16,"3":3,"7":7}],19:[function(_dereq_,module,exports){ 5536 'use strict'; 5537 5538 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; }; 5539 5540 var _window = _dereq_(3); 5541 5542 var _window2 = _interopRequireDefault(_window); 5543 5544 var _mejs = _dereq_(7); 5545 5546 var _mejs2 = _interopRequireDefault(_mejs); 5547 5548 var _renderer = _dereq_(8); 5549 5550 var _general = _dereq_(27); 5551 5552 var _media = _dereq_(28); 5553 5554 var _constants = _dereq_(25); 5555 5556 var _dom = _dereq_(26); 5557 5558 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5559 5560 var NativeDash = { 5561 5562 promise: null, 5563 5564 load: function load(settings) { 5565 if (typeof dashjs !== 'undefined') { 5566 NativeDash.promise = new Promise(function (resolve) { 5567 resolve(); 5568 }).then(function () { 5569 NativeDash._createPlayer(settings); 5570 }); 5571 } else { 5572 settings.options.path = typeof settings.options.path === 'string' ? settings.options.path : 'https://cdn.dashjs.org/latest/dash.all.min.js'; 5573 5574 NativeDash.promise = NativeDash.promise || (0, _dom.loadScript)(settings.options.path); 5575 NativeDash.promise.then(function () { 5576 NativeDash._createPlayer(settings); 5577 }); 5578 } 5579 5580 return NativeDash.promise; 5581 }, 5582 5583 _createPlayer: function _createPlayer(settings) { 5584 var player = dashjs.MediaPlayer().create(); 5585 _window2.default['__ready__' + settings.id](player); 5586 return player; 5587 } 5588 }; 5589 5590 var DashNativeRenderer = { 5591 name: 'native_dash', 5592 options: { 5593 prefix: 'native_dash', 5594 dash: { 5595 path: 'https://cdn.dashjs.org/latest/dash.all.min.js', 5596 debug: false, 5597 drm: {}, 5598 5599 robustnessLevel: '' 5600 } 5601 }, 5602 5603 canPlayType: function canPlayType(type) { 5604 return _constants.HAS_MSE && ['application/dash+xml'].indexOf(type.toLowerCase()) > -1; 5605 }, 5606 5607 create: function create(mediaElement, options, mediaFiles) { 5608 5609 var originalNode = mediaElement.originalNode, 5610 id = mediaElement.id + '_' + options.prefix, 5611 autoplay = originalNode.autoplay, 5612 children = originalNode.children; 5613 5614 var node = null, 5615 dashPlayer = null; 5616 5617 originalNode.removeAttribute('type'); 5618 for (var i = 0, total = children.length; i < total; i++) { 5619 children[i].removeAttribute('type'); 5620 } 5621 5622 node = originalNode.cloneNode(true); 5623 options = Object.assign(options, mediaElement.options); 5624 5625 var props = _mejs2.default.html5media.properties, 5626 events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']).filter(function (e) { 5627 return e !== 'error'; 5628 }), 5629 attachNativeEvents = function attachNativeEvents(e) { 5630 var event = (0, _general.createEvent)(e.type, mediaElement); 5631 mediaElement.dispatchEvent(event); 5632 }, 5633 assignGettersSetters = function assignGettersSetters(propName) { 5634 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 5635 5636 node['get' + capName] = function () { 5637 return dashPlayer !== null ? node[propName] : null; 5638 }; 5639 5640 node['set' + capName] = function (value) { 5641 if (_mejs2.default.html5media.readOnlyProperties.indexOf(propName) === -1) { 5642 if (propName === 'src') { 5643 var source = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src ? value.src : value; 5644 node[propName] = source; 5645 if (dashPlayer !== null) { 5646 dashPlayer.reset(); 5647 for (var _i = 0, _total = events.length; _i < _total; _i++) { 5648 node.removeEventListener(events[_i], attachNativeEvents); 5649 } 5650 dashPlayer = NativeDash._createPlayer({ 5651 options: options.dash, 5652 id: id 5653 }); 5654 5655 if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && _typeof(value.drm) === 'object') { 5656 dashPlayer.setProtectionData(value.drm); 5657 if ((0, _general.isString)(options.dash.robustnessLevel) && options.dash.robustnessLevel) { 5658 dashPlayer.getProtectionController().setRobustnessLevel(options.dash.robustnessLevel); 5659 } 5660 } 5661 dashPlayer.attachSource(source); 5662 if (autoplay) { 5663 dashPlayer.play(); 5664 } 5665 } 5666 } else { 5667 node[propName] = value; 5668 } 5669 } 5670 }; 5671 }; 5672 5673 for (var _i2 = 0, _total2 = props.length; _i2 < _total2; _i2++) { 5674 assignGettersSetters(props[_i2]); 5675 } 5676 5677 _window2.default['__ready__' + id] = function (_dashPlayer) { 5678 mediaElement.dashPlayer = dashPlayer = _dashPlayer; 5679 5680 var dashEvents = dashjs.MediaPlayer.events, 5681 assignEvents = function assignEvents(eventName) { 5682 if (eventName === 'loadedmetadata') { 5683 dashPlayer.initialize(); 5684 dashPlayer.attachView(node); 5685 dashPlayer.setAutoPlay(false); 5686 5687 if (_typeof(options.dash.drm) === 'object' && !_mejs2.default.Utils.isObjectEmpty(options.dash.drm)) { 5688 dashPlayer.setProtectionData(options.dash.drm); 5689 if ((0, _general.isString)(options.dash.robustnessLevel) && options.dash.robustnessLevel) { 5690 dashPlayer.getProtectionController().setRobustnessLevel(options.dash.robustnessLevel); 5691 } 5692 } 5693 dashPlayer.attachSource(node.getSrc()); 5694 } 5695 5696 node.addEventListener(eventName, attachNativeEvents); 5697 }; 5698 5699 for (var _i3 = 0, _total3 = events.length; _i3 < _total3; _i3++) { 5700 assignEvents(events[_i3]); 5701 } 5702 5703 var assignMdashEvents = function assignMdashEvents(e) { 5704 if (e.type.toLowerCase() === 'error') { 5705 mediaElement.generateError(e.message, node.src); 5706 console.error(e); 5707 } else { 5708 var _event = (0, _general.createEvent)(e.type, mediaElement); 5709 _event.data = e; 5710 mediaElement.dispatchEvent(_event); 5711 } 5712 }; 5713 5714 for (var eventType in dashEvents) { 5715 if (dashEvents.hasOwnProperty(eventType)) { 5716 dashPlayer.on(dashEvents[eventType], function (e) { 5717 return assignMdashEvents(e); 5718 }); 5719 } 5720 } 5721 }; 5722 5723 if (mediaFiles && mediaFiles.length > 0) { 5724 for (var _i4 = 0, _total4 = mediaFiles.length; _i4 < _total4; _i4++) { 5725 if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[_i4].type)) { 5726 node.setAttribute('src', mediaFiles[_i4].src); 5727 if (typeof mediaFiles[_i4].drm !== 'undefined') { 5728 options.dash.drm = mediaFiles[_i4].drm; 5729 } 5730 break; 5731 } 5732 } 5733 } 5734 5735 node.setAttribute('id', id); 5736 5737 originalNode.parentNode.insertBefore(node, originalNode); 5738 originalNode.autoplay = false; 5739 originalNode.style.display = 'none'; 5740 5741 node.setSize = function (width, height) { 5742 node.style.width = width + 'px'; 5743 node.style.height = height + 'px'; 5744 return node; 5745 }; 5746 5747 node.hide = function () { 5748 node.pause(); 5749 node.style.display = 'none'; 5750 return node; 5751 }; 5752 5753 node.show = function () { 5754 node.style.display = ''; 5755 return node; 5756 }; 5757 5758 node.destroy = function () { 5759 if (dashPlayer !== null) { 5760 dashPlayer.reset(); 5761 } 5762 }; 5763 5764 var event = (0, _general.createEvent)('rendererready', node); 5765 mediaElement.dispatchEvent(event); 5766 5767 mediaElement.promises.push(NativeDash.load({ 5768 options: options.dash, 5769 id: id 5770 })); 5771 5772 return node; 5773 } 5774 }; 5775 5776 _media.typeChecks.push(function (url) { 5777 return ~url.toLowerCase().indexOf('.mpd') ? 'application/dash+xml' : null; 5778 }); 5779 5780 _renderer.renderer.add(DashNativeRenderer); 5781 5782 },{"25":25,"26":26,"27":27,"28":28,"3":3,"7":7,"8":8}],20:[function(_dereq_,module,exports){ 5783 'use strict'; 5784 5785 Object.defineProperty(exports, "__esModule", { 5786 value: true 5787 }); 5788 exports.PluginDetector = undefined; 5789 5790 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; }; 5791 5792 var _window = _dereq_(3); 5793 5794 var _window2 = _interopRequireDefault(_window); 5795 5796 var _document = _dereq_(2); 5797 5798 var _document2 = _interopRequireDefault(_document); 5799 5800 var _mejs = _dereq_(7); 5801 5802 var _mejs2 = _interopRequireDefault(_mejs); 5803 5804 var _i18n = _dereq_(5); 5805 5806 var _i18n2 = _interopRequireDefault(_i18n); 5807 5808 var _renderer = _dereq_(8); 5809 5810 var _general = _dereq_(27); 5811 5812 var _constants = _dereq_(25); 5813 5814 var _media = _dereq_(28); 5815 5816 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 5817 5818 var PluginDetector = exports.PluginDetector = { 5819 plugins: [], 5820 5821 hasPluginVersion: function hasPluginVersion(plugin, v) { 5822 var pv = PluginDetector.plugins[plugin]; 5823 v[1] = v[1] || 0; 5824 v[2] = v[2] || 0; 5825 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]; 5826 }, 5827 5828 addPlugin: function addPlugin(p, pluginName, mimeType, activeX, axDetect) { 5829 PluginDetector.plugins[p] = PluginDetector.detectPlugin(pluginName, mimeType, activeX, axDetect); 5830 }, 5831 5832 detectPlugin: function detectPlugin(pluginName, mimeType, activeX, axDetect) { 5833 5834 var version = [0, 0, 0], 5835 description = void 0, 5836 ax = void 0; 5837 5838 if (_constants.NAV.plugins !== null && _constants.NAV.plugins !== undefined && _typeof(_constants.NAV.plugins[pluginName]) === 'object') { 5839 description = _constants.NAV.plugins[pluginName].description; 5840 if (description && !(typeof _constants.NAV.mimeTypes !== 'undefined' && _constants.NAV.mimeTypes[mimeType] && !_constants.NAV.mimeTypes[mimeType].enabledPlugin)) { 5841 version = description.replace(pluginName, '').replace(/^\s+/, '').replace(/\sr/gi, '.').split('.'); 5842 for (var i = 0, total = version.length; i < total; i++) { 5843 version[i] = parseInt(version[i].match(/\d+/), 10); 5844 } 5845 } 5846 } else if (_window2.default.ActiveXObject !== undefined) { 5847 try { 5848 ax = new ActiveXObject(activeX); 5849 if (ax) { 5850 version = axDetect(ax); 5851 } 5852 } catch (e) { 5853 5854 } 5855 } 5856 return version; 5857 } 5858 }; 5859 5860 PluginDetector.addPlugin('flash', 'Shockwave Flash', 'application/x-shockwave-flash', 'ShockwaveFlash.ShockwaveFlash', function (ax) { 5861 var version = [], 5862 d = ax.GetVariable("$version"); 5863 5864 if (d) { 5865 d = d.split(" ")[1].split(","); 5866 version = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; 5867 } 5868 return version; 5869 }); 5870 5871 var FlashMediaElementRenderer = { 5872 create: function create(mediaElement, options, mediaFiles) { 5873 5874 var flash = {}; 5875 var isActive = false; 5876 5877 flash.options = options; 5878 flash.id = mediaElement.id + '_' + flash.options.prefix; 5879 flash.mediaElement = mediaElement; 5880 flash.flashState = {}; 5881 flash.flashApi = null; 5882 flash.flashApiStack = []; 5883 5884 var props = _mejs2.default.html5media.properties, 5885 assignGettersSetters = function assignGettersSetters(propName) { 5886 flash.flashState[propName] = null; 5887 5888 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 5889 5890 flash['get' + capName] = function () { 5891 if (flash.flashApi !== null) { 5892 if (typeof flash.flashApi['get_' + propName] === 'function') { 5893 var value = flash.flashApi['get_' + propName](); 5894 5895 if (propName === 'buffered') { 5896 return { 5897 start: function start() { 5898 return 0; 5899 }, 5900 end: function end() { 5901 return value; 5902 }, 5903 length: 1 5904 }; 5905 } 5906 return value; 5907 } else { 5908 return null; 5909 } 5910 } else { 5911 return null; 5912 } 5913 }; 5914 5915 flash['set' + capName] = function (value) { 5916 if (propName === 'src') { 5917 value = (0, _media.absolutizeUrl)(value); 5918 } 5919 5920 if (flash.flashApi !== null && flash.flashApi['set_' + propName] !== undefined) { 5921 try { 5922 flash.flashApi['set_' + propName](value); 5923 } catch (e) { 5924 5925 } 5926 } else { 5927 flash.flashApiStack.push({ 5928 type: 'set', 5929 propName: propName, 5930 value: value 5931 }); 5932 } 5933 }; 5934 }; 5935 5936 for (var i = 0, total = props.length; i < total; i++) { 5937 assignGettersSetters(props[i]); 5938 } 5939 5940 var methods = _mejs2.default.html5media.methods, 5941 assignMethods = function assignMethods(methodName) { 5942 flash[methodName] = function () { 5943 if (isActive) { 5944 if (flash.flashApi !== null) { 5945 if (flash.flashApi['fire_' + methodName]) { 5946 try { 5947 flash.flashApi['fire_' + methodName](); 5948 } catch (e) { 5949 5950 } 5951 } else { 5952 5953 } 5954 } else { 5955 flash.flashApiStack.push({ 5956 type: 'call', 5957 methodName: methodName 5958 }); 5959 } 5960 } 5961 }; 5962 }; 5963 methods.push('stop'); 5964 for (var _i = 0, _total = methods.length; _i < _total; _i++) { 5965 assignMethods(methods[_i]); 5966 } 5967 5968 var initEvents = ['rendererready']; 5969 5970 for (var _i2 = 0, _total2 = initEvents.length; _i2 < _total2; _i2++) { 5971 var event = (0, _general.createEvent)(initEvents[_i2], flash); 5972 mediaElement.dispatchEvent(event); 5973 } 5974 5975 _window2.default['__ready__' + flash.id] = function () { 5976 5977 flash.flashReady = true; 5978 flash.flashApi = _document2.default.getElementById('__' + flash.id); 5979 5980 if (flash.flashApiStack.length) { 5981 for (var _i3 = 0, _total3 = flash.flashApiStack.length; _i3 < _total3; _i3++) { 5982 var stackItem = flash.flashApiStack[_i3]; 5983 5984 if (stackItem.type === 'set') { 5985 var propName = stackItem.propName, 5986 capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 5987 5988 flash['set' + capName](stackItem.value); 5989 } else if (stackItem.type === 'call') { 5990 flash[stackItem.methodName](); 5991 } 5992 } 5993 } 5994 }; 5995 5996 _window2.default['__event__' + flash.id] = function (eventName, message) { 5997 var event = (0, _general.createEvent)(eventName, flash); 5998 if (message) { 5999 try { 6000 event.data = JSON.parse(message); 6001 event.details.data = JSON.parse(message); 6002 } catch (e) { 6003 event.message = message; 6004 } 6005 } 6006 6007 flash.mediaElement.dispatchEvent(event); 6008 }; 6009 6010 flash.flashWrapper = _document2.default.createElement('div'); 6011 6012 if (['always', 'sameDomain'].indexOf(flash.options.shimScriptAccess) === -1) { 6013 flash.options.shimScriptAccess = 'sameDomain'; 6014 } 6015 6016 var autoplay = mediaElement.originalNode.autoplay, 6017 flashVars = ['uid=' + flash.id, 'autoplay=' + autoplay, 'allowScriptAccess=' + flash.options.shimScriptAccess, 'preload=' + (mediaElement.originalNode.getAttribute('preload') || '')], 6018 isVideo = mediaElement.originalNode !== null && mediaElement.originalNode.tagName.toLowerCase() === 'video', 6019 flashHeight = isVideo ? mediaElement.originalNode.height : 1, 6020 flashWidth = isVideo ? mediaElement.originalNode.width : 1; 6021 6022 if (mediaElement.originalNode.getAttribute('src')) { 6023 flashVars.push('src=' + mediaElement.originalNode.getAttribute('src')); 6024 } 6025 6026 if (flash.options.enablePseudoStreaming === true) { 6027 flashVars.push('pseudostreamstart=' + flash.options.pseudoStreamingStartQueryParam); 6028 flashVars.push('pseudostreamtype=' + flash.options.pseudoStreamingType); 6029 } 6030 6031 if (flash.options.streamDelimiter) { 6032 flashVars.push('streamdelimiter=' + encodeURIComponent(flash.options.streamDelimiter)); 6033 } 6034 6035 if (flash.options.proxyType) { 6036 flashVars.push('proxytype=' + flash.options.proxyType); 6037 } 6038 6039 mediaElement.appendChild(flash.flashWrapper); 6040 mediaElement.originalNode.style.display = 'none'; 6041 6042 var settings = []; 6043 6044 if (_constants.IS_IE || _constants.IS_EDGE) { 6045 var specialIEContainer = _document2.default.createElement('div'); 6046 flash.flashWrapper.appendChild(specialIEContainer); 6047 6048 if (_constants.IS_EDGE) { 6049 settings = ['type="application/x-shockwave-flash"', 'data="' + flash.options.pluginPath + flash.options.filename + '"', 'id="__' + flash.id + '"', 'width="' + flashWidth + '"', 'height="' + flashHeight + '\'"']; 6050 } else { 6051 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 + '"']; 6052 } 6053 6054 if (!isVideo) { 6055 settings.push('style="clip: rect(0 0 0 0); position: absolute;"'); 6056 } 6057 6058 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>'; 6059 } else { 6060 6061 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('&') + '"']; 6062 6063 if (isVideo) { 6064 settings.push('width="' + flashWidth + '"'); 6065 settings.push('height="' + flashHeight + '"'); 6066 } else { 6067 settings.push('style="position: fixed; left: -9999em; top: -9999em;"'); 6068 } 6069 6070 flash.flashWrapper.innerHTML = '<embed ' + settings.join(' ') + '>'; 6071 } 6072 6073 flash.flashNode = flash.flashWrapper.lastChild; 6074 6075 flash.hide = function () { 6076 isActive = false; 6077 if (isVideo) { 6078 flash.flashNode.style.display = 'none'; 6079 } 6080 }; 6081 flash.show = function () { 6082 isActive = true; 6083 if (isVideo) { 6084 flash.flashNode.style.display = ''; 6085 } 6086 }; 6087 flash.setSize = function (width, height) { 6088 flash.flashNode.style.width = width + 'px'; 6089 flash.flashNode.style.height = height + 'px'; 6090 6091 if (flash.flashApi !== null && typeof flash.flashApi.fire_setSize === 'function') { 6092 flash.flashApi.fire_setSize(width, height); 6093 } 6094 }; 6095 6096 flash.destroy = function () { 6097 flash.flashNode.remove(); 6098 }; 6099 6100 if (mediaFiles && mediaFiles.length > 0) { 6101 for (var _i4 = 0, _total4 = mediaFiles.length; _i4 < _total4; _i4++) { 6102 if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[_i4].type)) { 6103 flash.setSrc(mediaFiles[_i4].src); 6104 break; 6105 } 6106 } 6107 } 6108 6109 return flash; 6110 } 6111 }; 6112 6113 var hasFlash = PluginDetector.hasPluginVersion('flash', [10, 0, 0]); 6114 6115 if (hasFlash) { 6116 _media.typeChecks.push(function (url) { 6117 url = url.toLowerCase(); 6118 6119 if (url.startsWith('rtmp')) { 6120 if (~url.indexOf('.mp3')) { 6121 return 'audio/rtmp'; 6122 } else { 6123 return 'video/rtmp'; 6124 } 6125 } else if (/\.og(a|g)/i.test(url)) { 6126 return 'audio/ogg'; 6127 } else if (~url.indexOf('.m3u8')) { 6128 return 'application/x-mpegURL'; 6129 } else if (~url.indexOf('.mpd')) { 6130 return 'application/dash+xml'; 6131 } else if (~url.indexOf('.flv')) { 6132 return 'video/flv'; 6133 } else { 6134 return null; 6135 } 6136 }); 6137 6138 var FlashMediaElementVideoRenderer = { 6139 name: 'flash_video', 6140 options: { 6141 prefix: 'flash_video', 6142 filename: 'mediaelement-flash-video.swf', 6143 enablePseudoStreaming: false, 6144 6145 pseudoStreamingStartQueryParam: 'start', 6146 6147 pseudoStreamingType: 'byte', 6148 6149 proxyType: '', 6150 6151 streamDelimiter: '' 6152 }, 6153 6154 canPlayType: function canPlayType(type) { 6155 return ~['video/mp4', 'video/rtmp', 'audio/rtmp', 'rtmp/mp4', 'audio/mp4', 'video/flv', 'video/x-flv'].indexOf(type.toLowerCase()); 6156 }, 6157 6158 create: FlashMediaElementRenderer.create 6159 6160 }; 6161 _renderer.renderer.add(FlashMediaElementVideoRenderer); 6162 6163 var FlashMediaElementHlsVideoRenderer = { 6164 name: 'flash_hls', 6165 options: { 6166 prefix: 'flash_hls', 6167 filename: 'mediaelement-flash-video-hls.swf' 6168 }, 6169 6170 canPlayType: function canPlayType(type) { 6171 return ~['application/x-mpegurl', 'application/vnd.apple.mpegurl', 'audio/mpegurl', 'audio/hls', 'video/hls'].indexOf(type.toLowerCase()); 6172 }, 6173 6174 create: FlashMediaElementRenderer.create 6175 }; 6176 _renderer.renderer.add(FlashMediaElementHlsVideoRenderer); 6177 6178 var FlashMediaElementMdashVideoRenderer = { 6179 name: 'flash_dash', 6180 options: { 6181 prefix: 'flash_dash', 6182 filename: 'mediaelement-flash-video-mdash.swf' 6183 }, 6184 6185 canPlayType: function canPlayType(type) { 6186 return ~['application/dash+xml'].indexOf(type.toLowerCase()); 6187 }, 6188 6189 create: FlashMediaElementRenderer.create 6190 }; 6191 _renderer.renderer.add(FlashMediaElementMdashVideoRenderer); 6192 6193 var FlashMediaElementAudioRenderer = { 6194 name: 'flash_audio', 6195 options: { 6196 prefix: 'flash_audio', 6197 filename: 'mediaelement-flash-audio.swf' 6198 }, 6199 6200 canPlayType: function canPlayType(type) { 6201 return ~['audio/mp3'].indexOf(type.toLowerCase()); 6202 }, 6203 6204 create: FlashMediaElementRenderer.create 6205 }; 6206 _renderer.renderer.add(FlashMediaElementAudioRenderer); 6207 6208 var FlashMediaElementAudioOggRenderer = { 6209 name: 'flash_audio_ogg', 6210 options: { 6211 prefix: 'flash_audio_ogg', 6212 filename: 'mediaelement-flash-audio-ogg.swf' 6213 }, 6214 6215 canPlayType: function canPlayType(type) { 6216 return ~['audio/ogg', 'audio/oga', 'audio/ogv'].indexOf(type.toLowerCase()); 6217 }, 6218 6219 create: FlashMediaElementRenderer.create 6220 }; 6221 _renderer.renderer.add(FlashMediaElementAudioOggRenderer); 6222 } 6223 6224 },{"2":2,"25":25,"27":27,"28":28,"3":3,"5":5,"7":7,"8":8}],21:[function(_dereq_,module,exports){ 6225 'use strict'; 6226 6227 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; }; 6228 6229 var _window = _dereq_(3); 6230 6231 var _window2 = _interopRequireDefault(_window); 6232 6233 var _mejs = _dereq_(7); 6234 6235 var _mejs2 = _interopRequireDefault(_mejs); 6236 6237 var _renderer = _dereq_(8); 6238 6239 var _general = _dereq_(27); 6240 6241 var _constants = _dereq_(25); 6242 6243 var _media = _dereq_(28); 6244 6245 var _dom = _dereq_(26); 6246 6247 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 6248 6249 var NativeFlv = { 6250 6251 promise: null, 6252 6253 load: function load(settings) { 6254 if (typeof flvjs !== 'undefined') { 6255 NativeFlv.promise = new Promise(function (resolve) { 6256 resolve(); 6257 }).then(function () { 6258 NativeFlv._createPlayer(settings); 6259 }); 6260 } else { 6261 settings.options.path = typeof settings.options.path === 'string' ? settings.options.path : 'https://cdn.jsdelivr.net/npm/flv.js@latest'; 6262 6263 NativeFlv.promise = NativeFlv.promise || (0, _dom.loadScript)(settings.options.path); 6264 NativeFlv.promise.then(function () { 6265 NativeFlv._createPlayer(settings); 6266 }); 6267 } 6268 6269 return NativeFlv.promise; 6270 }, 6271 6272 _createPlayer: function _createPlayer(settings) { 6273 flvjs.LoggingControl.enableDebug = settings.options.debug; 6274 flvjs.LoggingControl.enableVerbose = settings.options.debug; 6275 var player = flvjs.createPlayer(settings.options, settings.configs); 6276 _window2.default['__ready__' + settings.id](player); 6277 return player; 6278 } 6279 }; 6280 6281 var FlvNativeRenderer = { 6282 name: 'native_flv', 6283 options: { 6284 prefix: 'native_flv', 6285 flv: { 6286 path: 'https://cdn.jsdelivr.net/npm/flv.js@latest', 6287 6288 cors: true, 6289 debug: false 6290 } 6291 }, 6292 6293 canPlayType: function canPlayType(type) { 6294 return _constants.HAS_MSE && ['video/x-flv', 'video/flv'].indexOf(type.toLowerCase()) > -1; 6295 }, 6296 6297 create: function create(mediaElement, options, mediaFiles) { 6298 6299 var originalNode = mediaElement.originalNode, 6300 id = mediaElement.id + '_' + options.prefix; 6301 6302 var node = null, 6303 flvPlayer = null; 6304 6305 node = originalNode.cloneNode(true); 6306 options = Object.assign(options, mediaElement.options); 6307 6308 var props = _mejs2.default.html5media.properties, 6309 events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']).filter(function (e) { 6310 return e !== 'error'; 6311 }), 6312 attachNativeEvents = function attachNativeEvents(e) { 6313 var event = (0, _general.createEvent)(e.type, mediaElement); 6314 mediaElement.dispatchEvent(event); 6315 }, 6316 assignGettersSetters = function assignGettersSetters(propName) { 6317 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 6318 6319 node['get' + capName] = function () { 6320 return flvPlayer !== null ? node[propName] : null; 6321 }; 6322 6323 node['set' + capName] = function (value) { 6324 if (_mejs2.default.html5media.readOnlyProperties.indexOf(propName) === -1) { 6325 if (propName === 'src') { 6326 node[propName] = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src ? value.src : value; 6327 if (flvPlayer !== null) { 6328 var _flvOptions = {}; 6329 _flvOptions.type = 'flv'; 6330 _flvOptions.url = value; 6331 _flvOptions.cors = options.flv.cors; 6332 _flvOptions.debug = options.flv.debug; 6333 _flvOptions.path = options.flv.path; 6334 var _flvConfigs = options.flv.configs; 6335 6336 flvPlayer.destroy(); 6337 for (var i = 0, total = events.length; i < total; i++) { 6338 node.removeEventListener(events[i], attachNativeEvents); 6339 } 6340 flvPlayer = NativeFlv._createPlayer({ 6341 options: _flvOptions, 6342 configs: _flvConfigs, 6343 id: id 6344 }); 6345 flvPlayer.attachMediaElement(node); 6346 flvPlayer.load(); 6347 } 6348 } else { 6349 node[propName] = value; 6350 } 6351 } 6352 }; 6353 }; 6354 6355 for (var i = 0, total = props.length; i < total; i++) { 6356 assignGettersSetters(props[i]); 6357 } 6358 6359 _window2.default['__ready__' + id] = function (_flvPlayer) { 6360 mediaElement.flvPlayer = flvPlayer = _flvPlayer; 6361 6362 var flvEvents = flvjs.Events, 6363 assignEvents = function assignEvents(eventName) { 6364 if (eventName === 'loadedmetadata') { 6365 flvPlayer.unload(); 6366 flvPlayer.detachMediaElement(); 6367 flvPlayer.attachMediaElement(node); 6368 flvPlayer.load(); 6369 } 6370 6371 node.addEventListener(eventName, attachNativeEvents); 6372 }; 6373 6374 for (var _i = 0, _total = events.length; _i < _total; _i++) { 6375 assignEvents(events[_i]); 6376 } 6377 6378 var assignFlvEvents = function assignFlvEvents(name, data) { 6379 if (name === 'error') { 6380 var message = data[0] + ': ' + data[1] + ' ' + data[2].msg; 6381 mediaElement.generateError(message, node.src); 6382 } else { 6383 var _event = (0, _general.createEvent)(name, mediaElement); 6384 _event.data = data; 6385 mediaElement.dispatchEvent(_event); 6386 } 6387 }; 6388 6389 var _loop = function _loop(eventType) { 6390 if (flvEvents.hasOwnProperty(eventType)) { 6391 flvPlayer.on(flvEvents[eventType], function () { 6392 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { 6393 args[_key] = arguments[_key]; 6394 } 6395 6396 return assignFlvEvents(flvEvents[eventType], args); 6397 }); 6398 } 6399 }; 6400 6401 for (var eventType in flvEvents) { 6402 _loop(eventType); 6403 } 6404 }; 6405 6406 if (mediaFiles && mediaFiles.length > 0) { 6407 for (var _i2 = 0, _total2 = mediaFiles.length; _i2 < _total2; _i2++) { 6408 if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[_i2].type)) { 6409 node.setAttribute('src', mediaFiles[_i2].src); 6410 break; 6411 } 6412 } 6413 } 6414 6415 node.setAttribute('id', id); 6416 6417 originalNode.parentNode.insertBefore(node, originalNode); 6418 originalNode.autoplay = false; 6419 originalNode.style.display = 'none'; 6420 6421 var flvOptions = {}; 6422 flvOptions.type = 'flv'; 6423 flvOptions.url = node.src; 6424 flvOptions.cors = options.flv.cors; 6425 flvOptions.debug = options.flv.debug; 6426 flvOptions.path = options.flv.path; 6427 var flvConfigs = options.flv.configs; 6428 6429 node.setSize = function (width, height) { 6430 node.style.width = width + 'px'; 6431 node.style.height = height + 'px'; 6432 return node; 6433 }; 6434 6435 node.hide = function () { 6436 if (flvPlayer !== null) { 6437 flvPlayer.pause(); 6438 } 6439 node.style.display = 'none'; 6440 return node; 6441 }; 6442 6443 node.show = function () { 6444 node.style.display = ''; 6445 return node; 6446 }; 6447 6448 node.destroy = function () { 6449 if (flvPlayer !== null) { 6450 flvPlayer.destroy(); 6451 } 6452 }; 6453 6454 var event = (0, _general.createEvent)('rendererready', node); 6455 mediaElement.dispatchEvent(event); 6456 6457 mediaElement.promises.push(NativeFlv.load({ 6458 options: flvOptions, 6459 configs: flvConfigs, 6460 id: id 6461 })); 6462 6463 return node; 6464 } 6465 }; 6466 6467 _media.typeChecks.push(function (url) { 6468 return ~url.toLowerCase().indexOf('.flv') ? 'video/flv' : null; 6469 }); 6470 6471 _renderer.renderer.add(FlvNativeRenderer); 6472 6473 },{"25":25,"26":26,"27":27,"28":28,"3":3,"7":7,"8":8}],22:[function(_dereq_,module,exports){ 6474 'use strict'; 6475 6476 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; }; 6477 6478 var _window = _dereq_(3); 6479 6480 var _window2 = _interopRequireDefault(_window); 6481 6482 var _mejs = _dereq_(7); 6483 6484 var _mejs2 = _interopRequireDefault(_mejs); 6485 6486 var _renderer = _dereq_(8); 6487 6488 var _general = _dereq_(27); 6489 6490 var _constants = _dereq_(25); 6491 6492 var _media = _dereq_(28); 6493 6494 var _dom = _dereq_(26); 6495 6496 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 6497 6498 var NativeHls = { 6499 6500 promise: null, 6501 6502 load: function load(settings) { 6503 if (typeof Hls !== 'undefined') { 6504 NativeHls.promise = new Promise(function (resolve) { 6505 resolve(); 6506 }).then(function () { 6507 NativeHls._createPlayer(settings); 6508 }); 6509 } else { 6510 settings.options.path = typeof settings.options.path === 'string' ? settings.options.path : 'https://cdn.jsdelivr.net/npm/hls.js@latest'; 6511 6512 NativeHls.promise = NativeHls.promise || (0, _dom.loadScript)(settings.options.path); 6513 NativeHls.promise.then(function () { 6514 NativeHls._createPlayer(settings); 6515 }); 6516 } 6517 6518 return NativeHls.promise; 6519 }, 6520 6521 _createPlayer: function _createPlayer(settings) { 6522 var player = new Hls(settings.options); 6523 _window2.default['__ready__' + settings.id](player); 6524 return player; 6525 } 6526 }; 6527 6528 var HlsNativeRenderer = { 6529 name: 'native_hls', 6530 options: { 6531 prefix: 'native_hls', 6532 hls: { 6533 path: 'https://cdn.jsdelivr.net/npm/hls.js@latest', 6534 6535 autoStartLoad: false, 6536 debug: false 6537 } 6538 }, 6539 6540 canPlayType: function canPlayType(type) { 6541 return _constants.HAS_MSE && ['application/x-mpegurl', 'application/vnd.apple.mpegurl', 'audio/mpegurl', 'audio/hls', 'video/hls'].indexOf(type.toLowerCase()) > -1; 6542 }, 6543 6544 create: function create(mediaElement, options, mediaFiles) { 6545 6546 var originalNode = mediaElement.originalNode, 6547 id = mediaElement.id + '_' + options.prefix, 6548 preload = originalNode.getAttribute('preload'), 6549 autoplay = originalNode.autoplay; 6550 6551 var hlsPlayer = null, 6552 node = null, 6553 index = 0, 6554 total = mediaFiles.length; 6555 6556 node = originalNode.cloneNode(true); 6557 options = Object.assign(options, mediaElement.options); 6558 options.hls.autoStartLoad = preload && preload !== 'none' || autoplay; 6559 6560 var props = _mejs2.default.html5media.properties, 6561 events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']).filter(function (e) { 6562 return e !== 'error'; 6563 }), 6564 attachNativeEvents = function attachNativeEvents(e) { 6565 var event = (0, _general.createEvent)(e.type, mediaElement); 6566 mediaElement.dispatchEvent(event); 6567 }, 6568 assignGettersSetters = function assignGettersSetters(propName) { 6569 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 6570 6571 node['get' + capName] = function () { 6572 return hlsPlayer !== null ? node[propName] : null; 6573 }; 6574 6575 node['set' + capName] = function (value) { 6576 if (_mejs2.default.html5media.readOnlyProperties.indexOf(propName) === -1) { 6577 if (propName === 'src') { 6578 node[propName] = (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value.src ? value.src : value; 6579 if (hlsPlayer !== null) { 6580 hlsPlayer.destroy(); 6581 for (var i = 0, _total = events.length; i < _total; i++) { 6582 node.removeEventListener(events[i], attachNativeEvents); 6583 } 6584 hlsPlayer = NativeHls._createPlayer({ 6585 options: options.hls, 6586 id: id 6587 }); 6588 hlsPlayer.loadSource(value); 6589 hlsPlayer.attachMedia(node); 6590 } 6591 } else { 6592 node[propName] = value; 6593 } 6594 } 6595 }; 6596 }; 6597 6598 for (var i = 0, _total2 = props.length; i < _total2; i++) { 6599 assignGettersSetters(props[i]); 6600 } 6601 6602 _window2.default['__ready__' + id] = function (_hlsPlayer) { 6603 mediaElement.hlsPlayer = hlsPlayer = _hlsPlayer; 6604 var hlsEvents = Hls.Events, 6605 assignEvents = function assignEvents(eventName) { 6606 if (eventName === 'loadedmetadata') { 6607 var url = mediaElement.originalNode.src; 6608 hlsPlayer.detachMedia(); 6609 hlsPlayer.loadSource(url); 6610 hlsPlayer.attachMedia(node); 6611 } 6612 6613 node.addEventListener(eventName, attachNativeEvents); 6614 }; 6615 6616 for (var _i = 0, _total3 = events.length; _i < _total3; _i++) { 6617 assignEvents(events[_i]); 6618 } 6619 6620 var recoverDecodingErrorDate = void 0, 6621 recoverSwapAudioCodecDate = void 0; 6622 var assignHlsEvents = function assignHlsEvents(name, data) { 6623 if (name === 'hlsError') { 6624 console.warn(data); 6625 data = data[1]; 6626 6627 if (data.fatal) { 6628 switch (data.type) { 6629 case 'mediaError': 6630 var now = new Date().getTime(); 6631 if (!recoverDecodingErrorDate || now - recoverDecodingErrorDate > 3000) { 6632 recoverDecodingErrorDate = new Date().getTime(); 6633 hlsPlayer.recoverMediaError(); 6634 } else if (!recoverSwapAudioCodecDate || now - recoverSwapAudioCodecDate > 3000) { 6635 recoverSwapAudioCodecDate = new Date().getTime(); 6636 console.warn('Attempting to swap Audio Codec and recover from media error'); 6637 hlsPlayer.swapAudioCodec(); 6638 hlsPlayer.recoverMediaError(); 6639 } else { 6640 var message = 'Cannot recover, last media error recovery failed'; 6641 mediaElement.generateError(message, node.src); 6642 console.error(message); 6643 } 6644 break; 6645 case 'networkError': 6646 if (data.details === 'manifestLoadError') { 6647 if (index < total && mediaFiles[index + 1] !== undefined) { 6648 node.setSrc(mediaFiles[index++].src); 6649 node.load(); 6650 node.play(); 6651 } else { 6652 var _message = 'Network error'; 6653 mediaElement.generateError(_message, mediaFiles); 6654 console.error(_message); 6655 } 6656 } else { 6657 var _message2 = 'Network error'; 6658 mediaElement.generateError(_message2, mediaFiles); 6659 console.error(_message2); 6660 } 6661 break; 6662 default: 6663 hlsPlayer.destroy(); 6664 break; 6665 } 6666 return; 6667 } 6668 } 6669 var event = (0, _general.createEvent)(name, mediaElement); 6670 event.data = data; 6671 mediaElement.dispatchEvent(event); 6672 }; 6673 6674 var _loop = function _loop(eventType) { 6675 if (hlsEvents.hasOwnProperty(eventType)) { 6676 hlsPlayer.on(hlsEvents[eventType], function () { 6677 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { 6678 args[_key] = arguments[_key]; 6679 } 6680 6681 return assignHlsEvents(hlsEvents[eventType], args); 6682 }); 6683 } 6684 }; 6685 6686 for (var eventType in hlsEvents) { 6687 _loop(eventType); 6688 } 6689 }; 6690 6691 if (total > 0) { 6692 for (; index < total; index++) { 6693 if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[index].type)) { 6694 node.setAttribute('src', mediaFiles[index].src); 6695 break; 6696 } 6697 } 6698 } 6699 6700 if (preload !== 'auto' && !autoplay) { 6701 node.addEventListener('play', function () { 6702 if (hlsPlayer !== null) { 6703 hlsPlayer.startLoad(); 6704 } 6705 }); 6706 6707 node.addEventListener('pause', function () { 6708 if (hlsPlayer !== null) { 6709 hlsPlayer.stopLoad(); 6710 } 6711 }); 6712 } 6713 6714 node.setAttribute('id', id); 6715 6716 originalNode.parentNode.insertBefore(node, originalNode); 6717 originalNode.autoplay = false; 6718 originalNode.style.display = 'none'; 6719 6720 node.setSize = function (width, height) { 6721 node.style.width = width + 'px'; 6722 node.style.height = height + 'px'; 6723 return node; 6724 }; 6725 6726 node.hide = function () { 6727 node.pause(); 6728 node.style.display = 'none'; 6729 return node; 6730 }; 6731 6732 node.show = function () { 6733 node.style.display = ''; 6734 return node; 6735 }; 6736 6737 node.destroy = function () { 6738 if (hlsPlayer !== null) { 6739 hlsPlayer.stopLoad(); 6740 hlsPlayer.destroy(); 6741 } 6742 }; 6743 6744 var event = (0, _general.createEvent)('rendererready', node); 6745 mediaElement.dispatchEvent(event); 6746 6747 mediaElement.promises.push(NativeHls.load({ 6748 options: options.hls, 6749 id: id 6750 })); 6751 6752 return node; 6753 } 6754 }; 6755 6756 _media.typeChecks.push(function (url) { 6757 return ~url.toLowerCase().indexOf('.m3u8') ? 'application/x-mpegURL' : null; 6758 }); 6759 6760 _renderer.renderer.add(HlsNativeRenderer); 6761 6762 },{"25":25,"26":26,"27":27,"28":28,"3":3,"7":7,"8":8}],23:[function(_dereq_,module,exports){ 6763 'use strict'; 6764 6765 var _window = _dereq_(3); 6766 6767 var _window2 = _interopRequireDefault(_window); 6768 6769 var _document = _dereq_(2); 6770 6771 var _document2 = _interopRequireDefault(_document); 6772 6773 var _mejs = _dereq_(7); 6774 6775 var _mejs2 = _interopRequireDefault(_mejs); 6776 6777 var _renderer = _dereq_(8); 6778 6779 var _general = _dereq_(27); 6780 6781 var _constants = _dereq_(25); 6782 6783 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 6784 6785 var HtmlMediaElement = { 6786 name: 'html5', 6787 options: { 6788 prefix: 'html5' 6789 }, 6790 6791 canPlayType: function canPlayType(type) { 6792 6793 var mediaElement = _document2.default.createElement('video'); 6794 6795 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) { 6796 return 'yes'; 6797 } else if (mediaElement.canPlayType) { 6798 return mediaElement.canPlayType(type.toLowerCase()).replace(/no/, ''); 6799 } else { 6800 return ''; 6801 } 6802 }, 6803 6804 create: function create(mediaElement, options, mediaFiles) { 6805 6806 var id = mediaElement.id + '_' + options.prefix; 6807 var isActive = false; 6808 6809 var node = null; 6810 6811 if (mediaElement.originalNode === undefined || mediaElement.originalNode === null) { 6812 node = _document2.default.createElement('audio'); 6813 mediaElement.appendChild(node); 6814 } else { 6815 node = mediaElement.originalNode; 6816 } 6817 6818 node.setAttribute('id', id); 6819 6820 var props = _mejs2.default.html5media.properties, 6821 assignGettersSetters = function assignGettersSetters(propName) { 6822 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 6823 6824 node['get' + capName] = function () { 6825 return node[propName]; 6826 }; 6827 6828 node['set' + capName] = function (value) { 6829 if (_mejs2.default.html5media.readOnlyProperties.indexOf(propName) === -1) { 6830 node[propName] = value; 6831 } 6832 }; 6833 }; 6834 6835 for (var i = 0, _total = props.length; i < _total; i++) { 6836 assignGettersSetters(props[i]); 6837 } 6838 6839 var events = _mejs2.default.html5media.events.concat(['click', 'mouseover', 'mouseout']).filter(function (e) { 6840 return e !== 'error'; 6841 }), 6842 assignEvents = function assignEvents(eventName) { 6843 node.addEventListener(eventName, function (e) { 6844 if (isActive) { 6845 var _event = (0, _general.createEvent)(e.type, e.target); 6846 mediaElement.dispatchEvent(_event); 6847 } 6848 }); 6849 }; 6850 6851 for (var _i = 0, _total2 = events.length; _i < _total2; _i++) { 6852 assignEvents(events[_i]); 6853 } 6854 6855 node.setSize = function (width, height) { 6856 node.style.width = width + 'px'; 6857 node.style.height = height + 'px'; 6858 return node; 6859 }; 6860 6861 node.hide = function () { 6862 isActive = false; 6863 node.style.display = 'none'; 6864 6865 return node; 6866 }; 6867 6868 node.show = function () { 6869 isActive = true; 6870 node.style.display = ''; 6871 6872 return node; 6873 }; 6874 6875 var index = 0, 6876 total = mediaFiles.length; 6877 if (total > 0) { 6878 for (; index < total; index++) { 6879 if (_renderer.renderer.renderers[options.prefix].canPlayType(mediaFiles[index].type)) { 6880 node.setAttribute('src', mediaFiles[index].src); 6881 break; 6882 } 6883 } 6884 } 6885 6886 node.addEventListener('error', function (e) { 6887 if (e && e.target && e.target.error && e.target.error.code === 4 && isActive) { 6888 if (index < total && mediaFiles[index + 1] !== undefined) { 6889 node.src = mediaFiles[index++].src; 6890 node.load(); 6891 node.play(); 6892 } else { 6893 mediaElement.generateError('Media error: Format(s) not supported or source(s) not found', mediaFiles); 6894 } 6895 } 6896 }); 6897 6898 var event = (0, _general.createEvent)('rendererready', node); 6899 mediaElement.dispatchEvent(event); 6900 6901 return node; 6902 } 6903 }; 6904 6905 _window2.default.HtmlMediaElement = _mejs2.default.HtmlMediaElement = HtmlMediaElement; 6906 6907 _renderer.renderer.add(HtmlMediaElement); 6908 6909 },{"2":2,"25":25,"27":27,"3":3,"7":7,"8":8}],24:[function(_dereq_,module,exports){ 6910 'use strict'; 6911 6912 var _window = _dereq_(3); 6913 6914 var _window2 = _interopRequireDefault(_window); 6915 6916 var _document = _dereq_(2); 6917 6918 var _document2 = _interopRequireDefault(_document); 6919 6920 var _mejs = _dereq_(7); 6921 6922 var _mejs2 = _interopRequireDefault(_mejs); 6923 6924 var _renderer = _dereq_(8); 6925 6926 var _general = _dereq_(27); 6927 6928 var _media = _dereq_(28); 6929 6930 var _dom = _dereq_(26); 6931 6932 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 6933 6934 var YouTubeApi = { 6935 isIframeStarted: false, 6936 6937 isIframeLoaded: false, 6938 6939 iframeQueue: [], 6940 6941 enqueueIframe: function enqueueIframe(settings) { 6942 YouTubeApi.isLoaded = typeof YT !== 'undefined' && YT.loaded; 6943 6944 if (YouTubeApi.isLoaded) { 6945 YouTubeApi.createIframe(settings); 6946 } else { 6947 YouTubeApi.loadIframeApi(); 6948 YouTubeApi.iframeQueue.push(settings); 6949 } 6950 }, 6951 6952 loadIframeApi: function loadIframeApi() { 6953 if (!YouTubeApi.isIframeStarted) { 6954 (0, _dom.loadScript)('https://www.youtube.com/player_api'); 6955 YouTubeApi.isIframeStarted = true; 6956 } 6957 }, 6958 6959 iFrameReady: function iFrameReady() { 6960 6961 YouTubeApi.isLoaded = true; 6962 YouTubeApi.isIframeLoaded = true; 6963 6964 while (YouTubeApi.iframeQueue.length > 0) { 6965 var settings = YouTubeApi.iframeQueue.pop(); 6966 YouTubeApi.createIframe(settings); 6967 } 6968 }, 6969 6970 createIframe: function createIframe(settings) { 6971 return new YT.Player(settings.containerId, settings); 6972 }, 6973 6974 getYouTubeId: function getYouTubeId(url) { 6975 6976 var youTubeId = ''; 6977 6978 if (url.indexOf('?') > 0) { 6979 youTubeId = YouTubeApi.getYouTubeIdFromParam(url); 6980 6981 if (youTubeId === '') { 6982 youTubeId = YouTubeApi.getYouTubeIdFromUrl(url); 6983 } 6984 } else { 6985 youTubeId = YouTubeApi.getYouTubeIdFromUrl(url); 6986 } 6987 6988 var id = youTubeId.substring(youTubeId.lastIndexOf('/') + 1); 6989 youTubeId = id.split('?'); 6990 return youTubeId[0]; 6991 }, 6992 6993 getYouTubeIdFromParam: function getYouTubeIdFromParam(url) { 6994 6995 if (url === undefined || url === null || !url.trim().length) { 6996 return null; 6997 } 6998 6999 var parts = url.split('?'), 7000 parameters = parts[1].split('&'); 7001 7002 var youTubeId = ''; 7003 7004 for (var i = 0, total = parameters.length; i < total; i++) { 7005 var paramParts = parameters[i].split('='); 7006 if (paramParts[0] === 'v') { 7007 youTubeId = paramParts[1]; 7008 break; 7009 } 7010 } 7011 7012 return youTubeId; 7013 }, 7014 7015 getYouTubeIdFromUrl: function getYouTubeIdFromUrl(url) { 7016 7017 if (url === undefined || url === null || !url.trim().length) { 7018 return null; 7019 } 7020 7021 var parts = url.split('?'); 7022 url = parts[0]; 7023 return url.substring(url.lastIndexOf('/') + 1); 7024 }, 7025 7026 getYouTubeNoCookieUrl: function getYouTubeNoCookieUrl(url) { 7027 if (url === undefined || url === null || !url.trim().length || url.indexOf('//www.youtube') === -1) { 7028 return url; 7029 } 7030 7031 var parts = url.split('/'); 7032 parts[2] = parts[2].replace('.com', '-nocookie.com'); 7033 return parts.join('/'); 7034 } 7035 }; 7036 7037 var YouTubeIframeRenderer = { 7038 name: 'youtube_iframe', 7039 7040 options: { 7041 prefix: 'youtube_iframe', 7042 7043 youtube: { 7044 autoplay: 0, 7045 controls: 0, 7046 disablekb: 1, 7047 end: 0, 7048 loop: 0, 7049 modestbranding: 0, 7050 playsinline: 0, 7051 rel: 0, 7052 showinfo: 0, 7053 start: 0, 7054 iv_load_policy: 3, 7055 7056 nocookie: false, 7057 7058 imageQuality: null 7059 } 7060 }, 7061 7062 canPlayType: function canPlayType(type) { 7063 return ~['video/youtube', 'video/x-youtube'].indexOf(type.toLowerCase()); 7064 }, 7065 7066 create: function create(mediaElement, options, mediaFiles) { 7067 7068 var youtube = {}, 7069 apiStack = [], 7070 readyState = 4; 7071 7072 var youTubeApi = null, 7073 paused = true, 7074 ended = false, 7075 youTubeIframe = null, 7076 volume = 1; 7077 7078 youtube.options = options; 7079 youtube.id = mediaElement.id + '_' + options.prefix; 7080 youtube.mediaElement = mediaElement; 7081 7082 var props = _mejs2.default.html5media.properties, 7083 assignGettersSetters = function assignGettersSetters(propName) { 7084 7085 var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 7086 7087 youtube['get' + capName] = function () { 7088 if (youTubeApi !== null) { 7089 var value = null; 7090 7091 switch (propName) { 7092 case 'currentTime': 7093 return youTubeApi.getCurrentTime(); 7094 case 'duration': 7095 return youTubeApi.getDuration(); 7096 case 'volume': 7097 volume = youTubeApi.getVolume() / 100; 7098 return volume; 7099 case 'playbackRate': 7100 return youTubeApi.getPlaybackRate(); 7101 case 'paused': 7102 return paused; 7103 case 'ended': 7104 return ended; 7105 case 'muted': 7106 return youTubeApi.isMuted(); 7107 case 'buffered': 7108 var percentLoaded = youTubeApi.getVideoLoadedFraction(), 7109 duration = youTubeApi.getDuration(); 7110 return { 7111 start: function start() { 7112 return 0; 7113 }, 7114 end: function end() { 7115 return percentLoaded * duration; 7116 }, 7117 length: 1 7118 }; 7119 case 'src': 7120 return youTubeApi.getVideoUrl(); 7121 case 'readyState': 7122 return readyState; 7123 } 7124 7125 return value; 7126 } else { 7127 return null; 7128 } 7129 }; 7130 7131 youtube['set' + capName] = function (value) { 7132 if (youTubeApi !== null) { 7133 switch (propName) { 7134 case 'src': 7135 var url = typeof value === 'string' ? value : value[0].src, 7136 _videoId = YouTubeApi.getYouTubeId(url); 7137 7138 if (mediaElement.originalNode.autoplay) { 7139 youTubeApi.loadVideoById(_videoId); 7140 } else { 7141 youTubeApi.cueVideoById(_videoId); 7142 } 7143 break; 7144 case 'currentTime': 7145 youTubeApi.seekTo(value); 7146 break; 7147 case 'muted': 7148 if (value) { 7149 youTubeApi.mute(); 7150 } else { 7151 youTubeApi.unMute(); 7152 } 7153 setTimeout(function () { 7154 var event = (0, _general.createEvent)('volumechange', youtube); 7155 mediaElement.dispatchEvent(event); 7156 }, 50); 7157 break; 7158 case 'volume': 7159 volume = value; 7160 youTubeApi.setVolume(value * 100); 7161 setTimeout(function () { 7162 var event = (0, _general.createEvent)('volumechange', youtube); 7163 mediaElement.dispatchEvent(event); 7164 }, 50); 7165 break; 7166 case 'playbackRate': 7167 youTubeApi.setPlaybackRate(value); 7168 setTimeout(function () { 7169 var event = (0, _general.createEvent)('ratechange', youtube); 7170 mediaElement.dispatchEvent(event); 7171 }, 50); 7172 break; 7173 case 'readyState': 7174 var event = (0, _general.createEvent)('canplay', youtube); 7175 mediaElement.dispatchEvent(event); 7176 break; 7177 default: 7178 7179 break; 7180 } 7181 } else { 7182 apiStack.push({ type: 'set', propName: propName, value: value }); 7183 } 7184 }; 7185 }; 7186 7187 for (var i = 0, total = props.length; i < total; i++) { 7188 assignGettersSetters(props[i]); 7189 } 7190 7191 var methods = _mejs2.default.html5media.methods, 7192 assignMethods = function assignMethods(methodName) { 7193 youtube[methodName] = function () { 7194 if (youTubeApi !== null) { 7195 switch (methodName) { 7196 case 'play': 7197 paused = false; 7198 return youTubeApi.playVideo(); 7199 case 'pause': 7200 paused = true; 7201 return youTubeApi.pauseVideo(); 7202 case 'load': 7203 return null; 7204 } 7205 } else { 7206 apiStack.push({ type: 'call', methodName: methodName }); 7207 } 7208 }; 7209 }; 7210 7211 for (var _i = 0, _total = methods.length; _i < _total; _i++) { 7212 assignMethods(methods[_i]); 7213 } 7214 7215 var errorHandler = function errorHandler(error) { 7216 var message = ''; 7217 switch (error.data) { 7218 case 2: 7219 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.'; 7220 break; 7221 case 5: 7222 message = 'The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.'; 7223 break; 7224 case 100: 7225 message = 'The video requested was not found. Either video has been removed or has been marked as private.'; 7226 break; 7227 case 101: 7228 case 105: 7229 message = 'The owner of the requested video does not allow it to be played in embedded players.'; 7230 break; 7231 default: 7232 message = 'Unknown error.'; 7233 break; 7234 } 7235 mediaElement.generateError('Code ' + error.data + ': ' + message, mediaFiles); 7236 }; 7237 7238 var youtubeContainer = _document2.default.createElement('div'); 7239 youtubeContainer.id = youtube.id; 7240 7241 if (youtube.options.youtube.nocookie) { 7242 mediaElement.originalNode.src = YouTubeApi.getYouTubeNoCookieUrl(mediaFiles[0].src); 7243 } 7244 7245 mediaElement.originalNode.parentNode.insertBefore(youtubeContainer, mediaElement.originalNode); 7246 mediaElement.originalNode.style.display = 'none'; 7247 7248 var isAudio = mediaElement.originalNode.tagName.toLowerCase() === 'audio', 7249 height = isAudio ? '1' : mediaElement.originalNode.height, 7250 width = isAudio ? '1' : mediaElement.originalNode.width, 7251 videoId = YouTubeApi.getYouTubeId(mediaFiles[0].src), 7252 youtubeSettings = { 7253 id: youtube.id, 7254 containerId: youtubeContainer.id, 7255 videoId: videoId, 7256 height: height, 7257 width: width, 7258 playerVars: Object.assign({ 7259 controls: 0, 7260 rel: 0, 7261 disablekb: 1, 7262 showinfo: 0, 7263 modestbranding: 0, 7264 html5: 1, 7265 iv_load_policy: 3 7266 }, youtube.options.youtube), 7267 origin: _window2.default.location.host, 7268 events: { 7269 onReady: function onReady(e) { 7270 mediaElement.youTubeApi = youTubeApi = e.target; 7271 mediaElement.youTubeState = { 7272 paused: true, 7273 ended: false 7274 }; 7275 7276 if (apiStack.length) { 7277 for (var _i2 = 0, _total2 = apiStack.length; _i2 < _total2; _i2++) { 7278 7279 var stackItem = apiStack[_i2]; 7280 7281 if (stackItem.type === 'set') { 7282 var propName = stackItem.propName, 7283 capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1); 7284 7285 youtube['set' + capName](stackItem.value); 7286 } else if (stackItem.type === 'call') { 7287 youtube[stackItem.methodName](); 7288 } 7289 } 7290 } 7291 7292 youTubeIframe = youTubeApi.getIframe(); 7293 7294 if (mediaElement.originalNode.muted) { 7295 youTubeApi.mute(); 7296 } 7297 7298 var events = ['mouseover', 'mouseout'], 7299 assignEvents = function assignEvents(e) { 7300 var newEvent = (0, _general.createEvent)(e.type, youtube); 7301 mediaElement.dispatchEvent(newEvent); 7302 }; 7303 7304 for (var _i3 = 0, _total3 = events.length; _i3 < _total3; _i3++) { 7305 youTubeIframe.addEventListener(events[_i3], assignEvents, false); 7306 } 7307 7308 var initEvents = ['rendererready', 'loadedmetadata', 'loadeddata', 'canplay']; 7309 7310 for (var _i4 = 0, _total4 = initEvents.length; _i4 < _total4; _i4++) { 7311 var event = (0, _general.createEvent)(initEvents[_i4], youtube); 7312 mediaElement.dispatchEvent(event); 7313 } 7314 }, 7315 onStateChange: function onStateChange(e) { 7316 var events = []; 7317 7318 switch (e.data) { 7319 case -1: 7320 events = ['loadedmetadata']; 7321 paused = true; 7322 ended = false; 7323 break; 7324 case 0: 7325 events = ['ended']; 7326 paused = false; 7327 ended = !youtube.options.youtube.loop; 7328 if (!youtube.options.youtube.loop) { 7329 youtube.stopInterval(); 7330 } 7331 break; 7332 case 1: 7333 events = ['play', 'playing']; 7334 paused = false; 7335 ended = false; 7336 youtube.startInterval(); 7337 break; 7338 case 2: 7339 events = ['pause']; 7340 paused = true; 7341 ended = false; 7342 youtube.stopInterval(); 7343 break; 7344 case 3: 7345 events = ['progress']; 7346 ended = false; 7347 break; 7348 case 5: 7349 events = ['loadeddata', 'loadedmetadata', 'canplay']; 7350 paused = true; 7351 ended = false; 7352 break; 7353 } 7354 7355 for (var _i5 = 0, _total5 = events.length; _i5 < _total5; _i5++) { 7356 var event = (0, _general.createEvent)(events[_i5], youtube); 7357 mediaElement.dispatchEvent(event); 7358 } 7359 }, 7360 onError: function onError(e) { 7361 return errorHandler(e); 7362 } 7363 } 7364 }; 7365 7366 if (isAudio || mediaElement.originalNode.hasAttribute('playsinline')) { 7367 youtubeSettings.playerVars.playsinline = 1; 7368 } 7369 7370 if (mediaElement.originalNode.controls) { 7371 youtubeSettings.playerVars.controls = 1; 7372 } 7373 if (mediaElement.originalNode.autoplay) { 7374 youtubeSettings.playerVars.autoplay = 1; 7375 } 7376 if (mediaElement.originalNode.loop) { 7377 youtubeSettings.playerVars.loop = 1; 7378 } 7379 7380 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) { 7381 youtubeSettings.playerVars.playlist = YouTubeApi.getYouTubeId(mediaElement.originalNode.src); 7382 } 7383 7384 YouTubeApi.enqueueIframe(youtubeSettings); 7385 7386 youtube.onEvent = function (eventName, player, _youTubeState) { 7387 if (_youTubeState !== null && _youTubeState !== undefined) { 7388 mediaElement.youTubeState = _youTubeState; 7389 } 7390 }; 7391 7392 youtube.setSize = function (width, height) { 7393 if (youTubeApi !== null) { 7394 youTubeApi.setSize(width, height); 7395 } 7396 }; 7397 youtube.hide = function () { 7398 youtube.stopInterval(); 7399 youtube.pause(); 7400 if (youTubeIframe) { 7401 youTubeIframe.style.display = 'none'; 7402 } 7403 }; 7404 youtube.show = function () { 7405 if (youTubeIframe) { 7406 youTubeIframe.style.display = ''; 7407 } 7408 }; 7409 youtube.destroy = function () { 7410 youTubeApi.destroy(); 7411 }; 7412 youtube.interval = null; 7413 7414 youtube.startInterval = function () { 7415 youtube.interval = setInterval(function () { 7416 var event = (0, _general.createEvent)('timeupdate', youtube); 7417 mediaElement.dispatchEvent(event); 7418 }, 250); 7419 }; 7420 youtube.stopInterval = function () { 7421 if (youtube.interval) { 7422 clearInterval(youtube.interval); 7423 } 7424 }; 7425 youtube.getPosterUrl = function () { 7426 var quality = options.youtube.imageQuality, 7427 resolutions = ['default', 'hqdefault', 'mqdefault', 'sddefault', 'maxresdefault'], 7428 id = YouTubeApi.getYouTubeId(mediaElement.originalNode.src); 7429 return quality && resolutions.indexOf(quality) > -1 && id ? 'https://img.youtube.com/vi/' + id + '/' + quality + '.jpg' : ''; 7430 }; 7431 7432 return youtube; 7433 } 7434 }; 7435 7436 _window2.default.onYouTubePlayerAPIReady = function () { 7437 YouTubeApi.iFrameReady(); 7438 }; 7439 7440 _media.typeChecks.push(function (url) { 7441 return (/\/\/(www\.youtube|youtu\.?be)/i.test(url) ? 'video/x-youtube' : null 7442 ); 7443 }); 7444 7445 _renderer.renderer.add(YouTubeIframeRenderer); 7446 7447 },{"2":2,"26":26,"27":27,"28":28,"3":3,"7":7,"8":8}],25:[function(_dereq_,module,exports){ 7448 'use strict'; 7449 7450 Object.defineProperty(exports, "__esModule", { 7451 value: true 7452 }); 7453 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; 7454 7455 var _window = _dereq_(3); 7456 7457 var _window2 = _interopRequireDefault(_window); 7458 7459 var _document = _dereq_(2); 7460 7461 var _document2 = _interopRequireDefault(_document); 7462 7463 var _mejs = _dereq_(7); 7464 7465 var _mejs2 = _interopRequireDefault(_mejs); 7466 7467 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 7468 7469 var NAV = exports.NAV = _window2.default.navigator; 7470 var UA = exports.UA = NAV.userAgent.toLowerCase(); 7471 var IS_IPAD = exports.IS_IPAD = /ipad/i.test(UA) && !_window2.default.MSStream; 7472 var IS_IPHONE = exports.IS_IPHONE = /iphone/i.test(UA) && !_window2.default.MSStream; 7473 var IS_IPOD = exports.IS_IPOD = /ipod/i.test(UA) && !_window2.default.MSStream; 7474 var IS_IOS = exports.IS_IOS = /ipad|iphone|ipod/i.test(UA) && !_window2.default.MSStream; 7475 var IS_ANDROID = exports.IS_ANDROID = /android/i.test(UA); 7476 var IS_IE = exports.IS_IE = /(trident|microsoft)/i.test(NAV.appName); 7477 var IS_EDGE = exports.IS_EDGE = 'msLaunchUri' in NAV && !('documentMode' in _document2.default); 7478 var IS_CHROME = exports.IS_CHROME = /chrome/i.test(UA); 7479 var IS_FIREFOX = exports.IS_FIREFOX = /firefox/i.test(UA); 7480 var IS_SAFARI = exports.IS_SAFARI = /safari/i.test(UA) && !IS_CHROME; 7481 var IS_STOCK_ANDROID = exports.IS_STOCK_ANDROID = /^mozilla\/\d+\.\d+\s\(linux;\su;/i.test(UA); 7482 var HAS_MSE = exports.HAS_MSE = 'MediaSource' in _window2.default; 7483 var SUPPORT_POINTER_EVENTS = exports.SUPPORT_POINTER_EVENTS = function () { 7484 var element = _document2.default.createElement('x'), 7485 documentElement = _document2.default.documentElement, 7486 getComputedStyle = _window2.default.getComputedStyle; 7487 7488 if (!('pointerEvents' in element.style)) { 7489 return false; 7490 } 7491 7492 element.style.pointerEvents = 'auto'; 7493 element.style.pointerEvents = 'x'; 7494 documentElement.appendChild(element); 7495 var supports = getComputedStyle && (getComputedStyle(element, '') || {}).pointerEvents === 'auto'; 7496 element.remove(); 7497 return !!supports; 7498 }(); 7499 7500 var SUPPORT_PASSIVE_EVENT = exports.SUPPORT_PASSIVE_EVENT = function () { 7501 var supportsPassive = false; 7502 try { 7503 var opts = Object.defineProperty({}, 'passive', { 7504 get: function get() { 7505 supportsPassive = true; 7506 } 7507 }); 7508 _window2.default.addEventListener('test', null, opts); 7509 } catch (e) {} 7510 7511 return supportsPassive; 7512 }(); 7513 7514 var html5Elements = ['source', 'track', 'audio', 'video']; 7515 var video = void 0; 7516 7517 for (var i = 0, total = html5Elements.length; i < total; i++) { 7518 video = _document2.default.createElement(html5Elements[i]); 7519 } 7520 7521 var SUPPORTS_NATIVE_HLS = exports.SUPPORTS_NATIVE_HLS = IS_SAFARI || IS_IE && /edge/i.test(UA); 7522 7523 var hasiOSFullScreen = video.webkitEnterFullscreen !== undefined; 7524 7525 var hasNativeFullscreen = video.requestFullscreen !== undefined; 7526 7527 if (hasiOSFullScreen && /mac os x 10_5/i.test(UA)) { 7528 hasNativeFullscreen = false; 7529 hasiOSFullScreen = false; 7530 } 7531 7532 var hasWebkitNativeFullScreen = video.webkitRequestFullScreen !== undefined; 7533 var hasMozNativeFullScreen = video.mozRequestFullScreen !== undefined; 7534 var hasMsNativeFullScreen = video.msRequestFullscreen !== undefined; 7535 var hasTrueNativeFullScreen = hasWebkitNativeFullScreen || hasMozNativeFullScreen || hasMsNativeFullScreen; 7536 var nativeFullScreenEnabled = hasTrueNativeFullScreen; 7537 var fullScreenEventName = ''; 7538 var isFullScreen = void 0, 7539 requestFullScreen = void 0, 7540 cancelFullScreen = void 0; 7541 7542 if (hasMozNativeFullScreen) { 7543 nativeFullScreenEnabled = _document2.default.mozFullScreenEnabled; 7544 } else if (hasMsNativeFullScreen) { 7545 nativeFullScreenEnabled = _document2.default.msFullscreenEnabled; 7546 } 7547 7548 if (IS_CHROME) { 7549 hasiOSFullScreen = false; 7550 } 7551 7552 if (hasTrueNativeFullScreen) { 7553 if (hasWebkitNativeFullScreen) { 7554 fullScreenEventName = 'webkitfullscreenchange'; 7555 } else if (hasMozNativeFullScreen) { 7556 fullScreenEventName = 'fullscreenchange'; 7557 } else if (hasMsNativeFullScreen) { 7558 fullScreenEventName = 'MSFullscreenChange'; 7559 } 7560 7561 exports.isFullScreen = isFullScreen = function isFullScreen() { 7562 if (hasMozNativeFullScreen) { 7563 return _document2.default.mozFullScreen; 7564 } else if (hasWebkitNativeFullScreen) { 7565 return _document2.default.webkitIsFullScreen; 7566 } else if (hasMsNativeFullScreen) { 7567 return _document2.default.msFullscreenElement !== null; 7568 } 7569 }; 7570 7571 exports.requestFullScreen = requestFullScreen = function requestFullScreen(el) { 7572 if (hasWebkitNativeFullScreen) { 7573 el.webkitRequestFullScreen(); 7574 } else if (hasMozNativeFullScreen) { 7575 el.mozRequestFullScreen(); 7576 } else if (hasMsNativeFullScreen) { 7577 el.msRequestFullscreen(); 7578 } 7579 }; 7580 7581 exports.cancelFullScreen = cancelFullScreen = function cancelFullScreen() { 7582 if (hasWebkitNativeFullScreen) { 7583 _document2.default.webkitCancelFullScreen(); 7584 } else if (hasMozNativeFullScreen) { 7585 _document2.default.mozCancelFullScreen(); 7586 } else if (hasMsNativeFullScreen) { 7587 _document2.default.msExitFullscreen(); 7588 } 7589 }; 7590 } 7591 7592 var HAS_NATIVE_FULLSCREEN = exports.HAS_NATIVE_FULLSCREEN = hasNativeFullscreen; 7593 var HAS_WEBKIT_NATIVE_FULLSCREEN = exports.HAS_WEBKIT_NATIVE_FULLSCREEN = hasWebkitNativeFullScreen; 7594 var HAS_MOZ_NATIVE_FULLSCREEN = exports.HAS_MOZ_NATIVE_FULLSCREEN = hasMozNativeFullScreen; 7595 var HAS_MS_NATIVE_FULLSCREEN = exports.HAS_MS_NATIVE_FULLSCREEN = hasMsNativeFullScreen; 7596 var HAS_IOS_FULLSCREEN = exports.HAS_IOS_FULLSCREEN = hasiOSFullScreen; 7597 var HAS_TRUE_NATIVE_FULLSCREEN = exports.HAS_TRUE_NATIVE_FULLSCREEN = hasTrueNativeFullScreen; 7598 var HAS_NATIVE_FULLSCREEN_ENABLED = exports.HAS_NATIVE_FULLSCREEN_ENABLED = nativeFullScreenEnabled; 7599 var FULLSCREEN_EVENT_NAME = exports.FULLSCREEN_EVENT_NAME = fullScreenEventName; 7600 exports.isFullScreen = isFullScreen; 7601 exports.requestFullScreen = requestFullScreen; 7602 exports.cancelFullScreen = cancelFullScreen; 7603 7604 7605 _mejs2.default.Features = _mejs2.default.Features || {}; 7606 _mejs2.default.Features.isiPad = IS_IPAD; 7607 _mejs2.default.Features.isiPod = IS_IPOD; 7608 _mejs2.default.Features.isiPhone = IS_IPHONE; 7609 _mejs2.default.Features.isiOS = _mejs2.default.Features.isiPhone || _mejs2.default.Features.isiPad; 7610 _mejs2.default.Features.isAndroid = IS_ANDROID; 7611 _mejs2.default.Features.isIE = IS_IE; 7612 _mejs2.default.Features.isEdge = IS_EDGE; 7613 _mejs2.default.Features.isChrome = IS_CHROME; 7614 _mejs2.default.Features.isFirefox = IS_FIREFOX; 7615 _mejs2.default.Features.isSafari = IS_SAFARI; 7616 _mejs2.default.Features.isStockAndroid = IS_STOCK_ANDROID; 7617 _mejs2.default.Features.hasMSE = HAS_MSE; 7618 _mejs2.default.Features.supportsNativeHLS = SUPPORTS_NATIVE_HLS; 7619 _mejs2.default.Features.supportsPointerEvents = SUPPORT_POINTER_EVENTS; 7620 _mejs2.default.Features.supportsPassiveEvent = SUPPORT_PASSIVE_EVENT; 7621 _mejs2.default.Features.hasiOSFullScreen = HAS_IOS_FULLSCREEN; 7622 _mejs2.default.Features.hasNativeFullscreen = HAS_NATIVE_FULLSCREEN; 7623 _mejs2.default.Features.hasWebkitNativeFullScreen = HAS_WEBKIT_NATIVE_FULLSCREEN; 7624 _mejs2.default.Features.hasMozNativeFullScreen = HAS_MOZ_NATIVE_FULLSCREEN; 7625 _mejs2.default.Features.hasMsNativeFullScreen = HAS_MS_NATIVE_FULLSCREEN; 7626 _mejs2.default.Features.hasTrueNativeFullScreen = HAS_TRUE_NATIVE_FULLSCREEN; 7627 _mejs2.default.Features.nativeFullScreenEnabled = HAS_NATIVE_FULLSCREEN_ENABLED; 7628 _mejs2.default.Features.fullScreenEventName = FULLSCREEN_EVENT_NAME; 7629 _mejs2.default.Features.isFullScreen = isFullScreen; 7630 _mejs2.default.Features.requestFullScreen = requestFullScreen; 7631 _mejs2.default.Features.cancelFullScreen = cancelFullScreen; 7632 7633 },{"2":2,"3":3,"7":7}],26:[function(_dereq_,module,exports){ 7634 'use strict'; 7635 7636 Object.defineProperty(exports, "__esModule", { 7637 value: true 7638 }); 7639 exports.removeClass = exports.addClass = exports.hasClass = undefined; 7640 exports.loadScript = loadScript; 7641 exports.offset = offset; 7642 exports.toggleClass = toggleClass; 7643 exports.fadeOut = fadeOut; 7644 exports.fadeIn = fadeIn; 7645 exports.siblings = siblings; 7646 exports.visible = visible; 7647 exports.ajax = ajax; 7648 7649 var _window = _dereq_(3); 7650 7651 var _window2 = _interopRequireDefault(_window); 7652 7653 var _document = _dereq_(2); 7654 7655 var _document2 = _interopRequireDefault(_document); 7656 7657 var _mejs = _dereq_(7); 7658 7659 var _mejs2 = _interopRequireDefault(_mejs); 7660 7661 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 7662 7663 function loadScript(url) { 7664 return new Promise(function (resolve, reject) { 7665 var script = _document2.default.createElement('script'); 7666 script.src = url; 7667 script.async = true; 7668 script.onload = function () { 7669 script.remove(); 7670 resolve(); 7671 }; 7672 script.onerror = function () { 7673 script.remove(); 7674 reject(); 7675 }; 7676 _document2.default.head.appendChild(script); 7677 }); 7678 } 7679 7680 function offset(el) { 7681 var rect = el.getBoundingClientRect(), 7682 scrollLeft = _window2.default.pageXOffset || _document2.default.documentElement.scrollLeft, 7683 scrollTop = _window2.default.pageYOffset || _document2.default.documentElement.scrollTop; 7684 return { top: rect.top + scrollTop, left: rect.left + scrollLeft }; 7685 } 7686 7687 var hasClassMethod = void 0, 7688 addClassMethod = void 0, 7689 removeClassMethod = void 0; 7690 7691 if ('classList' in _document2.default.documentElement) { 7692 hasClassMethod = function hasClassMethod(el, className) { 7693 return el.classList !== undefined && el.classList.contains(className); 7694 }; 7695 addClassMethod = function addClassMethod(el, className) { 7696 return el.classList.add(className); 7697 }; 7698 removeClassMethod = function removeClassMethod(el, className) { 7699 return el.classList.remove(className); 7700 }; 7701 } else { 7702 hasClassMethod = function hasClassMethod(el, className) { 7703 return new RegExp('\\b' + className + '\\b').test(el.className); 7704 }; 7705 addClassMethod = function addClassMethod(el, className) { 7706 if (!hasClass(el, className)) { 7707 el.className += ' ' + className; 7708 } 7709 }; 7710 removeClassMethod = function removeClassMethod(el, className) { 7711 el.className = el.className.replace(new RegExp('\\b' + className + '\\b', 'g'), ''); 7712 }; 7713 } 7714 7715 var hasClass = exports.hasClass = hasClassMethod; 7716 var addClass = exports.addClass = addClassMethod; 7717 var removeClass = exports.removeClass = removeClassMethod; 7718 7719 function toggleClass(el, className) { 7720 hasClass(el, className) ? removeClass(el, className) : addClass(el, className); 7721 } 7722 7723 function fadeOut(el) { 7724 var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400; 7725 var callback = arguments[2]; 7726 7727 if (!el.style.opacity) { 7728 el.style.opacity = 1; 7729 } 7730 7731 var start = null; 7732 _window2.default.requestAnimationFrame(function animate(timestamp) { 7733 start = start || timestamp; 7734 var progress = timestamp - start; 7735 var opacity = parseFloat(1 - progress / duration, 2); 7736 el.style.opacity = opacity < 0 ? 0 : opacity; 7737 if (progress > duration) { 7738 if (callback && typeof callback === 'function') { 7739 callback(); 7740 } 7741 } else { 7742 _window2.default.requestAnimationFrame(animate); 7743 } 7744 }); 7745 } 7746 7747 function fadeIn(el) { 7748 var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400; 7749 var callback = arguments[2]; 7750 7751 if (!el.style.opacity) { 7752 el.style.opacity = 0; 7753 } 7754 7755 var start = null; 7756 _window2.default.requestAnimationFrame(function animate(timestamp) { 7757 start = start || timestamp; 7758 var progress = timestamp - start; 7759 var opacity = parseFloat(progress / duration, 2); 7760 el.style.opacity = opacity > 1 ? 1 : opacity; 7761 if (progress > duration) { 7762 if (callback && typeof callback === 'function') { 7763 callback(); 7764 } 7765 } else { 7766 _window2.default.requestAnimationFrame(animate); 7767 } 7768 }); 7769 } 7770 7771 function siblings(el, filter) { 7772 var siblings = []; 7773 el = el.parentNode.firstChild; 7774 do { 7775 if (!filter || filter(el)) { 7776 siblings.push(el); 7777 } 7778 } while (el = el.nextSibling); 7779 return siblings; 7780 } 7781 7782 function visible(elem) { 7783 if (elem.getClientRects !== undefined && elem.getClientRects === 'function') { 7784 return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length); 7785 } 7786 return !!(elem.offsetWidth || elem.offsetHeight); 7787 } 7788 7789 function ajax(url, dataType, success, error) { 7790 var xhr = _window2.default.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); 7791 7792 var type = 'application/x-www-form-urlencoded; charset=UTF-8', 7793 completed = false, 7794 accept = '*/'.concat('*'); 7795 7796 switch (dataType) { 7797 case 'text': 7798 type = 'text/plain'; 7799 break; 7800 case 'json': 7801 type = 'application/json, text/javascript'; 7802 break; 7803 case 'html': 7804 type = 'text/html'; 7805 break; 7806 case 'xml': 7807 type = 'application/xml, text/xml'; 7808 break; 7809 } 7810 7811 if (type !== 'application/x-www-form-urlencoded') { 7812 accept = type + ', */*; q=0.01'; 7813 } 7814 7815 if (xhr) { 7816 xhr.open('GET', url, true); 7817 xhr.setRequestHeader('Accept', accept); 7818 xhr.onreadystatechange = function () { 7819 if (completed) { 7820 return; 7821 } 7822 7823 if (xhr.readyState === 4) { 7824 if (xhr.status === 200) { 7825 completed = true; 7826 var data = void 0; 7827 switch (dataType) { 7828 case 'json': 7829 data = JSON.parse(xhr.responseText); 7830 break; 7831 case 'xml': 7832 data = xhr.responseXML; 7833 break; 7834 default: 7835 data = xhr.responseText; 7836 break; 7837 } 7838 success(data); 7839 } else if (typeof error === 'function') { 7840 error(xhr.status); 7841 } 7842 } 7843 }; 7844 7845 xhr.send(); 7846 } 7847 } 7848 7849 _mejs2.default.Utils = _mejs2.default.Utils || {}; 7850 _mejs2.default.Utils.offset = offset; 7851 _mejs2.default.Utils.hasClass = hasClass; 7852 _mejs2.default.Utils.addClass = addClass; 7853 _mejs2.default.Utils.removeClass = removeClass; 7854 _mejs2.default.Utils.toggleClass = toggleClass; 7855 _mejs2.default.Utils.fadeIn = fadeIn; 7856 _mejs2.default.Utils.fadeOut = fadeOut; 7857 _mejs2.default.Utils.siblings = siblings; 7858 _mejs2.default.Utils.visible = visible; 7859 _mejs2.default.Utils.ajax = ajax; 7860 _mejs2.default.Utils.loadScript = loadScript; 7861 7862 },{"2":2,"3":3,"7":7}],27:[function(_dereq_,module,exports){ 7863 'use strict'; 7864 7865 Object.defineProperty(exports, "__esModule", { 7866 value: true 7867 }); 7868 exports.escapeHTML = escapeHTML; 7869 exports.debounce = debounce; 7870 exports.isObjectEmpty = isObjectEmpty; 7871 exports.splitEvents = splitEvents; 7872 exports.createEvent = createEvent; 7873 exports.isNodeAfter = isNodeAfter; 7874 exports.isString = isString; 7875 7876 var _mejs = _dereq_(7); 7877 7878 var _mejs2 = _interopRequireDefault(_mejs); 7879 7880 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 7881 7882 function escapeHTML(input) { 7883 7884 if (typeof input !== 'string') { 7885 throw new Error('Argument passed must be a string'); 7886 } 7887 7888 var map = { 7889 '&': '&', 7890 '<': '<', 7891 '>': '>', 7892 '"': '"' 7893 }; 7894 7895 return input.replace(/[&<>"]/g, function (c) { 7896 return map[c]; 7897 }); 7898 } 7899 7900 function debounce(func, wait) { 7901 var _this = this, 7902 _arguments = arguments; 7903 7904 var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 7905 7906 7907 if (typeof func !== 'function') { 7908 throw new Error('First argument must be a function'); 7909 } 7910 7911 if (typeof wait !== 'number') { 7912 throw new Error('Second argument must be a numeric value'); 7913 } 7914 7915 var timeout = void 0; 7916 return function () { 7917 var context = _this, 7918 args = _arguments; 7919 var later = function later() { 7920 timeout = null; 7921 if (!immediate) { 7922 func.apply(context, args); 7923 } 7924 }; 7925 var callNow = immediate && !timeout; 7926 clearTimeout(timeout); 7927 timeout = setTimeout(later, wait); 7928 7929 if (callNow) { 7930 func.apply(context, args); 7931 } 7932 }; 7933 } 7934 7935 function isObjectEmpty(instance) { 7936 return Object.getOwnPropertyNames(instance).length <= 0; 7937 } 7938 7939 function splitEvents(events, id) { 7940 var rwindow = /^((after|before)print|(before)?unload|hashchange|message|o(ff|n)line|page(hide|show)|popstate|resize|storage)\b/; 7941 7942 var ret = { d: [], w: [] }; 7943 (events || '').split(' ').forEach(function (v) { 7944 var eventName = '' + v + (id ? '.' + id : ''); 7945 7946 if (eventName.startsWith('.')) { 7947 ret.d.push(eventName); 7948 ret.w.push(eventName); 7949 } else { 7950 ret[rwindow.test(v) ? 'w' : 'd'].push(eventName); 7951 } 7952 }); 7953 7954 ret.d = ret.d.join(' '); 7955 ret.w = ret.w.join(' '); 7956 return ret; 7957 } 7958 7959 function createEvent(eventName, target) { 7960 7961 if (typeof eventName !== 'string') { 7962 throw new Error('Event name must be a string'); 7963 } 7964 7965 var eventFrags = eventName.match(/([a-z]+\.([a-z]+))/i), 7966 detail = { 7967 target: target 7968 }; 7969 7970 if (eventFrags !== null) { 7971 eventName = eventFrags[1]; 7972 detail.namespace = eventFrags[2]; 7973 } 7974 7975 return new window.CustomEvent(eventName, { 7976 detail: detail 7977 }); 7978 } 7979 7980 function isNodeAfter(sourceNode, targetNode) { 7981 7982 return !!(sourceNode && targetNode && sourceNode.compareDocumentPosition(targetNode) & 2); 7983 } 7984 7985 function isString(value) { 7986 return typeof value === 'string'; 7987 } 7988 7989 _mejs2.default.Utils = _mejs2.default.Utils || {}; 7990 _mejs2.default.Utils.escapeHTML = escapeHTML; 7991 _mejs2.default.Utils.debounce = debounce; 7992 _mejs2.default.Utils.isObjectEmpty = isObjectEmpty; 7993 _mejs2.default.Utils.splitEvents = splitEvents; 7994 _mejs2.default.Utils.createEvent = createEvent; 7995 _mejs2.default.Utils.isNodeAfter = isNodeAfter; 7996 _mejs2.default.Utils.isString = isString; 7997 7998 },{"7":7}],28:[function(_dereq_,module,exports){ 7999 'use strict'; 8000 8001 Object.defineProperty(exports, "__esModule", { 8002 value: true 8003 }); 8004 exports.typeChecks = undefined; 8005 exports.absolutizeUrl = absolutizeUrl; 8006 exports.formatType = formatType; 8007 exports.getMimeFromType = getMimeFromType; 8008 exports.getTypeFromFile = getTypeFromFile; 8009 exports.getExtension = getExtension; 8010 exports.normalizeExtension = normalizeExtension; 8011 8012 var _mejs = _dereq_(7); 8013 8014 var _mejs2 = _interopRequireDefault(_mejs); 8015 8016 var _general = _dereq_(27); 8017 8018 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8019 8020 var typeChecks = exports.typeChecks = []; 8021 8022 function absolutizeUrl(url) { 8023 8024 if (typeof url !== 'string') { 8025 throw new Error('`url` argument must be a string'); 8026 } 8027 8028 var el = document.createElement('div'); 8029 el.innerHTML = '<a href="' + (0, _general.escapeHTML)(url) + '">x</a>'; 8030 return el.firstChild.href; 8031 } 8032 8033 function formatType(url) { 8034 var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 8035 8036 return url && !type ? getTypeFromFile(url) : type; 8037 } 8038 8039 function getMimeFromType(type) { 8040 8041 if (typeof type !== 'string') { 8042 throw new Error('`type` argument must be a string'); 8043 } 8044 8045 return type && type.indexOf(';') > -1 ? type.substr(0, type.indexOf(';')) : type; 8046 } 8047 8048 function getTypeFromFile(url) { 8049 8050 if (typeof url !== 'string') { 8051 throw new Error('`url` argument must be a string'); 8052 } 8053 8054 for (var i = 0, total = typeChecks.length; i < total; i++) { 8055 var type = typeChecks[i](url); 8056 8057 if (type) { 8058 return type; 8059 } 8060 } 8061 8062 var ext = getExtension(url), 8063 normalizedExt = normalizeExtension(ext); 8064 8065 var mime = 'video/mp4'; 8066 8067 if (normalizedExt) { 8068 if (~['mp4', 'm4v', 'ogg', 'ogv', 'webm', 'flv', 'mpeg', 'mov'].indexOf(normalizedExt)) { 8069 mime = 'video/' + normalizedExt; 8070 } else if (~['mp3', 'oga', 'wav', 'mid', 'midi'].indexOf(normalizedExt)) { 8071 mime = 'audio/' + normalizedExt; 8072 } 8073 } 8074 8075 return mime; 8076 } 8077 8078 function getExtension(url) { 8079 8080 if (typeof url !== 'string') { 8081 throw new Error('`url` argument must be a string'); 8082 } 8083 8084 var baseUrl = url.split('?')[0], 8085 baseName = baseUrl.split('\\').pop().split('/').pop(); 8086 return ~baseName.indexOf('.') ? baseName.substring(baseName.lastIndexOf('.') + 1) : ''; 8087 } 8088 8089 function normalizeExtension(extension) { 8090 8091 if (typeof extension !== 'string') { 8092 throw new Error('`extension` argument must be a string'); 8093 } 8094 8095 switch (extension) { 8096 case 'mp4': 8097 case 'm4v': 8098 return 'mp4'; 8099 case 'webm': 8100 case 'webma': 8101 case 'webmv': 8102 return 'webm'; 8103 case 'ogg': 8104 case 'oga': 8105 case 'ogv': 8106 return 'ogg'; 8107 default: 8108 return extension; 8109 } 8110 } 8111 8112 _mejs2.default.Utils = _mejs2.default.Utils || {}; 8113 _mejs2.default.Utils.typeChecks = typeChecks; 8114 _mejs2.default.Utils.absolutizeUrl = absolutizeUrl; 8115 _mejs2.default.Utils.formatType = formatType; 8116 _mejs2.default.Utils.getMimeFromType = getMimeFromType; 8117 _mejs2.default.Utils.getTypeFromFile = getTypeFromFile; 8118 _mejs2.default.Utils.getExtension = getExtension; 8119 _mejs2.default.Utils.normalizeExtension = normalizeExtension; 8120 8121 },{"27":27,"7":7}],29:[function(_dereq_,module,exports){ 8122 'use strict'; 8123 8124 var _document = _dereq_(2); 8125 8126 var _document2 = _interopRequireDefault(_document); 8127 8128 var _promisePolyfill = _dereq_(4); 8129 8130 var _promisePolyfill2 = _interopRequireDefault(_promisePolyfill); 8131 8132 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8133 8134 (function (arr) { 8135 arr.forEach(function (item) { 8136 if (item.hasOwnProperty('remove')) { 8137 return; 8138 } 8139 Object.defineProperty(item, 'remove', { 8140 configurable: true, 8141 enumerable: true, 8142 writable: true, 8143 value: function remove() { 8144 this.parentNode.removeChild(this); 8145 } 8146 }); 8147 }); 8148 })([Element.prototype, CharacterData.prototype, DocumentType.prototype]); 8149 8150 (function () { 8151 8152 if (typeof window.CustomEvent === 'function') { 8153 return false; 8154 } 8155 8156 function CustomEvent(event, params) { 8157 params = params || { bubbles: false, cancelable: false, detail: undefined }; 8158 var evt = _document2.default.createEvent('CustomEvent'); 8159 evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); 8160 return evt; 8161 } 8162 8163 CustomEvent.prototype = window.Event.prototype; 8164 window.CustomEvent = CustomEvent; 8165 })(); 8166 8167 if (typeof Object.assign !== 'function') { 8168 Object.assign = function (target) { 8169 8170 if (target === null || target === undefined) { 8171 throw new TypeError('Cannot convert undefined or null to object'); 8172 } 8173 8174 var to = Object(target); 8175 8176 for (var index = 1, total = arguments.length; index < total; index++) { 8177 var nextSource = arguments[index]; 8178 8179 if (nextSource !== null) { 8180 for (var nextKey in nextSource) { 8181 if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { 8182 to[nextKey] = nextSource[nextKey]; 8183 } 8184 } 8185 } 8186 } 8187 return to; 8188 }; 8189 } 8190 8191 if (!String.prototype.startsWith) { 8192 String.prototype.startsWith = function (searchString, position) { 8193 position = position || 0; 8194 return this.substr(position, searchString.length) === searchString; 8195 }; 8196 } 8197 8198 if (!Element.prototype.matches) { 8199 Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector || function (s) { 8200 var matches = (this.document || this.ownerDocument).querySelectorAll(s), 8201 i = matches.length - 1; 8202 while (--i >= 0 && matches.item(i) !== this) {} 8203 return i > -1; 8204 }; 8205 } 8206 8207 if (window.Element && !Element.prototype.closest) { 8208 Element.prototype.closest = function (s) { 8209 var matches = (this.document || this.ownerDocument).querySelectorAll(s), 8210 i = void 0, 8211 el = this; 8212 do { 8213 i = matches.length; 8214 while (--i >= 0 && matches.item(i) !== el) {} 8215 } while (i < 0 && (el = el.parentElement)); 8216 return el; 8217 }; 8218 } 8219 8220 (function () { 8221 var lastTime = 0; 8222 var vendors = ['ms', 'moz', 'webkit', 'o']; 8223 for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { 8224 window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; 8225 window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame']; 8226 } 8227 8228 if (!window.requestAnimationFrame) window.requestAnimationFrame = function (callback) { 8229 var currTime = new Date().getTime(); 8230 var timeToCall = Math.max(0, 16 - (currTime - lastTime)); 8231 var id = window.setTimeout(function () { 8232 callback(currTime + timeToCall); 8233 }, timeToCall); 8234 lastTime = currTime + timeToCall; 8235 return id; 8236 }; 8237 8238 if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function (id) { 8239 clearTimeout(id); 8240 }; 8241 })(); 8242 8243 if (/firefox/i.test(navigator.userAgent)) { 8244 var getComputedStyle = window.getComputedStyle; 8245 window.getComputedStyle = function (el, pseudoEl) { 8246 var t = getComputedStyle(el, pseudoEl); 8247 return t === null ? { getPropertyValue: function getPropertyValue() {} } : t; 8248 }; 8249 } 8250 8251 if (!window.Promise) { 8252 window.Promise = _promisePolyfill2.default; 8253 } 8254 8255 (function (constructor) { 8256 if (constructor && constructor.prototype && constructor.prototype.children === null) { 8257 Object.defineProperty(constructor.prototype, 'children', { 8258 get: function get() { 8259 var i = 0, 8260 node = void 0, 8261 nodes = this.childNodes, 8262 children = []; 8263 while (node = nodes[i++]) { 8264 if (node.nodeType === 1) { 8265 children.push(node); 8266 } 8267 } 8268 return children; 8269 } 8270 }); 8271 } 8272 })(window.Node || window.Element); 8273 8274 },{"2":2,"4":4}],30:[function(_dereq_,module,exports){ 8275 'use strict'; 8276 8277 Object.defineProperty(exports, "__esModule", { 8278 value: true 8279 }); 8280 exports.isDropFrame = isDropFrame; 8281 exports.secondsToTimeCode = secondsToTimeCode; 8282 exports.timeCodeToSeconds = timeCodeToSeconds; 8283 exports.calculateTimeFormat = calculateTimeFormat; 8284 exports.convertSMPTEtoSeconds = convertSMPTEtoSeconds; 8285 8286 var _mejs = _dereq_(7); 8287 8288 var _mejs2 = _interopRequireDefault(_mejs); 8289 8290 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 8291 8292 function isDropFrame() { 8293 var fps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 25; 8294 8295 return !(fps % 1 === 0); 8296 } 8297 function secondsToTimeCode(time) { 8298 var forceHours = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 8299 var showFrameCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 8300 var fps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 25; 8301 var secondsDecimalLength = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; 8302 var timeFormat = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 'hh:mm:ss'; 8303 8304 8305 time = !time || typeof time !== 'number' || time < 0 ? 0 : time; 8306 8307 var dropFrames = Math.round(fps * 0.066666), 8308 timeBase = Math.round(fps), 8309 framesPer24Hours = Math.round(fps * 3600) * 24, 8310 framesPer10Minutes = Math.round(fps * 600), 8311 frameSep = isDropFrame(fps) ? ';' : ':', 8312 hours = void 0, 8313 minutes = void 0, 8314 seconds = void 0, 8315 frames = void 0, 8316 f = Math.round(time * fps); 8317 8318 if (isDropFrame(fps)) { 8319 8320 if (f < 0) { 8321 f = framesPer24Hours + f; 8322 } 8323 8324 f = f % framesPer24Hours; 8325 8326 var d = Math.floor(f / framesPer10Minutes); 8327 var m = f % framesPer10Minutes; 8328 f = f + dropFrames * 9 * d; 8329 if (m > dropFrames) { 8330 f = f + dropFrames * Math.floor((m - dropFrames) / Math.round(timeBase * 60 - dropFrames)); 8331 } 8332 8333 var timeBaseDivision = Math.floor(f / timeBase); 8334 8335 hours = Math.floor(Math.floor(timeBaseDivision / 60) / 60); 8336 minutes = Math.floor(timeBaseDivision / 60) % 60; 8337 8338 if (showFrameCount) { 8339 seconds = timeBaseDivision % 60; 8340 } else { 8341 seconds = Math.floor(f / timeBase % 60).toFixed(secondsDecimalLength); 8342 } 8343 } else { 8344 hours = Math.floor(time / 3600) % 24; 8345 minutes = Math.floor(time / 60) % 60; 8346 if (showFrameCount) { 8347 seconds = Math.floor(time % 60); 8348 } else { 8349 seconds = Math.floor(time % 60).toFixed(secondsDecimalLength); 8350 } 8351 } 8352 hours = hours <= 0 ? 0 : hours; 8353 minutes = minutes <= 0 ? 0 : minutes; 8354 seconds = seconds <= 0 ? 0 : seconds; 8355 8356 seconds = seconds === 60 ? 0 : seconds; 8357 minutes = minutes === 60 ? 0 : minutes; 8358 8359 var timeFormatFrags = timeFormat.split(':'); 8360 var timeFormatSettings = {}; 8361 for (var i = 0, total = timeFormatFrags.length; i < total; ++i) { 8362 var unique = ''; 8363 for (var j = 0, t = timeFormatFrags[i].length; j < t; j++) { 8364 if (unique.indexOf(timeFormatFrags[i][j]) < 0) { 8365 unique += timeFormatFrags[i][j]; 8366 } 8367 } 8368 if (~['f', 's', 'm', 'h'].indexOf(unique)) { 8369 timeFormatSettings[unique] = timeFormatFrags[i].length; 8370 } 8371 } 8372 8373 var result = forceHours || hours > 0 ? (hours < 10 && timeFormatSettings.h > 1 ? '0' + hours : hours) + ':' : ''; 8374 result += (minutes < 10 && timeFormatSettings.m > 1 ? '0' + minutes : minutes) + ':'; 8375 result += '' + (seconds < 10 && timeFormatSettings.s > 1 ? '0' + seconds : seconds); 8376 8377 if (showFrameCount) { 8378 frames = (f % timeBase).toFixed(0); 8379 frames = frames <= 0 ? 0 : frames; 8380 result += frames < 10 && timeFormatSettings.f ? frameSep + '0' + frames : '' + frameSep + frames; 8381 } 8382 8383 return result; 8384 } 8385 8386 function timeCodeToSeconds(time) { 8387 var fps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25; 8388 8389 8390 if (typeof time !== 'string') { 8391 throw new TypeError('Time must be a string'); 8392 } 8393 8394 if (time.indexOf(';') > 0) { 8395 time = time.replace(';', ':'); 8396 } 8397 8398 if (!/\d{2}(\:\d{2}){0,3}/i.test(time)) { 8399 throw new TypeError('Time code must have the format `00:00:00`'); 8400 } 8401 8402 var parts = time.split(':'); 8403 8404 var output = void 0, 8405 hours = 0, 8406 minutes = 0, 8407 seconds = 0, 8408 frames = 0, 8409 totalMinutes = 0, 8410 dropFrames = Math.round(fps * 0.066666), 8411 timeBase = Math.round(fps), 8412 hFrames = timeBase * 3600, 8413 mFrames = timeBase * 60; 8414 8415 switch (parts.length) { 8416 default: 8417 case 1: 8418 seconds = parseInt(parts[0], 10); 8419 break; 8420 case 2: 8421 minutes = parseInt(parts[0], 10); 8422 seconds = parseInt(parts[1], 10); 8423 break; 8424 case 3: 8425 hours = parseInt(parts[0], 10); 8426 minutes = parseInt(parts[1], 10); 8427 seconds = parseInt(parts[2], 10); 8428 break; 8429 case 4: 8430 hours = parseInt(parts[0], 10); 8431 minutes = parseInt(parts[1], 10); 8432 seconds = parseInt(parts[2], 10); 8433 frames = parseInt(parts[3], 10); 8434 break; 8435 } 8436 8437 if (isDropFrame(fps)) { 8438 totalMinutes = 60 * hours + minutes; 8439 output = hFrames * hours + mFrames * minutes + timeBase * seconds + frames - dropFrames * (totalMinutes - Math.floor(totalMinutes / 10)); 8440 } else { 8441 output = (hFrames * hours + mFrames * minutes + fps * seconds + frames) / fps; 8442 } 8443 8444 return parseFloat(output.toFixed(3)); 8445 } 8446 8447 function calculateTimeFormat(time, options) { 8448 var fps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 25; 8449 8450 8451 time = !time || typeof time !== 'number' || time < 0 ? 0 : time; 8452 8453 var hours = Math.floor(time / 3600) % 24, 8454 minutes = Math.floor(time / 60) % 60, 8455 seconds = Math.floor(time % 60), 8456 frames = Math.floor((time % 1 * fps).toFixed(3)), 8457 lis = [[frames, 'f'], [seconds, 's'], [minutes, 'm'], [hours, 'h']]; 8458 8459 var format = options.timeFormat, 8460 firstTwoPlaces = format[1] === format[0], 8461 separatorIndex = firstTwoPlaces ? 2 : 1, 8462 separator = format.length < separatorIndex ? format[separatorIndex] : ':', 8463 firstChar = format[0], 8464 required = false; 8465 8466 for (var i = 0, len = lis.length; i < len; i++) { 8467 if (~format.indexOf(lis[i][1])) { 8468 required = true; 8469 } else if (required) { 8470 var hasNextValue = false; 8471 for (var j = i; j < len; j++) { 8472 if (lis[j][0] > 0) { 8473 hasNextValue = true; 8474 break; 8475 } 8476 } 8477 8478 if (!hasNextValue) { 8479 break; 8480 } 8481 8482 if (!firstTwoPlaces) { 8483 format = firstChar + format; 8484 } 8485 format = lis[i][1] + separator + format; 8486 if (firstTwoPlaces) { 8487 format = lis[i][1] + format; 8488 } 8489 firstChar = lis[i][1]; 8490 } 8491 } 8492 8493 options.timeFormat = format; 8494 } 8495 8496 function convertSMPTEtoSeconds(SMPTE) { 8497 8498 if (typeof SMPTE !== 'string') { 8499 throw new TypeError('Argument must be a string value'); 8500 } 8501 8502 SMPTE = SMPTE.replace(',', '.'); 8503 8504 var decimalLen = ~SMPTE.indexOf('.') ? SMPTE.split('.')[1].length : 0; 8505 8506 var secs = 0, 8507 multiplier = 1; 8508 8509 SMPTE = SMPTE.split(':').reverse(); 8510 8511 for (var i = 0, total = SMPTE.length; i < total; i++) { 8512 multiplier = 1; 8513 if (i > 0) { 8514 multiplier = Math.pow(60, i); 8515 } 8516 secs += Number(SMPTE[i]) * multiplier; 8517 } 8518 return Number(secs.toFixed(decimalLen)); 8519 } 8520 8521 _mejs2.default.Utils = _mejs2.default.Utils || {}; 8522 _mejs2.default.Utils.secondsToTimeCode = secondsToTimeCode; 8523 _mejs2.default.Utils.timeCodeToSeconds = timeCodeToSeconds; 8524 _mejs2.default.Utils.calculateTimeFormat = calculateTimeFormat; 8525 _mejs2.default.Utils.convertSMPTEtoSeconds = convertSMPTEtoSeconds; 8526 8527 },{"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: Sun Dec 22 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |