(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["Clappr"] = factory();
else
root["Clappr"] = factory();
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "dist/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/main.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./node_modules/babel-runtime/core-js/array/from.js":
/*!**********************************************************!*\
!*** ./node_modules/babel-runtime/core-js/array/from.js ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(/*! core-js/library/fn/array/from */ "./node_modules/core-js/library/fn/array/from.js"), __esModule: true };
/***/ }),
/***/ "./node_modules/babel-runtime/core-js/get-iterator.js":
/*!************************************************************!*\
!*** ./node_modules/babel-runtime/core-js/get-iterator.js ***!
\************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(/*! core-js/library/fn/get-iterator */ "./node_modules/core-js/library/fn/get-iterator.js"), __esModule: true };
/***/ }),
/***/ "./node_modules/babel-runtime/core-js/json/stringify.js":
/*!**************************************************************!*\
!*** ./node_modules/babel-runtime/core-js/json/stringify.js ***!
\**************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(/*! core-js/library/fn/json/stringify */ "./node_modules/core-js/library/fn/json/stringify.js"), __esModule: true };
/***/ }),
/***/ "./node_modules/babel-runtime/core-js/object/assign.js":
/*!*************************************************************!*\
!*** ./node_modules/babel-runtime/core-js/object/assign.js ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(/*! core-js/library/fn/object/assign */ "./node_modules/core-js/library/fn/object/assign.js"), __esModule: true };
/***/ }),
/***/ "./node_modules/babel-runtime/core-js/object/create.js":
/*!*************************************************************!*\
!*** ./node_modules/babel-runtime/core-js/object/create.js ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(/*! core-js/library/fn/object/create */ "./node_modules/core-js/library/fn/object/create.js"), __esModule: true };
/***/ }),
/***/ "./node_modules/babel-runtime/core-js/object/define-property.js":
/*!**********************************************************************!*\
!*** ./node_modules/babel-runtime/core-js/object/define-property.js ***!
\**********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(/*! core-js/library/fn/object/define-property */ "./node_modules/core-js/library/fn/object/define-property.js"), __esModule: true };
/***/ }),
/***/ "./node_modules/babel-runtime/core-js/object/get-own-property-descriptor.js":
/*!**********************************************************************************!*\
!*** ./node_modules/babel-runtime/core-js/object/get-own-property-descriptor.js ***!
\**********************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(/*! core-js/library/fn/object/get-own-property-descriptor */ "./node_modules/core-js/library/fn/object/get-own-property-descriptor.js"), __esModule: true };
/***/ }),
/***/ "./node_modules/babel-runtime/core-js/object/keys.js":
/*!***********************************************************!*\
!*** ./node_modules/babel-runtime/core-js/object/keys.js ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(/*! core-js/library/fn/object/keys */ "./node_modules/core-js/library/fn/object/keys.js"), __esModule: true };
/***/ }),
/***/ "./node_modules/babel-runtime/core-js/object/set-prototype-of.js":
/*!***********************************************************************!*\
!*** ./node_modules/babel-runtime/core-js/object/set-prototype-of.js ***!
\***********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(/*! core-js/library/fn/object/set-prototype-of */ "./node_modules/core-js/library/fn/object/set-prototype-of.js"), __esModule: true };
/***/ }),
/***/ "./node_modules/babel-runtime/core-js/symbol.js":
/*!******************************************************!*\
!*** ./node_modules/babel-runtime/core-js/symbol.js ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(/*! core-js/library/fn/symbol */ "./node_modules/core-js/library/fn/symbol/index.js"), __esModule: true };
/***/ }),
/***/ "./node_modules/babel-runtime/core-js/symbol/iterator.js":
/*!***************************************************************!*\
!*** ./node_modules/babel-runtime/core-js/symbol/iterator.js ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = { "default": __webpack_require__(/*! core-js/library/fn/symbol/iterator */ "./node_modules/core-js/library/fn/symbol/iterator.js"), __esModule: true };
/***/ }),
/***/ "./node_modules/babel-runtime/helpers/classCallCheck.js":
/*!**************************************************************!*\
!*** ./node_modules/babel-runtime/helpers/classCallCheck.js ***!
\**************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
/***/ }),
/***/ "./node_modules/babel-runtime/helpers/createClass.js":
/*!***********************************************************!*\
!*** ./node_modules/babel-runtime/helpers/createClass.js ***!
\***********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _defineProperty = __webpack_require__(/*! ../core-js/object/define-property */ "./node_modules/babel-runtime/core-js/object/define-property.js");
var _defineProperty2 = _interopRequireDefault(_defineProperty);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = 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;
(0, _defineProperty2.default)(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
/***/ }),
/***/ "./node_modules/babel-runtime/helpers/extends.js":
/*!*******************************************************!*\
!*** ./node_modules/babel-runtime/helpers/extends.js ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _assign = __webpack_require__(/*! ../core-js/object/assign */ "./node_modules/babel-runtime/core-js/object/assign.js");
var _assign2 = _interopRequireDefault(_assign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _assign2.default || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
/***/ }),
/***/ "./node_modules/babel-runtime/helpers/inherits.js":
/*!********************************************************!*\
!*** ./node_modules/babel-runtime/helpers/inherits.js ***!
\********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _setPrototypeOf = __webpack_require__(/*! ../core-js/object/set-prototype-of */ "./node_modules/babel-runtime/core-js/object/set-prototype-of.js");
var _setPrototypeOf2 = _interopRequireDefault(_setPrototypeOf);
var _create = __webpack_require__(/*! ../core-js/object/create */ "./node_modules/babel-runtime/core-js/object/create.js");
var _create2 = _interopRequireDefault(_create);
var _typeof2 = __webpack_require__(/*! ../helpers/typeof */ "./node_modules/babel-runtime/helpers/typeof.js");
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass)));
}
subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass;
};
/***/ }),
/***/ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js":
/*!*************************************************************************!*\
!*** ./node_modules/babel-runtime/helpers/possibleConstructorReturn.js ***!
\*************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _typeof2 = __webpack_require__(/*! ../helpers/typeof */ "./node_modules/babel-runtime/helpers/typeof.js");
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self;
};
/***/ }),
/***/ "./node_modules/babel-runtime/helpers/toConsumableArray.js":
/*!*****************************************************************!*\
!*** ./node_modules/babel-runtime/helpers/toConsumableArray.js ***!
\*****************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _from = __webpack_require__(/*! ../core-js/array/from */ "./node_modules/babel-runtime/core-js/array/from.js");
var _from2 = _interopRequireDefault(_from);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
arr2[i] = arr[i];
}
return arr2;
} else {
return (0, _from2.default)(arr);
}
};
/***/ }),
/***/ "./node_modules/babel-runtime/helpers/typeof.js":
/*!******************************************************!*\
!*** ./node_modules/babel-runtime/helpers/typeof.js ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _iterator = __webpack_require__(/*! ../core-js/symbol/iterator */ "./node_modules/babel-runtime/core-js/symbol/iterator.js");
var _iterator2 = _interopRequireDefault(_iterator);
var _symbol = __webpack_require__(/*! ../core-js/symbol */ "./node_modules/babel-runtime/core-js/symbol.js");
var _symbol2 = _interopRequireDefault(_symbol);
var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
return typeof obj === "undefined" ? "undefined" : _typeof(obj);
} : function (obj) {
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
};
/***/ }),
/***/ "./node_modules/clappr-zepto/zepto.js":
/*!********************************************!*\
!*** ./node_modules/clappr-zepto/zepto.js ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/* Zepto v1.2.0 - zepto ajax callbacks deferred event ie selector - zeptojs.com/license */
var Zepto = (function() {
var undefined, key, $, classList, emptyArray = [], concat = emptyArray.concat, filter = emptyArray.filter, slice = emptyArray.slice,
document = window.document,
elementDisplay = {}, classCache = {},
cssNumber = { 'column-count': 1, 'columns': 1, 'font-weight': 1, 'line-height': 1,'opacity': 1, 'z-index': 1, 'zoom': 1 },
fragmentRE = /^\s*<(\w+|!)[^>]*>/,
singleTagRE = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
tagExpanderRE = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
rootNodeRE = /^(?:body|html)$/i,
capitalRE = /([A-Z])/g,
// special attributes that should be get/set via method calls
methodAttributes = ['val', 'css', 'html', 'text', 'data', 'width', 'height', 'offset'],
adjacencyOperators = [ 'after', 'prepend', 'before', 'append' ],
table = document.createElement('table'),
tableRow = document.createElement('tr'),
containers = {
'tr': document.createElement('tbody'),
'tbody': table, 'thead': table, 'tfoot': table,
'td': tableRow, 'th': tableRow,
'*': document.createElement('div')
},
readyRE = /complete|loaded|interactive/,
simpleSelectorRE = /^[\w-]*$/,
class2type = {},
toString = class2type.toString,
zepto = {},
camelize, uniq,
tempParent = document.createElement('div'),
propMap = {
'tabindex': 'tabIndex',
'readonly': 'readOnly',
'for': 'htmlFor',
'class': 'className',
'maxlength': 'maxLength',
'cellspacing': 'cellSpacing',
'cellpadding': 'cellPadding',
'rowspan': 'rowSpan',
'colspan': 'colSpan',
'usemap': 'useMap',
'frameborder': 'frameBorder',
'contenteditable': 'contentEditable'
},
isArray = Array.isArray ||
function(object){ return object instanceof Array }
zepto.matches = function(element, selector) {
if (!selector || !element || element.nodeType !== 1) return false
var matchesSelector = element.matches || element.webkitMatchesSelector ||
element.mozMatchesSelector || element.oMatchesSelector ||
element.matchesSelector
if (matchesSelector) return matchesSelector.call(element, selector)
// fall back to performing a selector:
var match, parent = element.parentNode, temp = !parent
if (temp) (parent = tempParent).appendChild(element)
match = ~zepto.qsa(parent, selector).indexOf(element)
temp && tempParent.removeChild(element)
return match
}
function type(obj) {
return obj == null ? String(obj) :
class2type[toString.call(obj)] || "object"
}
function isFunction(value) { return type(value) == "function" }
function isWindow(obj) { return obj != null && obj == obj.window }
function isDocument(obj) { return obj != null && obj.nodeType == obj.DOCUMENT_NODE }
function isObject(obj) { return type(obj) == "object" }
function isPlainObject(obj) {
return isObject(obj) && !isWindow(obj) && Object.getPrototypeOf(obj) == Object.prototype
}
function likeArray(obj) {
var length = !!obj && 'length' in obj && obj.length,
type = $.type(obj)
return 'function' != type && !isWindow(obj) && (
'array' == type || length === 0 ||
(typeof length == 'number' && length > 0 && (length - 1) in obj)
)
}
function compact(array) { return filter.call(array, function(item){ return item != null }) }
function flatten(array) { return array.length > 0 ? $.fn.concat.apply([], array) : array }
camelize = function(str){ return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) }
function dasherize(str) {
return str.replace(/::/g, '/')
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
.replace(/_/g, '-')
.toLowerCase()
}
uniq = function(array){ return filter.call(array, function(item, idx){ return array.indexOf(item) == idx }) }
function classRE(name) {
return name in classCache ?
classCache[name] : (classCache[name] = new RegExp('(^|\\s)' + name + '(\\s|$)'))
}
function maybeAddPx(name, value) {
return (typeof value == "number" && !cssNumber[dasherize(name)]) ? value + "px" : value
}
function defaultDisplay(nodeName) {
var element, display
if (!elementDisplay[nodeName]) {
element = document.createElement(nodeName)
document.body.appendChild(element)
display = getComputedStyle(element, '').getPropertyValue("display")
element.parentNode.removeChild(element)
display == "none" && (display = "block")
elementDisplay[nodeName] = display
}
return elementDisplay[nodeName]
}
function children(element) {
return 'children' in element ?
slice.call(element.children) :
$.map(element.childNodes, function(node){ if (node.nodeType == 1) return node })
}
function Z(dom, selector) {
var i, len = dom ? dom.length : 0
for (i = 0; i < len; i++) this[i] = dom[i]
this.length = len
this.selector = selector || ''
}
// `$.zepto.fragment` takes a html string and an optional tag name
// to generate DOM nodes from the given html string.
// The generated DOM nodes are returned as an array.
// This function can be overridden in plugins for example to make
// it compatible with browsers that don't support the DOM fully.
zepto.fragment = function(html, name, properties) {
var dom, nodes, container
// A special case optimization for a single tag
if (singleTagRE.test(html)) dom = $(document.createElement(RegExp.$1))
if (!dom) {
if (html.replace) html = html.replace(tagExpanderRE, "<$1>$2>")
if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
if (!(name in containers)) name = '*'
container = containers[name]
container.innerHTML = '' + html
dom = $.each(slice.call(container.childNodes), function(){
container.removeChild(this)
})
}
if (isPlainObject(properties)) {
nodes = $(dom)
$.each(properties, function(key, value) {
if (methodAttributes.indexOf(key) > -1) nodes[key](value)
else nodes.attr(key, value)
})
}
return dom
}
// `$.zepto.Z` swaps out the prototype of the given `dom` array
// of nodes with `$.fn` and thus supplying all the Zepto functions
// to the array. This method can be overridden in plugins.
zepto.Z = function(dom, selector) {
return new Z(dom, selector)
}
// `$.zepto.isZ` should return `true` if the given object is a Zepto
// collection. This method can be overridden in plugins.
zepto.isZ = function(object) {
return object instanceof zepto.Z
}
// `$.zepto.init` is Zepto's counterpart to jQuery's `$.fn.init` and
// takes a CSS selector and an optional context (and handles various
// special cases).
// This method can be overridden in plugins.
zepto.init = function(selector, context) {
var dom
// If nothing given, return an empty Zepto collection
if (!selector) return zepto.Z()
// Optimize for string selectors
else if (typeof selector == 'string') {
selector = selector.trim()
// If it's a html fragment, create nodes from it
// Note: In both Chrome 21 and Firefox 15, DOM error 12
// is thrown if the fragment doesn't begin with <
if (selector[0] == '<' && fragmentRE.test(selector))
dom = zepto.fragment(selector, RegExp.$1, context), selector = null
// If there's a context, create a collection on that context first, and select
// nodes from there
else if (context !== undefined) return $(context).find(selector)
// If it's a CSS selector, use it to select nodes.
else dom = zepto.qsa(document, selector)
}
// If a function is given, call it when the DOM is ready
else if (isFunction(selector)) return $(document).ready(selector)
// If a Zepto collection is given, just return it
else if (zepto.isZ(selector)) return selector
else {
// normalize array if an array of nodes is given
if (isArray(selector)) dom = compact(selector)
// Wrap DOM nodes.
else if (isObject(selector))
dom = [selector], selector = null
// If it's a html fragment, create nodes from it
else if (fragmentRE.test(selector))
dom = zepto.fragment(selector.trim(), RegExp.$1, context), selector = null
// If there's a context, create a collection on that context first, and select
// nodes from there
else if (context !== undefined) return $(context).find(selector)
// And last but no least, if it's a CSS selector, use it to select nodes.
else dom = zepto.qsa(document, selector)
}
// create a new Zepto collection from the nodes found
return zepto.Z(dom, selector)
}
// `$` will be the base `Zepto` object. When calling this
// function just call `$.zepto.init, which makes the implementation
// details of selecting nodes and creating Zepto collections
// patchable in plugins.
$ = function(selector, context){
return zepto.init(selector, context)
}
function extend(target, source, deep) {
for (key in source)
if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
if (isPlainObject(source[key]) && !isPlainObject(target[key]))
target[key] = {}
if (isArray(source[key]) && !isArray(target[key]))
target[key] = []
extend(target[key], source[key], deep)
}
else if (source[key] !== undefined) target[key] = source[key]
}
// Copy all but undefined properties from one or more
// objects to the `target` object.
$.extend = function(target){
var deep, args = slice.call(arguments, 1)
if (typeof target == 'boolean') {
deep = target
target = args.shift()
}
args.forEach(function(arg){ extend(target, arg, deep) })
return target
}
// `$.zepto.qsa` is Zepto's CSS selector implementation which
// uses `document.querySelectorAll` and optimizes for some special cases, like `#id`.
// This method can be overridden in plugins.
zepto.qsa = function(element, selector){
var found,
maybeID = selector[0] == '#',
maybeClass = !maybeID && selector[0] == '.',
nameOnly = maybeID || maybeClass ? selector.slice(1) : selector, // Ensure that a 1 char tag name still gets checked
isSimple = simpleSelectorRE.test(nameOnly)
return (element.getElementById && isSimple && maybeID) ? // Safari DocumentFragment doesn't have getElementById
( (found = element.getElementById(nameOnly)) ? [found] : [] ) :
(element.nodeType !== 1 && element.nodeType !== 9 && element.nodeType !== 11) ? [] :
slice.call(
isSimple && !maybeID && element.getElementsByClassName ? // DocumentFragment doesn't have getElementsByClassName/TagName
maybeClass ? element.getElementsByClassName(nameOnly) : // If it's simple, it could be a class
element.getElementsByTagName(selector) : // Or a tag
element.querySelectorAll(selector) // Or it's not simple, and we need to query all
)
}
function filtered(nodes, selector) {
return selector == null ? $(nodes) : $(nodes).filter(selector)
}
$.contains = document.documentElement.contains ?
function(parent, node) {
return parent !== node && parent.contains(node)
} :
function(parent, node) {
while (node && (node = node.parentNode))
if (node === parent) return true
return false
}
function funcArg(context, arg, idx, payload) {
return isFunction(arg) ? arg.call(context, idx, payload) : arg
}
function setAttribute(node, name, value) {
value == null ? node.removeAttribute(name) : node.setAttribute(name, value)
}
// access className property while respecting SVGAnimatedString
function className(node, value){
var klass = node.className || '',
svg = klass && klass.baseVal !== undefined
if (value === undefined) return svg ? klass.baseVal : klass
svg ? (klass.baseVal = value) : (node.className = value)
}
// "true" => true
// "false" => false
// "null" => null
// "42" => 42
// "42.5" => 42.5
// "08" => "08"
// JSON => parse if valid
// String => self
function deserializeValue(value) {
try {
return value ?
value == "true" ||
( value == "false" ? false :
value == "null" ? null :
+value + "" == value ? +value :
/^[\[\{]/.test(value) ? $.parseJSON(value) :
value )
: value
} catch(e) {
return value
}
}
$.type = type
$.isFunction = isFunction
$.isWindow = isWindow
$.isArray = isArray
$.isPlainObject = isPlainObject
$.isEmptyObject = function(obj) {
var name
for (name in obj) return false
return true
}
$.isNumeric = function(val) {
var num = Number(val), type = typeof val
return val != null && type != 'boolean' &&
(type != 'string' || val.length) &&
!isNaN(num) && isFinite(num) || false
}
$.inArray = function(elem, array, i){
return emptyArray.indexOf.call(array, elem, i)
}
$.camelCase = camelize
$.trim = function(str) {
return str == null ? "" : String.prototype.trim.call(str)
}
// plugin compatibility
$.uuid = 0
$.support = { }
$.expr = { }
$.noop = function() {}
$.map = function(elements, callback){
var value, values = [], i, key
if (likeArray(elements))
for (i = 0; i < elements.length; i++) {
value = callback(elements[i], i)
if (value != null) values.push(value)
}
else
for (key in elements) {
value = callback(elements[key], key)
if (value != null) values.push(value)
}
return flatten(values)
}
$.each = function(elements, callback){
var i, key
if (likeArray(elements)) {
for (i = 0; i < elements.length; i++)
if (callback.call(elements[i], i, elements[i]) === false) return elements
} else {
for (key in elements)
if (callback.call(elements[key], key, elements[key]) === false) return elements
}
return elements
}
$.grep = function(elements, callback){
return filter.call(elements, callback)
}
if (window.JSON) $.parseJSON = JSON.parse
// Populate the class2type map
$.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
class2type[ "[object " + name + "]" ] = name.toLowerCase()
})
// Define methods that will be available on all
// Zepto collections
$.fn = {
constructor: zepto.Z,
length: 0,
// Because a collection acts like an array
// copy over these useful array functions.
forEach: emptyArray.forEach,
reduce: emptyArray.reduce,
push: emptyArray.push,
sort: emptyArray.sort,
splice: emptyArray.splice,
indexOf: emptyArray.indexOf,
concat: function(){
var i, value, args = []
for (i = 0; i < arguments.length; i++) {
value = arguments[i]
args[i] = zepto.isZ(value) ? value.toArray() : value
}
return concat.apply(zepto.isZ(this) ? this.toArray() : this, args)
},
// `map` and `slice` in the jQuery API work differently
// from their array counterparts
map: function(fn){
return $($.map(this, function(el, i){ return fn.call(el, i, el) }))
},
slice: function(){
return $(slice.apply(this, arguments))
},
ready: function(callback){
// need to check if document.body exists for IE as that browser reports
// document ready when it hasn't yet created the body element
if (readyRE.test(document.readyState) && document.body) callback($)
else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false)
return this
},
get: function(idx){
return idx === undefined ? slice.call(this) : this[idx >= 0 ? idx : idx + this.length]
},
toArray: function(){ return this.get() },
size: function(){
return this.length
},
remove: function(){
return this.each(function(){
if (this.parentNode != null)
this.parentNode.removeChild(this)
})
},
each: function(callback){
emptyArray.every.call(this, function(el, idx){
return callback.call(el, idx, el) !== false
})
return this
},
filter: function(selector){
if (isFunction(selector)) return this.not(this.not(selector))
return $(filter.call(this, function(element){
return zepto.matches(element, selector)
}))
},
add: function(selector,context){
return $(uniq(this.concat($(selector,context))))
},
is: function(selector){
return this.length > 0 && zepto.matches(this[0], selector)
},
not: function(selector){
var nodes=[]
if (isFunction(selector) && selector.call !== undefined)
this.each(function(idx){
if (!selector.call(this,idx)) nodes.push(this)
})
else {
var excludes = typeof selector == 'string' ? this.filter(selector) :
(likeArray(selector) && isFunction(selector.item)) ? slice.call(selector) : $(selector)
this.forEach(function(el){
if (excludes.indexOf(el) < 0) nodes.push(el)
})
}
return $(nodes)
},
has: function(selector){
return this.filter(function(){
return isObject(selector) ?
$.contains(this, selector) :
$(this).find(selector).size()
})
},
eq: function(idx){
return idx === -1 ? this.slice(idx) : this.slice(idx, + idx + 1)
},
first: function(){
var el = this[0]
return el && !isObject(el) ? el : $(el)
},
last: function(){
var el = this[this.length - 1]
return el && !isObject(el) ? el : $(el)
},
find: function(selector){
var result, $this = this
if (!selector) result = $()
else if (typeof selector == 'object')
result = $(selector).filter(function(){
var node = this
return emptyArray.some.call($this, function(parent){
return $.contains(parent, node)
})
})
else if (this.length == 1) result = $(zepto.qsa(this[0], selector))
else result = this.map(function(){ return zepto.qsa(this, selector) })
return result
},
closest: function(selector, context){
var nodes = [], collection = typeof selector == 'object' && $(selector)
this.each(function(_, node){
while (node && !(collection ? collection.indexOf(node) >= 0 : zepto.matches(node, selector)))
node = node !== context && !isDocument(node) && node.parentNode
if (node && nodes.indexOf(node) < 0) nodes.push(node)
})
return $(nodes)
},
parents: function(selector){
var ancestors = [], nodes = this
while (nodes.length > 0)
nodes = $.map(nodes, function(node){
if ((node = node.parentNode) && !isDocument(node) && ancestors.indexOf(node) < 0) {
ancestors.push(node)
return node
}
})
return filtered(ancestors, selector)
},
parent: function(selector){
return filtered(uniq(this.pluck('parentNode')), selector)
},
children: function(selector){
return filtered(this.map(function(){ return children(this) }), selector)
},
contents: function() {
return this.map(function() { return this.contentDocument || slice.call(this.childNodes) })
},
siblings: function(selector){
return filtered(this.map(function(i, el){
return filter.call(children(el.parentNode), function(child){ return child!==el })
}), selector)
},
empty: function(){
return this.each(function(){ this.innerHTML = '' })
},
// `pluck` is borrowed from Prototype.js
pluck: function(property){
return $.map(this, function(el){ return el[property] })
},
show: function(){
return this.each(function(){
this.style.display == "none" && (this.style.display = '')
if (getComputedStyle(this, '').getPropertyValue("display") == "none")
this.style.display = defaultDisplay(this.nodeName)
})
},
replaceWith: function(newContent){
return this.before(newContent).remove()
},
wrap: function(structure){
var func = isFunction(structure)
if (this[0] && !func)
var dom = $(structure).get(0),
clone = dom.parentNode || this.length > 1
return this.each(function(index){
$(this).wrapAll(
func ? structure.call(this, index) :
clone ? dom.cloneNode(true) : dom
)
})
},
wrapAll: function(structure){
if (this[0]) {
$(this[0]).before(structure = $(structure))
var children
// drill down to the inmost element
while ((children = structure.children()).length) structure = children.first()
$(structure).append(this)
}
return this
},
wrapInner: function(structure){
var func = isFunction(structure)
return this.each(function(index){
var self = $(this), contents = self.contents(),
dom = func ? structure.call(this, index) : structure
contents.length ? contents.wrapAll(dom) : self.append(dom)
})
},
unwrap: function(){
this.parent().each(function(){
$(this).replaceWith($(this).children())
})
return this
},
clone: function(){
return this.map(function(){ return this.cloneNode(true) })
},
hide: function(){
return this.css("display", "none")
},
toggle: function(setting){
return this.each(function(){
var el = $(this)
;(setting === undefined ? el.css("display") == "none" : setting) ? el.show() : el.hide()
})
},
prev: function(selector){ return $(this.pluck('previousElementSibling')).filter(selector || '*') },
next: function(selector){ return $(this.pluck('nextElementSibling')).filter(selector || '*') },
html: function(html){
return 0 in arguments ?
this.each(function(idx){
var originHtml = this.innerHTML
$(this).empty().append( funcArg(this, html, idx, originHtml) )
}) :
(0 in this ? this[0].innerHTML : null)
},
text: function(text){
return 0 in arguments ?
this.each(function(idx){
var newText = funcArg(this, text, idx, this.textContent)
this.textContent = newText == null ? '' : ''+newText
}) :
(0 in this ? this.pluck('textContent').join("") : null)
},
attr: function(name, value){
var result
return (typeof name == 'string' && !(1 in arguments)) ?
(0 in this && this[0].nodeType == 1 && (result = this[0].getAttribute(name)) != null ? result : undefined) :
this.each(function(idx){
if (this.nodeType !== 1) return
if (isObject(name)) for (key in name) setAttribute(this, key, name[key])
else setAttribute(this, name, funcArg(this, value, idx, this.getAttribute(name)))
})
},
removeAttr: function(name){
return this.each(function(){ this.nodeType === 1 && name.split(' ').forEach(function(attribute){
setAttribute(this, attribute)
}, this)})
},
prop: function(name, value){
name = propMap[name] || name
return (1 in arguments) ?
this.each(function(idx){
this[name] = funcArg(this, value, idx, this[name])
}) :
(this[0] && this[0][name])
},
removeProp: function(name){
name = propMap[name] || name
return this.each(function(){ delete this[name] })
},
data: function(name, value){
var attrName = 'data-' + name.replace(capitalRE, '-$1').toLowerCase()
var data = (1 in arguments) ?
this.attr(attrName, value) :
this.attr(attrName)
return data !== null ? deserializeValue(data) : undefined
},
val: function(value){
if (0 in arguments) {
if (value == null) value = ""
return this.each(function(idx){
this.value = funcArg(this, value, idx, this.value)
})
} else {
return this[0] && (this[0].multiple ?
$(this[0]).find('option').filter(function(){ return this.selected }).pluck('value') :
this[0].value)
}
},
offset: function(coordinates){
if (coordinates) return this.each(function(index){
var $this = $(this),
coords = funcArg(this, coordinates, index, $this.offset()),
parentOffset = $this.offsetParent().offset(),
props = {
top: coords.top - parentOffset.top,
left: coords.left - parentOffset.left
}
if ($this.css('position') == 'static') props['position'] = 'relative'
$this.css(props)
})
if (!this.length) return null
if (document.documentElement !== this[0] && !$.contains(document.documentElement, this[0]))
return {top: 0, left: 0}
var obj = this[0].getBoundingClientRect()
return {
left: obj.left + window.pageXOffset,
top: obj.top + window.pageYOffset,
width: Math.round(obj.width),
height: Math.round(obj.height)
}
},
css: function(property, value){
if (arguments.length < 2) {
var element = this[0]
if (typeof property == 'string') {
if (!element) return
return element.style[camelize(property)] || getComputedStyle(element, '').getPropertyValue(property)
} else if (isArray(property)) {
if (!element) return
var props = {}
var computedStyle = getComputedStyle(element, '')
$.each(property, function(_, prop){
props[prop] = (element.style[camelize(prop)] || computedStyle.getPropertyValue(prop))
})
return props
}
}
var css = ''
if (type(property) == 'string') {
if (!value && value !== 0)
this.each(function(){ this.style.removeProperty(dasherize(property)) })
else
css = dasherize(property) + ":" + maybeAddPx(property, value)
} else {
for (key in property)
if (!property[key] && property[key] !== 0)
this.each(function(){ this.style.removeProperty(dasherize(key)) })
else
css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';'
}
return this.each(function(){ this.style.cssText += ';' + css })
},
index: function(element){
return element ? this.indexOf($(element)[0]) : this.parent().children().indexOf(this[0])
},
hasClass: function(name){
if (!name) return false
return emptyArray.some.call(this, function(el){
return this.test(className(el))
}, classRE(name))
},
addClass: function(name){
if (!name) return this
return this.each(function(idx){
if (!('className' in this)) return
classList = []
var cls = className(this), newName = funcArg(this, name, idx, cls)
newName.split(/\s+/g).forEach(function(klass){
if (!$(this).hasClass(klass)) classList.push(klass)
}, this)
classList.length && className(this, cls + (cls ? " " : "") + classList.join(" "))
})
},
removeClass: function(name){
return this.each(function(idx){
if (!('className' in this)) return
if (name === undefined) return className(this, '')
classList = className(this)
funcArg(this, name, idx, classList).split(/\s+/g).forEach(function(klass){
classList = classList.replace(classRE(klass), " ")
})
className(this, classList.trim())
})
},
toggleClass: function(name, when){
if (!name) return this
return this.each(function(idx){
var $this = $(this), names = funcArg(this, name, idx, className(this))
names.split(/\s+/g).forEach(function(klass){
(when === undefined ? !$this.hasClass(klass) : when) ?
$this.addClass(klass) : $this.removeClass(klass)
})
})
},
scrollTop: function(value){
if (!this.length) return
var hasScrollTop = 'scrollTop' in this[0]
if (value === undefined) return hasScrollTop ? this[0].scrollTop : this[0].pageYOffset
return this.each(hasScrollTop ?
function(){ this.scrollTop = value } :
function(){ this.scrollTo(this.scrollX, value) })
},
scrollLeft: function(value){
if (!this.length) return
var hasScrollLeft = 'scrollLeft' in this[0]
if (value === undefined) return hasScrollLeft ? this[0].scrollLeft : this[0].pageXOffset
return this.each(hasScrollLeft ?
function(){ this.scrollLeft = value } :
function(){ this.scrollTo(value, this.scrollY) })
},
position: function() {
if (!this.length) return
var elem = this[0],
// Get *real* offsetParent
offsetParent = this.offsetParent(),
// Get correct offsets
offset = this.offset(),
parentOffset = rootNodeRE.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset()
// Subtract element margins
// note: when an element has margin: auto the offsetLeft and marginLeft
// are the same in Safari causing offset.left to incorrectly be 0
offset.top -= parseFloat( $(elem).css('margin-top') ) || 0
offset.left -= parseFloat( $(elem).css('margin-left') ) || 0
// Add offsetParent borders
parentOffset.top += parseFloat( $(offsetParent[0]).css('border-top-width') ) || 0
parentOffset.left += parseFloat( $(offsetParent[0]).css('border-left-width') ) || 0
// Subtract the two offsets
return {
top: offset.top - parentOffset.top,
left: offset.left - parentOffset.left
}
},
offsetParent: function() {
return this.map(function(){
var parent = this.offsetParent || document.body
while (parent && !rootNodeRE.test(parent.nodeName) && $(parent).css("position") == "static")
parent = parent.offsetParent
return parent
})
}
}
// for now
$.fn.detach = $.fn.remove
// Generate the `width` and `height` functions
;['width', 'height'].forEach(function(dimension){
var dimensionProperty =
dimension.replace(/./, function(m){ return m[0].toUpperCase() })
$.fn[dimension] = function(value){
var offset, el = this[0]
if (value === undefined) return isWindow(el) ? el['inner' + dimensionProperty] :
isDocument(el) ? el.documentElement['scroll' + dimensionProperty] :
(offset = this.offset()) && offset[dimension]
else return this.each(function(idx){
el = $(this)
el.css(dimension, funcArg(this, value, idx, el[dimension]()))
})
}
})
function traverseNode(node, fun) {
fun(node)
for (var i = 0, len = node.childNodes.length; i < len; i++)
traverseNode(node.childNodes[i], fun)
}
// Generate the `after`, `prepend`, `before`, `append`,
// `insertAfter`, `insertBefore`, `appendTo`, and `prependTo` methods.
adjacencyOperators.forEach(function(operator, operatorIndex) {
var inside = operatorIndex % 2 //=> prepend, append
$.fn[operator] = function(){
// arguments can be nodes, arrays of nodes, Zepto objects and HTML strings
var argType, nodes = $.map(arguments, function(arg) {
var arr = []
argType = type(arg)
if (argType == "array") {
arg.forEach(function(el) {
if (el.nodeType !== undefined) return arr.push(el)
else if ($.zepto.isZ(el)) return arr = arr.concat(el.get())
arr = arr.concat(zepto.fragment(el))
})
return arr
}
return argType == "object" || arg == null ?
arg : zepto.fragment(arg)
}),
parent, copyByClone = this.length > 1
if (nodes.length < 1) return this
return this.each(function(_, target){
parent = inside ? target : target.parentNode
// convert all methods to a "before" operation
target = operatorIndex == 0 ? target.nextSibling :
operatorIndex == 1 ? target.firstChild :
operatorIndex == 2 ? target :
null
var parentInDocument = $.contains(document.documentElement, parent)
nodes.forEach(function(node){
if (copyByClone) node = node.cloneNode(true)
else if (!parent) return $(node).remove()
parent.insertBefore(node, target)
if (parentInDocument) traverseNode(node, function(el){
if (el.nodeName != null && el.nodeName.toUpperCase() === 'SCRIPT' &&
(!el.type || el.type === 'text/javascript') && !el.src){
var target = el.ownerDocument ? el.ownerDocument.defaultView : window
target['eval'].call(target, el.innerHTML)
}
})
})
})
}
// after => insertAfter
// prepend => prependTo
// before => insertBefore
// append => appendTo
$.fn[inside ? operator+'To' : 'insert'+(operatorIndex ? 'Before' : 'After')] = function(html){
$(html)[operator](this)
return this
}
})
zepto.Z.prototype = Z.prototype = $.fn
// Export internal API functions in the `$.zepto` namespace
zepto.uniq = uniq
zepto.deserializeValue = deserializeValue
$.zepto = zepto
return $
})()
window.Zepto = Zepto
window.$ === undefined && (window.$ = Zepto)
;(function($){
var jsonpID = +new Date(),
document = window.document,
key,
name,
rscript = /
*
* ```
* Now, create the player:
* ```html
*
*
*
*
* ```
*/
// Copyright 2014 Globo.com Player authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
var Player = function (_BaseObject) {
(0, _inherits3.default)(Player, _BaseObject);
(0, _createClass3.default)(Player, [{
key: 'loader',
set: function set(loader) {
this._loader = loader;
},
get: function get() {
if (!this._loader) this._loader = new _loader2.default(this.options.plugins || {}, this.options.playerId);
return this._loader;
}
/**
* Determine if the playback has ended.
* @property ended
* @type Boolean
*/
}, {
key: 'ended',
get: function get() {
return this.core.activeContainer.ended;
}
/**
* Determine if the playback is having to buffer in order for
* playback to be smooth.
* (i.e if a live stream is playing smoothly, this will be false)
* @property buffering
* @type Boolean
*/
}, {
key: 'buffering',
get: function get() {
return this.core.activeContainer.buffering;
}
/*
* determine if the player is ready.
* @property isReady
* @type {Boolean} `true` if the player is ready. ie PLAYER_READY event has fired
*/
}, {
key: 'isReady',
get: function get() {
return !!this._ready;
}
/**
* An events map that allows the user to add custom callbacks in player's options.
* @property eventsMapping
* @type {Object}
*/
}, {
key: 'eventsMapping',
get: function get() {
return {
onReady: _events2.default.PLAYER_READY,
onResize: _events2.default.PLAYER_RESIZE,
onPlay: _events2.default.PLAYER_PLAY,
onPause: _events2.default.PLAYER_PAUSE,
onStop: _events2.default.PLAYER_STOP,
onEnded: _events2.default.PLAYER_ENDED,
onSeek: _events2.default.PLAYER_SEEK,
onError: _events2.default.PLAYER_ERROR,
onTimeUpdate: _events2.default.PLAYER_TIMEUPDATE,
onVolumeUpdate: _events2.default.PLAYER_VOLUMEUPDATE,
onSubtitleAvailable: _events2.default.PLAYER_SUBTITLE_AVAILABLE
};
}
/**
* @typedef {Object} PlaybackConfig
* @prop {boolean} disableContextMenu
* disables the context menu (right click) on the video element if a HTML5Video playback is used.
* @prop {boolean} preload
* video will be preloaded according to `preload` attribute options **default**: `'metadata'`
* @prop {boolean} controls
* enabled/disables displaying controls
* @prop {boolean} crossOrigin
* enables cross-origin capability for media-hacks
* @prop {boolean} playInline
* enables in-line video elements
* @prop {boolean} audioOnly
* enforce audio-only playback (when possible)
* @prop {Object} externalTracks
* pass externaly loaded track to playback
* @prop {Number} [maxBufferLength]
* The default behavior for the **HLS playback** is to keep buffering indefinitely, even on VoD.
* This replicates the behavior for progressive download, which continues buffering when pausing the video, thus making the video available for playback even on slow networks.
* To change this behavior use `maxBufferLength` where **value is in seconds**.
* @prop {Number} [maxBackBufferLength]
* After how much distance of the playhead data should be pruned from the buffer (influences memory consumption
* of adaptive media-engines like Hls.js or Shaka)
* @prop {Number} [minBufferLength]
* After how much data in the buffer at least we attempt to consume it (influences QoS-related behavior
* of adaptive media-engines like Hls.js or Shaka). If this is too low, and the available bandwidth is varying a lot
* and too close to the streamed bitrate, we may continuously hit under-runs.
* @prop {Number} [initialBandwidthEstimate]
* define an initial bandwidth "guess" (or previously stored/established value) for underlying adaptive-bitreate engines
* of adaptive playback implementations, like Hls.js or Shaka
* @prop {Number} [maxAdaptiveBitrate]
* Limits the streamed bitrate (for adaptive media-engines in underlying playback implementations)
* @prop {Object} [maxAdaptiveVideoDimensions]
* Limits the video dimensions in adaptive media-engines. Should be a literal object with `height` and `width`.
* @prop {Boolean}[enableAutomaticABR] **default**: `true`
* Allows to enable/disable automatic bitrate switching in adaptive media-engines
* @prop {String} [preferredTextLanguage] **default**: `'pt-BR'`
* Allows to set a preferred text language, that may be enabled by the media-engine if available.
* @prop {String} [preferredAudioLanguage] **default**: `'pt-BR'`
* Allows to set a preferred audio language, that may be enabled by the media-engine if available.
*/
/**
* ## Player's constructor
*
* You might pass the options object to build the player.
* ```javascript
* var options = {source: "http://example.com/video.mp4", param1: "val1"};
* var player = new Clappr.Player(options);
* ```
*
* @method constructor
* @param {Object} options Data
* options to build a player instance
* @param {Number} [options.width]
* player's width **default**: `640`
* @param {Number} [options.height]
* player's height **default**: `360`
* @param {String} [options.parentId]
* the id of the element on the page that the player should be inserted into
* @param {Object} [options.parent]
* a reference to a dom element that the player should be inserted into
* @param {String} [options.source]
* The media source URL, or {source: <>, mimeType: <>}
* @param {Object} [options.sources]
* An array of media source URL's, or an array of {source: <>, mimeType: <>}
* @param {Boolean} [options.autoPlay]
* automatically play after page load **default**: `false`
* @param {Boolean} [options.loop]
* automatically replay after it ends **default**: `false`
* @param {Boolean} [options.chromeless]
* player acts in chromeless mode **default**: `false`
* @param {Boolean} [options.allowUserInteraction]
* whether or not the player should handle click events when in chromeless mode **default**: `false` on desktops browsers, `true` on mobile.
* @param {Boolean} [options.disableKeyboardShortcuts]
* disable keyboard shortcuts. **default**: `false`. `true` if `allowUserInteraction` is `false`.
* @param {Boolean} [options.mute]
* start the video muted **default**: `false`
* @param {String} [options.mimeType]
* add `mimeType: "application/vnd.apple.mpegurl"` if you need to use a url without extension.
* @param {Boolean} [options.actualLiveTime]
* show duration and seek time relative to actual time.
* @param {String} [options.actualLiveServerTime]
* specify server time as a string, format: "2015/11/26 06:01:03". This option is meant to be used with actualLiveTime.
* @param {Boolean} [options.persistConfig]
* persist player's settings (volume) through the same domain **default**: `true`
* @param {String} [options.preload] @deprecated
* video will be preloaded according to `preload` attribute options **default**: `'metadata'`
* @param {Number} [options.maxBufferLength] @deprecated
* the default behavior for the **HLS playback** is to keep buffering indefinitely, even on VoD.
* This replicates the behavior for progressive download, which continues buffering when pausing the video, thus making the video available for playback even on slow networks.
* To change this behavior use `maxBufferLength` where **value is in seconds**.
* @param {String} [options.gaAccount]
* enable Google Analytics events dispatch **(play/pause/stop/buffering/etc)** by adding your `gaAccount`
* @param {String} [options.gaTrackerName]
* besides `gaAccount` you can optionally, pass your favorite trackerName as `gaTrackerName`
* @param {Object} [options.mediacontrol]
* customize control bar colors, example: `mediacontrol: {seekbar: "#E113D3", buttons: "#66B2FF"}`
* @param {Boolean} [options.hideMediaControl]
* control media control auto hide **default**: `true`
* @param {Boolean} [options.hideVolumeBar]
* when embedded with width less than 320, volume bar will hide. You can force this behavior for all sizes by adding `true` **default**: `false`
* @param {String} [options.watermark]
* put `watermark: 'http://url/img.png'` on your embed parameters to automatically add watermark on your video.
* You can customize corner position by defining position parameter. Positions can be `bottom-left`, `bottom-right`, `top-left` and `top-right`.
* @param {String} [options.watermarkLink]
* `watermarkLink: 'http://example.net/'` - define URL to open when the watermark is clicked. If not provided watermark will not be clickable.
* @param {Boolean} [options.disableVideoTagContextMenu] @deprecated
* disables the context menu (right click) on the video element if a HTML5Video playback is used.
* @param {Boolean} [options.autoSeekFromUrl]
* Automatically seek to the seconds provided in the url (e.g example.com?t=100) **default**: `true`
* @param {Boolean} [options.exitFullscreenOnEnd]
* Automatically exit full screen when the media finishes. **default**: `true`
* @param {String} [options.poster]
* define a poster by adding its address `poster: 'http://url/img.png'`. It will appear after video embed, disappear on play and go back when user stops the video.
* @param {String} [options.playbackNotSupportedMessage]
* define a custom message to be displayed when a playback is not supported.
* @param {Object} [options.events]
* Specify listeners which will be registered with their corresponding player events.
* E.g. onReady -> "PLAYER_READY", onTimeUpdate -> "PLAYER_TIMEUPDATE"
* @param {PlaybackConfig} [options.playback]
* Generic `Playback` component related configuration
* @param {Boolean} [options.disableErrorScreen]
* disables the error screen plugin.
* @param {Number} [options.autoPlayTimeout]
* autoplay check timeout.
*/
}]);
function Player(options) {
(0, _classCallCheck3.default)(this, Player);
var _this = (0, _possibleConstructorReturn3.default)(this, _BaseObject.call(this, options));
var playbackDefaultOptions = { recycleVideo: true };
var defaultOptions = {
playerId: (0, _utils.uniqueId)(''),
persistConfig: true,
width: 640,
height: 360,
baseUrl: baseUrl,
allowUserInteraction: _browser2.default.isMobile,
playback: playbackDefaultOptions
};
_this._options = _clapprZepto2.default.extend(defaultOptions, options);
_this.options.sources = _this._normalizeSources(options);
if (!_this.options.chromeless) {
// "allowUserInteraction" cannot be false if not in chromeless mode.
_this.options.allowUserInteraction = true;
}
if (!_this.options.allowUserInteraction) {
// if user iteraction is not allowed ensure keyboard shortcuts are disabled
_this.options.disableKeyboardShortcuts = true;
}
_this._registerOptionEventListeners(_this.options.events);
_this._coreFactory = new _core_factory2.default(_this);
_this.playerInfo = _player_info2.default.getInstance(_this.options.playerId);
_this.playerInfo.currentSize = { width: options.width, height: options.height };
_this.playerInfo.options = _this.options;
if (_this.options.parentId) _this.setParentId(_this.options.parentId);else if (_this.options.parent) _this.attachTo(_this.options.parent);
return _this;
}
/**
* Specify a `parentId` to the player.
* @method setParentId
* @param {String} parentId the element parent id.
* @return {Player} itself
*/
Player.prototype.setParentId = function setParentId(parentId) {
var el = document.querySelector(parentId);
if (el) this.attachTo(el);
return this;
};
/**
* You can use this method to attach the player to a given element. You don't need to do this when you specify it during the player instantiation passing the `parentId` param.
* @method attachTo
* @param {Object} element a given element.
* @return {Player} itself
*/
Player.prototype.attachTo = function attachTo(element) {
this.options.parentElement = element;
this.core = this._coreFactory.create();
this._addEventListeners();
return this;
};
Player.prototype._addEventListeners = function _addEventListeners() {
if (!this.core.isReady) this.listenToOnce(this.core, _events2.default.CORE_READY, this._onReady);else this._onReady();
this.listenTo(this.core, _events2.default.CORE_ACTIVE_CONTAINER_CHANGED, this._containerChanged);
this.listenTo(this.core, _events2.default.CORE_FULLSCREEN, this._onFullscreenChange);
this.listenTo(this.core, _events2.default.CORE_RESIZE, this._onResize);
return this;
};
Player.prototype._addContainerEventListeners = function _addContainerEventListeners() {
var container = this.core.activeContainer;
if (container) {
this.listenTo(container, _events2.default.CONTAINER_PLAY, this._onPlay);
this.listenTo(container, _events2.default.CONTAINER_PAUSE, this._onPause);
this.listenTo(container, _events2.default.CONTAINER_STOP, this._onStop);
this.listenTo(container, _events2.default.CONTAINER_ENDED, this._onEnded);
this.listenTo(container, _events2.default.CONTAINER_SEEK, this._onSeek);
this.listenTo(container, _events2.default.CONTAINER_ERROR, this._onError);
this.listenTo(container, _events2.default.CONTAINER_TIMEUPDATE, this._onTimeUpdate);
this.listenTo(container, _events2.default.CONTAINER_VOLUME, this._onVolumeUpdate);
this.listenTo(container, _events2.default.CONTAINER_SUBTITLE_AVAILABLE, this._onSubtitleAvailable);
}
return this;
};
Player.prototype._registerOptionEventListeners = function _registerOptionEventListeners() {
var _this2 = this;
var newEvents = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var hasNewEvents = (0, _keys2.default)(newEvents).length > 0;
hasNewEvents && (0, _keys2.default)(events).forEach(function (userEvent) {
var eventType = _this2.eventsMapping[userEvent];
eventType && _this2.off(eventType, events[userEvent]);
});
(0, _keys2.default)(newEvents).forEach(function (userEvent) {
var eventType = _this2.eventsMapping[userEvent];
if (eventType) {
var eventFunction = newEvents[userEvent];
eventFunction = typeof eventFunction === 'function' && eventFunction;
eventFunction && _this2.on(eventType, eventFunction);
}
});
return this;
};
Player.prototype._containerChanged = function _containerChanged() {
this.stopListening();
this._addEventListeners();
};
Player.prototype._onReady = function _onReady() {
this._ready = true;
this._addContainerEventListeners();
this.trigger(_events2.default.PLAYER_READY);
};
Player.prototype._onFullscreenChange = function _onFullscreenChange(fullscreen) {
this.trigger(_events2.default.PLAYER_FULLSCREEN, fullscreen);
};
Player.prototype._onVolumeUpdate = function _onVolumeUpdate(volume) {
this.trigger(_events2.default.PLAYER_VOLUMEUPDATE, volume);
};
Player.prototype._onSubtitleAvailable = function _onSubtitleAvailable() {
this.trigger(_events2.default.PLAYER_SUBTITLE_AVAILABLE);
};
Player.prototype._onResize = function _onResize(size) {
this.trigger(_events2.default.PLAYER_RESIZE, size);
};
Player.prototype._onPlay = function _onPlay() {
this.trigger(_events2.default.PLAYER_PLAY);
};
Player.prototype._onPause = function _onPause() {
this.trigger(_events2.default.PLAYER_PAUSE);
};
Player.prototype._onStop = function _onStop() {
this.trigger(_events2.default.PLAYER_STOP, this.getCurrentTime());
};
Player.prototype._onEnded = function _onEnded() {
this.trigger(_events2.default.PLAYER_ENDED);
};
Player.prototype._onSeek = function _onSeek(time) {
this.trigger(_events2.default.PLAYER_SEEK, time);
};
Player.prototype._onTimeUpdate = function _onTimeUpdate(timeProgress) {
this.trigger(_events2.default.PLAYER_TIMEUPDATE, timeProgress);
};
Player.prototype._onError = function _onError(error) {
this.trigger(_events2.default.PLAYER_ERROR, error);
};
Player.prototype._normalizeSources = function _normalizeSources(options) {
var sources = options.sources || (options.source !== undefined ? [options.source] : []);
return sources.length === 0 ? [{ source: '', mimeType: '' }] : sources;
};
/**
* resizes the current player canvas.
* @method resize
* @param {Object} size should be a literal object with `height` and `width`.
* @return {Player} itself
* @example
* ```javascript
* player.resize({height: 360, width: 640})
* ```
*/
Player.prototype.resize = function resize(size) {
this.core.resize(size);
return this;
};
/**
* loads a new source.
* @method load
* @param {Array|String} sources source or sources of video.
* An array item can be a string or {source: <>, mimeType: <>}
* @param {String} mimeType a mime type, example: `'application/vnd.apple.mpegurl'`
* @param {Boolean} [autoPlay=false] whether playing should be started immediately
* @return {Player} itself
*/
Player.prototype.load = function load(sources, mimeType, autoPlay) {
if (autoPlay !== undefined) this.configure({ autoPlay: !!autoPlay });
this.core.load(sources, mimeType);
return this;
};
/**
* destroys the current player and removes it from the DOM.
* @method destroy
* @return {Player} itself
*/
Player.prototype.destroy = function destroy() {
this.stopListening();
this.core.destroy();
return this;
};
/**
* Gives user consent to playback. Required by mobile device after a click event before Player.load().
* @method consent
* @return {Player} itself
*/
Player.prototype.consent = function consent() {
this.core.getCurrentPlayback().consent();
return this;
};
/**
* plays the current video (`source`).
* @method play
* @return {Player} itself
*/
Player.prototype.play = function play() {
this.core.activeContainer.play();
return this;
};
/**
* pauses the current video (`source`).
* @method pause
* @return {Player} itself
*/
Player.prototype.pause = function pause() {
this.core.activeContainer.pause();
return this;
};
/**
* stops the current video (`source`).
* @method stop
* @return {Player} itself
*/
Player.prototype.stop = function stop() {
this.core.activeContainer.stop();
return this;
};
/**
* seeks the current video (`source`). For example, `player.seek(120)` will seek to second 120 (2minutes) of the current video.
* @method seek
* @param {Number} time should be a number between 0 and the video duration.
* @return {Player} itself
*/
Player.prototype.seek = function seek(time) {
this.core.activeContainer.seek(time);
return this;
};
/**
* seeks the current video (`source`). For example, `player.seek(50)` will seek to the middle of the current video.
* @method seekPercentage
* @param {Number} time should be a number between 0 and 100.
* @return {Player} itself
*/
Player.prototype.seekPercentage = function seekPercentage(percentage) {
this.core.activeContainer.seekPercentage(percentage);
return this;
};
/**
* mutes the current video (`source`).
* @method mute
* @return {Player} itself
*/
Player.prototype.mute = function mute() {
this._mutedVolume = this.getVolume();
this.setVolume(0);
return this;
};
/**
* unmutes the current video (`source`).
* @method unmute
* @return {Player} itself
*/
Player.prototype.unmute = function unmute() {
this.setVolume(typeof this._mutedVolume === 'number' ? this._mutedVolume : 100);
this._mutedVolume = null;
return this;
};
/**
* checks if the player is playing.
* @method isPlaying
* @return {Boolean} `true` if the current source is playing, otherwise `false`
*/
Player.prototype.isPlaying = function isPlaying() {
return this.core.activeContainer.isPlaying();
};
/**
* returns `true` if DVR is enable otherwise `false`.
* @method isDvrEnabled
* @return {Boolean}
*/
Player.prototype.isDvrEnabled = function isDvrEnabled() {
return this.core.activeContainer.isDvrEnabled();
};
/**
* returns `true` if DVR is in use otherwise `false`.
* @method isDvrInUse
* @return {Boolean}
*/
Player.prototype.isDvrInUse = function isDvrInUse() {
return this.core.activeContainer.isDvrInUse();
};
/**
* enables to configure a player after its creation
* @method configure
* @param {Object} options all the options to change in form of a javascript object
* @return {Player} itself
*/
Player.prototype.configure = function configure() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
this._registerOptionEventListeners(options.events, this.options.events);
this.core.configure(options);
return this;
};
/**
* get a plugin by its name.
* @method getPlugin
* @param {String} name of the plugin.
* @return {Object} the plugin instance
* @example
* ```javascript
* var poster = player.getPlugin('poster');
* poster.hidePlayButton();
* ```
*/
Player.prototype.getPlugin = function getPlugin(name) {
var plugins = this.core.plugins.concat(this.core.activeContainer.plugins);
return plugins.filter(function (plugin) {
return plugin.name === name;
})[0];
};
/**
* the current time in seconds.
* @method getCurrentTime
* @return {Number} current time (in seconds) of the current source
*/
Player.prototype.getCurrentTime = function getCurrentTime() {
return this.core.activeContainer.getCurrentTime();
};
/**
* The time that "0" now represents relative to when playback started.
* For a stream with a sliding window this will increase as content is
* removed from the beginning.
* @method getStartTimeOffset
* @return {Number} time (in seconds) that time "0" represents.
*/
Player.prototype.getStartTimeOffset = function getStartTimeOffset() {
return this.core.activeContainer.getStartTimeOffset();
};
/**
* the duration time in seconds.
* @method getDuration
* @return {Number} duration time (in seconds) of the current source
*/
Player.prototype.getDuration = function getDuration() {
return this.core.activeContainer.getDuration();
};
return Player;
}(_base_object2.default);
exports.default = Player;
(0, _assign2.default)(Player.prototype, _error_mixin2.default);
module.exports = exports['default'];
/***/ }),
/***/ "./src/components/player_info.js":
/*!***************************************!*\
!*** ./src/components/player_info.js ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Copyright 2014 Globo.com Player authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
var PlayerInfo = function PlayerInfo() {
(0, _classCallCheck3.default)(this, PlayerInfo);
this.options = {};
this.playbackPlugins = [];
this.currentSize = { width: 0, height: 0 };
};
PlayerInfo._players = {};
PlayerInfo.getInstance = function (playerId) {
return PlayerInfo._players[playerId] || (PlayerInfo._players[playerId] = new PlayerInfo());
};
exports.default = PlayerInfo;
module.exports = exports["default"];
/***/ }),
/***/ "./src/icons/01-play.svg":
/*!*******************************!*\
!*** ./src/icons/01-play.svg ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ""
/***/ }),
/***/ "./src/icons/02-pause.svg":
/*!********************************!*\
!*** ./src/icons/02-pause.svg ***!
\********************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ""
/***/ }),
/***/ "./src/icons/03-stop.svg":
/*!*******************************!*\
!*** ./src/icons/03-stop.svg ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ""
/***/ }),
/***/ "./src/icons/04-volume.svg":
/*!*********************************!*\
!*** ./src/icons/04-volume.svg ***!
\*********************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ""
/***/ }),
/***/ "./src/icons/05-mute.svg":
/*!*******************************!*\
!*** ./src/icons/05-mute.svg ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ""
/***/ }),
/***/ "./src/icons/06-expand.svg":
/*!*********************************!*\
!*** ./src/icons/06-expand.svg ***!
\*********************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ""
/***/ }),
/***/ "./src/icons/07-shrink.svg":
/*!*********************************!*\
!*** ./src/icons/07-shrink.svg ***!
\*********************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ""
/***/ }),
/***/ "./src/icons/08-hd.svg":
/*!*****************************!*\
!*** ./src/icons/08-hd.svg ***!
\*****************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ""
/***/ }),
/***/ "./src/icons/09-cc.svg":
/*!*****************************!*\
!*** ./src/icons/09-cc.svg ***!
\*****************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ""
/***/ }),
/***/ "./src/icons/10-reload.svg":
/*!*********************************!*\
!*** ./src/icons/10-reload.svg ***!
\*********************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ""
/***/ }),
/***/ "./src/main.js":
/*!*********************!*\
!*** ./src/main.js ***!
\*********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _player = __webpack_require__(/*! ./components/player */ "./src/components/player.js");
var _player2 = _interopRequireDefault(_player);
var _utils = __webpack_require__(/*! ./base/utils */ "./src/base/utils.js");
var _utils2 = _interopRequireDefault(_utils);
var _events = __webpack_require__(/*! ./base/events */ "./src/base/events.js");
var _events2 = _interopRequireDefault(_events);
var _playback = __webpack_require__(/*! ./base/playback */ "./src/base/playback.js");
var _playback2 = _interopRequireDefault(_playback);
var _container_plugin = __webpack_require__(/*! ./base/container_plugin */ "./src/base/container_plugin.js");
var _container_plugin2 = _interopRequireDefault(_container_plugin);
var _core_plugin = __webpack_require__(/*! ./base/core_plugin */ "./src/base/core_plugin.js");
var _core_plugin2 = _interopRequireDefault(_core_plugin);
var _ui_core_plugin = __webpack_require__(/*! ./base/ui_core_plugin */ "./src/base/ui_core_plugin.js");
var _ui_core_plugin2 = _interopRequireDefault(_ui_core_plugin);
var _ui_container_plugin = __webpack_require__(/*! ./base/ui_container_plugin */ "./src/base/ui_container_plugin.js");
var _ui_container_plugin2 = _interopRequireDefault(_ui_container_plugin);
var _base_object = __webpack_require__(/*! ./base/base_object */ "./src/base/base_object.js");
var _base_object2 = _interopRequireDefault(_base_object);
var _ui_object = __webpack_require__(/*! ./base/ui_object */ "./src/base/ui_object.js");
var _ui_object2 = _interopRequireDefault(_ui_object);
var _browser = __webpack_require__(/*! ./components/browser */ "./src/components/browser/index.js");
var _browser2 = _interopRequireDefault(_browser);
var _container = __webpack_require__(/*! ./components/container */ "./src/components/container/index.js");
var _container2 = _interopRequireDefault(_container);
var _core = __webpack_require__(/*! ./components/core */ "./src/components/core/index.js");
var _core2 = _interopRequireDefault(_core);
var _error = __webpack_require__(/*! ./components/error */ "./src/components/error/index.js");
var _error2 = _interopRequireDefault(_error);
var _loader = __webpack_require__(/*! ./components/loader */ "./src/components/loader/index.js");
var _loader2 = _interopRequireDefault(_loader);
var _mediator = __webpack_require__(/*! ./components/mediator */ "./src/components/mediator.js");
var _mediator2 = _interopRequireDefault(_mediator);
var _player_info = __webpack_require__(/*! ./components/player_info */ "./src/components/player_info.js");
var _player_info2 = _interopRequireDefault(_player_info);
var _base_flash_playback = __webpack_require__(/*! ./playbacks/base_flash_playback */ "./src/playbacks/base_flash_playback/index.js");
var _base_flash_playback2 = _interopRequireDefault(_base_flash_playback);
var _flash = __webpack_require__(/*! ./playbacks/flash */ "./src/playbacks/flash/index.js");
var _flash2 = _interopRequireDefault(_flash);
var _flashls = __webpack_require__(/*! ./playbacks/flashls */ "./src/playbacks/flashls/index.js");
var _flashls2 = _interopRequireDefault(_flashls);
var _hls = __webpack_require__(/*! ./playbacks/hls */ "./src/playbacks/hls/index.js");
var _hls2 = _interopRequireDefault(_hls);
var _html5_audio = __webpack_require__(/*! ./playbacks/html5_audio */ "./src/playbacks/html5_audio/index.js");
var _html5_audio2 = _interopRequireDefault(_html5_audio);
var _html5_video = __webpack_require__(/*! ./playbacks/html5_video */ "./src/playbacks/html5_video/index.js");
var _html5_video2 = _interopRequireDefault(_html5_video);
var _html_img = __webpack_require__(/*! ./playbacks/html_img */ "./src/playbacks/html_img/index.js");
var _html_img2 = _interopRequireDefault(_html_img);
var _no_op = __webpack_require__(/*! ./playbacks/no_op */ "./src/playbacks/no_op/index.js");
var _no_op2 = _interopRequireDefault(_no_op);
var _media_control = __webpack_require__(/*! ./plugins/media_control */ "./src/plugins/media_control/index.js");
var _media_control2 = _interopRequireDefault(_media_control);
var _click_to_pause = __webpack_require__(/*! ./plugins/click_to_pause */ "./src/plugins/click_to_pause/index.js");
var _click_to_pause2 = _interopRequireDefault(_click_to_pause);
var _dvr_controls = __webpack_require__(/*! ./plugins/dvr_controls */ "./src/plugins/dvr_controls/index.js");
var _dvr_controls2 = _interopRequireDefault(_dvr_controls);
var _favicon = __webpack_require__(/*! ./plugins/favicon */ "./src/plugins/favicon/index.js");
var _favicon2 = _interopRequireDefault(_favicon);
var _log = __webpack_require__(/*! ./plugins/log */ "./src/plugins/log/index.js");
var _log2 = _interopRequireDefault(_log);
var _poster = __webpack_require__(/*! ./plugins/poster */ "./src/plugins/poster/index.js");
var _poster2 = _interopRequireDefault(_poster);
var _spinner_three_bounce = __webpack_require__(/*! ./plugins/spinner_three_bounce */ "./src/plugins/spinner_three_bounce/index.js");
var _spinner_three_bounce2 = _interopRequireDefault(_spinner_three_bounce);
var _watermark = __webpack_require__(/*! ./plugins/watermark */ "./src/plugins/watermark/index.js");
var _watermark2 = _interopRequireDefault(_watermark);
var _styler = __webpack_require__(/*! ./base/styler */ "./src/base/styler.js");
var _styler2 = _interopRequireDefault(_styler);
var _vendor = __webpack_require__(/*! ./vendor */ "./src/vendor/index.js");
var _vendor2 = _interopRequireDefault(_vendor);
var _template = __webpack_require__(/*! ./base/template */ "./src/base/template.js");
var _template2 = _interopRequireDefault(_template);
var _clapprZepto = __webpack_require__(/*! clappr-zepto */ "./node_modules/clappr-zepto/zepto.js");
var _clapprZepto2 = _interopRequireDefault(_clapprZepto);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var version = "0.3.7"; // Copyright 2014 Globo.com Player authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
exports.default = {
Player: _player2.default,
Mediator: _mediator2.default,
Events: _events2.default,
Browser: _browser2.default,
PlayerInfo: _player_info2.default,
MediaControl: _media_control2.default,
ContainerPlugin: _container_plugin2.default,
UIContainerPlugin: _ui_container_plugin2.default,
CorePlugin: _core_plugin2.default,
UICorePlugin: _ui_core_plugin2.default,
Playback: _playback2.default,
Container: _container2.default,
Core: _core2.default,
PlayerError: _error2.default,
Loader: _loader2.default,
BaseObject: _base_object2.default,
UIObject: _ui_object2.default,
Utils: _utils2.default,
BaseFlashPlayback: _base_flash_playback2.default,
Flash: _flash2.default,
FlasHLS: _flashls2.default,
HLS: _hls2.default,
HTML5Audio: _html5_audio2.default,
HTML5Video: _html5_video2.default,
HTMLImg: _html_img2.default,
NoOp: _no_op2.default,
ClickToPausePlugin: _click_to_pause2.default,
DVRControls: _dvr_controls2.default,
Favicon: _favicon2.default,
Log: _log2.default,
Poster: _poster2.default,
SpinnerThreeBouncePlugin: _spinner_three_bounce2.default,
WaterMarkPlugin: _watermark2.default,
Styler: _styler2.default,
Vendor: _vendor2.default,
version: version,
template: _template2.default,
$: _clapprZepto2.default
};
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/base_flash_playback/base_flash_playback.js":
/*!******************************************************************!*\
!*** ./src/playbacks/base_flash_playback/base_flash_playback.js ***!
\******************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");
var _inherits3 = _interopRequireDefault(_inherits2);
var _playback = __webpack_require__(/*! ../../base/playback */ "./src/base/playback.js");
var _playback2 = _interopRequireDefault(_playback);
var _template = __webpack_require__(/*! ../../base/template */ "./src/base/template.js");
var _template2 = _interopRequireDefault(_template);
var _browser = __webpack_require__(/*! ../../components/browser */ "./src/components/browser/index.js");
var _browser2 = _interopRequireDefault(_browser);
var _flash = __webpack_require__(/*! ./public/flash.html */ "./src/playbacks/base_flash_playback/public/flash.html");
var _flash2 = _interopRequireDefault(_flash);
__webpack_require__(/*! ./public/flash.scss */ "./src/playbacks/base_flash_playback/public/flash.scss");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var IE_CLASSID = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'; // Copyright 2015 Globo.com Player authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
var BaseFlashPlayback = function (_Playback) {
(0, _inherits3.default)(BaseFlashPlayback, _Playback);
function BaseFlashPlayback() {
(0, _classCallCheck3.default)(this, BaseFlashPlayback);
return (0, _possibleConstructorReturn3.default)(this, _Playback.apply(this, arguments));
}
BaseFlashPlayback.prototype.setElement = function setElement(element) {
this.$el = element;
this.el = element[0];
};
BaseFlashPlayback.prototype.render = function render() {
this.$el.attr('data', this.swfPath);
this.$el.html(this.template({
cid: this.cid,
swfPath: this.swfPath,
baseUrl: this.baseUrl,
playbackId: this.uniqueId,
wmode: this.wmode,
callbackName: 'window.Clappr.flashlsCallbacks.' + this.cid }));
if (_browser2.default.isIE) {
this.$('embed').remove();
if (_browser2.default.isLegacyIE) this.$el.attr('classid', IE_CLASSID);
}
this.el.id = this.cid;
return this;
};
(0, _createClass3.default)(BaseFlashPlayback, [{
key: 'tagName',
get: function get() {
return 'object';
}
}, {
key: 'swfPath',
get: function get() {
return '';
}
}, {
key: 'wmode',
get: function get() {
return 'transparent';
}
}, {
key: 'template',
get: function get() {
return (0, _template2.default)(_flash2.default);
}
}, {
key: 'attributes',
get: function get() {
var type = 'application/x-shockwave-flash';
if (_browser2.default.isLegacyIE) type = '';
return {
class: 'clappr-flash-playback',
type: type,
width: '100%',
height: '100%',
data: this.swfPath,
'data-flash-playback': this.name
};
}
}]);
return BaseFlashPlayback;
}(_playback2.default);
exports.default = BaseFlashPlayback;
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/base_flash_playback/index.js":
/*!****************************************************!*\
!*** ./src/playbacks/base_flash_playback/index.js ***!
\****************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = __webpack_require__(/*! ./base_flash_playback */ "./src/playbacks/base_flash_playback/base_flash_playback.js");
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/base_flash_playback/public/flash.html":
/*!*************************************************************!*\
!*** ./src/playbacks/base_flash_playback/public/flash.html ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "\">\n\n\n\n\n\n\">\n\n&callback=<%= callbackName %>\">\n\n";
/***/ }),
/***/ "./src/playbacks/base_flash_playback/public/flash.scss":
/*!*************************************************************!*\
!*** ./src/playbacks/base_flash_playback/public/flash.scss ***!
\*************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var content = __webpack_require__(/*! !../../../../node_modules/css-loader!../../../../node_modules/postcss-loader/lib!../../../../node_modules/sass-loader/lib/loader.js?includePaths[]=/Users/bruno/workspace/clappr/clappr/src/base/scss!./flash.scss */ "./node_modules/css-loader/index.js!./node_modules/postcss-loader/lib/index.js!./node_modules/sass-loader/lib/loader.js?includePaths[]=/Users/bruno/workspace/clappr/clappr/src/base/scss!./src/playbacks/base_flash_playback/public/flash.scss");
if(typeof content === 'string') content = [[module.i, content, '']];
var transform;
var insertInto;
var options = {"singleton":true,"hmr":true}
options.transform = transform
options.insertInto = undefined;
var update = __webpack_require__(/*! ../../../../node_modules/style-loader/lib/addStyles.js */ "./node_modules/style-loader/lib/addStyles.js")(content, options);
if(content.locals) module.exports = content.locals;
if(false) {}
/***/ }),
/***/ "./src/playbacks/flash/flash.js":
/*!**************************************!*\
!*** ./src/playbacks/flash/flash.js ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");
var _createClass3 = _interopRequireDefault(_createClass2);
var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");
var _inherits3 = _interopRequireDefault(_inherits2);
var _utils = __webpack_require__(/*! ../../base/utils */ "./src/base/utils.js");
var _base_flash_playback = __webpack_require__(/*! ../../playbacks/base_flash_playback */ "./src/playbacks/base_flash_playback/index.js");
var _base_flash_playback2 = _interopRequireDefault(_base_flash_playback);
var _browser = __webpack_require__(/*! ../../components/browser */ "./src/components/browser/index.js");
var _browser2 = _interopRequireDefault(_browser);
var _mediator = __webpack_require__(/*! ../../components/mediator */ "./src/components/mediator.js");
var _mediator2 = _interopRequireDefault(_mediator);
var _template = __webpack_require__(/*! ../../base/template */ "./src/base/template.js");
var _template2 = _interopRequireDefault(_template);
var _clapprZepto = __webpack_require__(/*! clappr-zepto */ "./node_modules/clappr-zepto/zepto.js");
var _clapprZepto2 = _interopRequireDefault(_clapprZepto);
var _events = __webpack_require__(/*! ../../base/events */ "./src/base/events.js");
var _events2 = _interopRequireDefault(_events);
var _playback = __webpack_require__(/*! ../../base/playback */ "./src/base/playback.js");
var _playback2 = _interopRequireDefault(_playback);
var _Player = __webpack_require__(/*! ./public/Player.swf */ "./src/playbacks/flash/public/Player.swf");
var _Player2 = _interopRequireDefault(_Player);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var MAX_ATTEMPTS = 60; // Copyright 2014 Globo.com Player authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
var Flash = function (_BaseFlashPlayback) {
(0, _inherits3.default)(Flash, _BaseFlashPlayback);
(0, _createClass3.default)(Flash, [{
key: 'name',
get: function get() {
return 'flash';
}
}, {
key: 'swfPath',
get: function get() {
return (0, _template2.default)(_Player2.default)({ baseUrl: this._baseUrl });
}
/**
* Determine if the playback has ended.
* @property ended
* @type Boolean
*/
}, {
key: 'ended',
get: function get() {
return this._currentState === 'ENDED';
}
/**
* Determine if the playback is buffering.
* This is related to the PLAYBACK_BUFFERING and PLAYBACK_BUFFERFULL events
* @property buffering
* @type Boolean
*/
}, {
key: 'buffering',
get: function get() {
return !!this._bufferingState && this._currentState !== 'ENDED';
}
}]);
function Flash() {
(0, _classCallCheck3.default)(this, Flash);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var _this = (0, _possibleConstructorReturn3.default)(this, _BaseFlashPlayback.call.apply(_BaseFlashPlayback, [this].concat(args)));
_this._src = _this.options.src;
_this._baseUrl = _this.options.baseUrl;
_this._autoPlay = _this.options.autoPlay;
_this.settings = { default: ['seekbar'] };
_this.settings.left = ['playpause', 'position', 'duration'];
_this.settings.right = ['fullscreen', 'volume'];
_this.settings.seekEnabled = true;
_this._isReadyState = false;
_this._addListeners();
return _this;
}
Flash.prototype._bootstrap = function _bootstrap() {
var _this2 = this;
if (this.el.playerPlay) {
this.el.width = '100%';
this.el.height = '100%';
if (this._currentState === 'PLAYING') {
this._firstPlay();
} else {
this._currentState = 'IDLE';
this._autoPlay && this.play();
}
(0, _clapprZepto2.default)('').insertAfter(this.$el);
if (this.getDuration() > 0) this._metadataLoaded();else _mediator2.default.once(this.uniqueId + ':timeupdate', this._metadataLoaded, this);
} else {
this._attempts = this._attempts || 0;
if (++this._attempts <= MAX_ATTEMPTS) setTimeout(function () {
return _this2._bootstrap();
}, 50);else this.trigger(_events2.default.PLAYBACK_ERROR, { message: 'Max number of attempts reached' }, this.name);
}
};
Flash.prototype._metadataLoaded = function _metadataLoaded() {
this._isReadyState = true;
this.trigger(_events2.default.PLAYBACK_READY, this.name);
this.trigger(_events2.default.PLAYBACK_SETTINGSUPDATE, this.name);
};
Flash.prototype.getPlaybackType = function getPlaybackType() {
return _playback2.default.VOD;
};
Flash.prototype.isHighDefinitionInUse = function isHighDefinitionInUse() {
return false;
};
Flash.prototype._updateTime = function _updateTime() {
this.trigger(_events2.default.PLAYBACK_TIMEUPDATE, { current: this.el.getPosition(), total: this.el.getDuration() }, this.name);
};
Flash.prototype._addListeners = function _addListeners() {
_mediator2.default.on(this.uniqueId + ':progress', this._progress, this);
_mediator2.default.on(this.uniqueId + ':timeupdate', this._updateTime, this);
_mediator2.default.on(this.uniqueId + ':statechanged', this._checkState, this);
_mediator2.default.on(this.uniqueId + ':flashready', this._bootstrap, this);
};
Flash.prototype.stopListening = function stopListening() {
_BaseFlashPlayback.prototype.stopListening.call(this);
_mediator2.default.off(this.uniqueId + ':progress');
_mediator2.default.off(this.uniqueId + ':timeupdate');
_mediator2.default.off(this.uniqueId + ':statechanged');
_mediator2.default.off(this.uniqueId + ':flashready');
};
Flash.prototype._checkState = function _checkState() {
if (this._isIdle || this._currentState === 'PAUSED') {
return;
} else if (this._currentState !== 'PLAYING_BUFFERING' && this.el.getState() === 'PLAYING_BUFFERING') {
this._bufferingState = true;
this.trigger(_events2.default.PLAYBACK_BUFFERING, this.name);
this._currentState = 'PLAYING_BUFFERING';
} else if (this.el.getState() === 'PLAYING') {
this._bufferingState = false;
this.trigger(_events2.default.PLAYBACK_BUFFERFULL, this.name);
this._currentState = 'PLAYING';
} else if (this.el.getState() === 'IDLE') {
this._currentState = 'IDLE';
} else if (this.el.getState() === 'ENDED') {
this.trigger(_events2.default.PLAYBACK_ENDED, this.name);
this.trigger(_events2.default.PLAYBACK_TIMEUPDATE, { current: 0, total: this.el.getDuration() }, this.name);
this._currentState = 'ENDED';
this._isIdle = true;
}
};
Flash.prototype._progress = function _progress() {
if (this._currentState !== 'IDLE' && this._currentState !== 'ENDED') {
this.trigger(_events2.default.PLAYBACK_PROGRESS, {
start: 0,
current: this.el.getBytesLoaded(),
total: this.el.getBytesTotal()
});
}
};
Flash.prototype._firstPlay = function _firstPlay() {
var _this3 = this;
if (this.el.playerPlay) {
this._isIdle = false;
this.el.playerPlay(this._src);
this.listenToOnce(this, _events2.default.PLAYBACK_BUFFERFULL, function () {
return _this3._checkInitialSeek();
});
this._currentState = 'PLAYING';
} else {
this.listenToOnce(this, _events2.default.PLAYBACK_READY, this._firstPlay);
}
};
Flash.prototype._checkInitialSeek = function _checkInitialSeek() {
var seekTime = (0, _utils.seekStringToSeconds)(window.location.href);
if (seekTime !== 0) this.seekSeconds(seekTime);
};
Flash.prototype.play = function play() {
this.trigger(_events2.default.PLAYBACK_PLAY_INTENT);
if (this._currentState === 'PAUSED' || this._currentState === 'PLAYING_BUFFERING') {
this._currentState = 'PLAYING';
this.el.playerResume();
this.trigger(_events2.default.PLAYBACK_PLAY, this.name);
} else if (this._currentState !== 'PLAYING') {
this._firstPlay();
this.trigger(_events2.default.PLAYBACK_PLAY, this.name);
}
};
Flash.prototype.volume = function volume(value) {
var _this4 = this;
if (this.isReady) this.el.playerVolume(value);else this.listenToOnce(this, _events2.default.PLAYBACK_BUFFERFULL, function () {
return _this4.volume(value);
});
};
Flash.prototype.pause = function pause() {
this._currentState = 'PAUSED';
this.el.playerPause();
this.trigger(_events2.default.PLAYBACK_PAUSE, this.name);
};
Flash.prototype.stop = function stop() {
this.el.playerStop();
this.trigger(_events2.default.PLAYBACK_STOP);
this.trigger(_events2.default.PLAYBACK_TIMEUPDATE, { current: 0, total: 0 }, this.name);
};
Flash.prototype.isPlaying = function isPlaying() {
return !!(this.isReady && this._currentState.indexOf('PLAYING') > -1);
};
Flash.prototype.getDuration = function getDuration() {
return this.el.getDuration();
};
Flash.prototype.seekPercentage = function seekPercentage(percentage) {
var _this5 = this;
if (this.el.getDuration() > 0) {
var seekSeconds = this.el.getDuration() * (percentage / 100);
this.seek(seekSeconds);
} else {
this.listenToOnce(this, _events2.default.PLAYBACK_BUFFERFULL, function () {
return _this5.seekPercentage(percentage);
});
}
};
Flash.prototype.seek = function seek(time) {
var _this6 = this;
if (this.isReady && this.el.playerSeek) {
this.el.playerSeek(time);
this.trigger(_events2.default.PLAYBACK_TIMEUPDATE, { current: time, total: this.el.getDuration() }, this.name);
if (this._currentState === 'PAUSED') this.el.playerPause();
} else {
this.listenToOnce(this, _events2.default.PLAYBACK_BUFFERFULL, function () {
return _this6.seek(time);
});
}
};
Flash.prototype.destroy = function destroy() {
clearInterval(this.bootstrapId);
_BaseFlashPlayback.prototype.stopListening.call(this);
this.$el.remove();
};
(0, _createClass3.default)(Flash, [{
key: 'isReady',
get: function get() {
return this._isReadyState;
}
}]);
return Flash;
}(_base_flash_playback2.default);
exports.default = Flash;
Flash.canPlay = function (resource) {
if (!_browser2.default.hasFlash || !resource || resource.constructor !== String) {
return false;
} else {
var resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
return resourceParts.length > 1 && !_browser2.default.isMobile && resourceParts[1].toLowerCase().match(/^(mp4|mov|f4v|3gpp|3gp)$/);
}
};
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/flash/index.js":
/*!**************************************!*\
!*** ./src/playbacks/flash/index.js ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _flash = __webpack_require__(/*! ./flash */ "./src/playbacks/flash/flash.js");
var _flash2 = _interopRequireDefault(_flash);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _flash2.default;
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/flash/public/Player.swf":
/*!***********************************************!*\
!*** ./src/playbacks/flash/public/Player.swf ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "<%=baseUrl%>/4b76590b32dab62bc95c1b7951efae78.swf";
/***/ }),
/***/ "./src/playbacks/flashls/flashls.js":
/*!******************************************!*\
!*** ./src/playbacks/flashls/flashls.js ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");
var _createClass3 = _interopRequireDefault(_createClass2);
var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");
var _inherits3 = _interopRequireDefault(_inherits2);
var _base_flash_playback = __webpack_require__(/*! ../../playbacks/base_flash_playback */ "./src/playbacks/base_flash_playback/index.js");
var _base_flash_playback2 = _interopRequireDefault(_base_flash_playback);
var _events = __webpack_require__(/*! ../../base/events */ "./src/base/events.js");
var _events2 = _interopRequireDefault(_events);
var _template = __webpack_require__(/*! ../../base/template */ "./src/base/template.js");
var _template2 = _interopRequireDefault(_template);
var _playback = __webpack_require__(/*! ../../base/playback */ "./src/base/playback.js");
var _playback2 = _interopRequireDefault(_playback);
var _mediator = __webpack_require__(/*! ../../components/mediator */ "./src/components/mediator.js");
var _mediator2 = _interopRequireDefault(_mediator);
var _browser = __webpack_require__(/*! ../../components/browser */ "./src/components/browser/index.js");
var _browser2 = _interopRequireDefault(_browser);
var _error = __webpack_require__(/*! ../../components/error */ "./src/components/error/index.js");
var _error2 = _interopRequireDefault(_error);
var _flashls_events = __webpack_require__(/*! ./flashls_events */ "./src/playbacks/flashls/flashls_events.js");
var _flashls_events2 = _interopRequireDefault(_flashls_events);
var _HLSPlayer = __webpack_require__(/*! ./public/HLSPlayer.swf */ "./src/playbacks/flashls/public/HLSPlayer.swf");
var _HLSPlayer2 = _interopRequireDefault(_HLSPlayer);
var _clapprZepto = __webpack_require__(/*! clappr-zepto */ "./node_modules/clappr-zepto/zepto.js");
var _clapprZepto2 = _interopRequireDefault(_clapprZepto);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Copyright 2014 Globo.com Player authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
var MAX_ATTEMPTS = 60;
var AUTO = -1;
var FlasHLS = function (_BaseFlashPlayback) {
(0, _inherits3.default)(FlasHLS, _BaseFlashPlayback);
(0, _createClass3.default)(FlasHLS, [{
key: 'name',
get: function get() {
return 'flashls';
}
}, {
key: 'swfPath',
get: function get() {
return (0, _template2.default)(_HLSPlayer2.default)({ baseUrl: this._baseUrl });
}
}, {
key: 'levels',
get: function get() {
return this._levels || [];
}
}, {
key: 'currentLevel',
get: function get() {
if (this._currentLevel === null || this._currentLevel === undefined) return AUTO;else return this._currentLevel; //0 is a valid level ID
},
set: function set(id) {
this._currentLevel = id;
this.trigger(_events2.default.PLAYBACK_LEVEL_SWITCH_START);
this.el.playerSetCurrentLevel(id);
}
/**
* Determine if the playback has ended.
* @property ended
* @type Boolean
*/
}, {
key: 'ended',
get: function get() {
return this._hasEnded;
}
/**
* Determine if the playback is buffering.
* This is related to the PLAYBACK_BUFFERING and PLAYBACK_BUFFERFULL events
* @property buffering
* @type Boolean
*/
}, {
key: 'buffering',
get: function get() {
return !!this._bufferingState && !this._hasEnded;
}
}]);
function FlasHLS() {
(0, _classCallCheck3.default)(this, FlasHLS);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var _this = (0, _possibleConstructorReturn3.default)(this, _BaseFlashPlayback.call.apply(_BaseFlashPlayback, [this].concat(args)));
_this._src = _this.options.src;
_this._baseUrl = _this.options.baseUrl;
_this._initHlsParameters(_this.options);
// TODO can this be private?
_this.highDefinition = false;
_this._autoPlay = _this.options.autoPlay;
_this._loop = _this.options.loop;
_this._defaultSettings = {
left: ['playstop'],
default: ['seekbar'],
right: ['fullscreen', 'volume', 'hd-indicator'],
seekEnabled: false
};
_this.settings = _clapprZepto2.default.extend({}, _this._defaultSettings);
_this._playbackType = _playback2.default.LIVE;
_this._hasEnded = false;
_this._addListeners();
return _this;
}
FlasHLS.prototype._initHlsParameters = function _initHlsParameters(options) {
this._autoStartLoad = options.autoStartLoad === undefined ? true : options.autoStartLoad;
this._capLevelToStage = options.capLevelToStage === undefined ? false : options.capLevelToStage;
this._maxLevelCappingMode = options.maxLevelCappingMode === undefined ? 'downscale' : options.maxLevelCappingMode;
this._minBufferLength = options.minBufferLength === undefined ? -1 : options.minBufferLength;
this._minBufferLengthCapping = options.minBufferLengthCapping === undefined ? -1 : options.minBufferLengthCapping;
this._maxBufferLength = options.maxBufferLength === undefined ? 120 : options.maxBufferLength;
this._maxBackBufferLength = options.maxBackBufferLength === undefined ? 30 : options.maxBackBufferLength;
this._lowBufferLength = options.lowBufferLength === undefined ? 3 : options.lowBufferLength;
this._mediaTimePeriod = options.mediaTimePeriod === undefined ? 100 : options.mediaTimePeriod;
this._fpsDroppedMonitoringPeriod = options.fpsDroppedMonitoringPeriod === undefined ? 5000 : options.fpsDroppedMonitoringPeriod;
this._fpsDroppedMonitoringThreshold = options.fpsDroppedMonitoringThreshold === undefined ? 0.2 : options.fpsDroppedMonitoringThreshold;
this._capLevelonFPSDrop = options.capLevelonFPSDrop === undefined ? false : options.capLevelonFPSDrop;
this._smoothAutoSwitchonFPSDrop = options.smoothAutoSwitchonFPSDrop === undefined ? this.capLevelonFPSDrop : options.smoothAutoSwitchonFPSDrop;
this._switchDownOnLevelError = options.switchDownOnLevelError === undefined ? true : options.switchDownOnLevelError;
this._seekMode = options.seekMode === undefined ? 'ACCURATE' : options.seekMode;
this._keyLoadMaxRetry = options.keyLoadMaxRetry === undefined ? 3 : options.keyLoadMaxRetry;
this._keyLoadMaxRetryTimeout = options.keyLoadMaxRetryTimeout === undefined ? 64000 : options.keyLoadMaxRetryTimeout;
this._fragmentLoadMaxRetry = options.fragmentLoadMaxRetry === undefined ? 3 : options.fragmentLoadMaxRetry;
this._fragmentLoadMaxRetryTimeout = options.fragmentLoadMaxRetryTimeout === undefined ? 4000 : options.fragmentLoadMaxRetryTimeout;
this._fragmentLoadSkipAfterMaxRetry = options.fragmentLoadSkipAfterMaxRetry === undefined ? true : options.fragmentLoadSkipAfterMaxRetry;
this._maxSkippedFragments = options.maxSkippedFragments === undefined ? 5 : options.maxSkippedFragments;
this._flushLiveURLCache = options.flushLiveURLCache === undefined ? false : options.flushLiveURLCache;
this._initialLiveManifestSize = options.initialLiveManifestSize === undefined ? 1 : options.initialLiveManifestSize;
this._manifestLoadMaxRetry = options.manifestLoadMaxRetry === undefined ? 3 : options.manifestLoadMaxRetry;
this._manifestLoadMaxRetryTimeout = options.manifestLoadMaxRetryTimeout === undefined ? 64000 : options.manifestLoadMaxRetryTimeout;
this._manifestRedundantLoadmaxRetry = options.manifestRedundantLoadmaxRetry === undefined ? 3 : options.manifestRedundantLoadmaxRetry;
this._startFromBitrate = options.startFromBitrate === undefined ? -1 : options.startFromBitrate;
this._startFromLevel = options.startFromLevel === undefined ? -1 : options.startFromLevel;
this._autoStartMaxDuration = options.autoStartMaxDuration === undefined ? -1 : options.autoStartMaxDuration;
this._seekFromLevel = options.seekFromLevel === undefined ? -1 : options.seekFromLevel;
this._useHardwareVideoDecoder = options.useHardwareVideoDecoder === undefined ? false : options.useHardwareVideoDecoder;
this._hlsLogEnabled = options.hlsLogEnabled === undefined ? true : options.hlsLogEnabled;
this._logDebug = options.logDebug === undefined ? false : options.logDebug;
this._logDebug2 = options.logDebug2 === undefined ? false : options.logDebug2;
this._logWarn = options.logWarn === undefined ? true : options.logWarn;
this._logError = options.logError === undefined ? true : options.logError;
this._hlsMinimumDvrSize = options.hlsMinimumDvrSize === undefined ? 60 : options.hlsMinimumDvrSize;
};
FlasHLS.prototype._addListeners = function _addListeners() {
var _this2 = this;
_mediator2.default.on(this.cid + ':flashready', function () {
return _this2._bootstrap();
});
_mediator2.default.on(this.cid + ':timeupdate', function (timeMetrics) {
return _this2._updateTime(timeMetrics);
});
_mediator2.default.on(this.cid + ':playbackstate', function (state) {
return _this2._setPlaybackState(state);
});
_mediator2.default.on(this.cid + ':levelchanged', function (level) {
return _this2._levelChanged(level);
});
_mediator2.default.on(this.cid + ':error', function (code, url, message) {
return _this2._flashPlaybackError(code, url, message);
});
_mediator2.default.on(this.cid + ':fragmentloaded', function (loadmetrics) {
return _this2._onFragmentLoaded(loadmetrics);
});
_mediator2.default.on(this.cid + ':levelendlist', function (level) {
return _this2._onLevelEndlist(level);
});
};
FlasHLS.prototype.stopListening = function stopListening() {
_BaseFlashPlayback.prototype.stopListening.call(this);
_mediator2.default.off(this.cid + ':flashready');
_mediator2.default.off(this.cid + ':timeupdate');
_mediator2.default.off(this.cid + ':playbackstate');
_mediator2.default.off(this.cid + ':levelchanged');
_mediator2.default.off(this.cid + ':playbackerror');
_mediator2.default.off(this.cid + ':fragmentloaded');
_mediator2.default.off(this.cid + ':manifestloaded');
_mediator2.default.off(this.cid + ':levelendlist');
};
FlasHLS.prototype._bootstrap = function _bootstrap() {
var _this3 = this;
if (this.el.playerLoad) {
this.el.width = '100%';
this.el.height = '100%';
this._isReadyState = true;
this._srcLoaded = false;
this._currentState = 'IDLE';
this._setFlashSettings();
this._updatePlaybackType();
if (this._autoPlay || this._shouldPlayOnManifestLoaded) this.play();
this.trigger(_events2.default.PLAYBACK_READY, this.name);
} else {
this._bootstrapAttempts = this._bootstrapAttempts || 0;
if (++this._bootstrapAttempts <= MAX_ATTEMPTS) {
setTimeout(function () {
return _this3._bootstrap();
}, 50);
} else {
var formattedError = this.createError({
code: 'playerLoadFail_maxNumberAttemptsReached',
description: this.name + ' error: Max number of attempts reached',
level: _error2.default.Levels.FATAL,
raw: {}
});
this.trigger(_events2.default.PLAYBACK_ERROR, formattedError);
}
}
};
FlasHLS.prototype._setFlashSettings = function _setFlashSettings() {
this.el.playerSetAutoStartLoad(this._autoStartLoad);
this.el.playerSetCapLevelToStage(this._capLevelToStage);
this.el.playerSetMaxLevelCappingMode(this._maxLevelCappingMode);
this.el.playerSetMinBufferLength(this._minBufferLength);
this.el.playerSetMinBufferLengthCapping(this._minBufferLengthCapping);
this.el.playerSetMaxBufferLength(this._maxBufferLength);
this.el.playerSetMaxBackBufferLength(this._maxBackBufferLength);
this.el.playerSetLowBufferLength(this._lowBufferLength);
this.el.playerSetMediaTimePeriod(this._mediaTimePeriod);
this.el.playerSetFpsDroppedMonitoringPeriod(this._fpsDroppedMonitoringPeriod);
this.el.playerSetFpsDroppedMonitoringThreshold(this._fpsDroppedMonitoringThreshold);
this.el.playerSetCapLevelonFPSDrop(this._capLevelonFPSDrop);
this.el.playerSetSmoothAutoSwitchonFPSDrop(this._smoothAutoSwitchonFPSDrop);
this.el.playerSetSwitchDownOnLevelError(this._switchDownOnLevelError);
this.el.playerSetSeekMode(this._seekMode);
this.el.playerSetKeyLoadMaxRetry(this._keyLoadMaxRetry);
this.el.playerSetKeyLoadMaxRetryTimeout(this._keyLoadMaxRetryTimeout);
this.el.playerSetFragmentLoadMaxRetry(this._fragmentLoadMaxRetry);
this.el.playerSetFragmentLoadMaxRetryTimeout(this._fragmentLoadMaxRetryTimeout);
this.el.playerSetFragmentLoadSkipAfterMaxRetry(this._fragmentLoadSkipAfterMaxRetry);
this.el.playerSetMaxSkippedFragments(this._maxSkippedFragments);
this.el.playerSetFlushLiveURLCache(this._flushLiveURLCache);
this.el.playerSetInitialLiveManifestSize(this._initialLiveManifestSize);
this.el.playerSetManifestLoadMaxRetry(this._manifestLoadMaxRetry);
this.el.playerSetManifestLoadMaxRetryTimeout(this._manifestLoadMaxRetryTimeout);
this.el.playerSetManifestRedundantLoadmaxRetry(this._manifestRedundantLoadmaxRetry);
this.el.playerSetStartFromBitrate(this._startFromBitrate);
this.el.playerSetStartFromLevel(this._startFromLevel);
this.el.playerSetAutoStartMaxDuration(this._autoStartMaxDuration);
this.el.playerSetSeekFromLevel(this._seekFromLevel);
this.el.playerSetUseHardwareVideoDecoder(this._useHardwareVideoDecoder);
this.el.playerSetLogInfo(this._hlsLogEnabled);
this.el.playerSetLogDebug(this._logDebug);
this.el.playerSetLogDebug2(this._logDebug2);
this.el.playerSetLogWarn(this._logWarn);
this.el.playerSetLogError(this._logError);
};
FlasHLS.prototype.setAutoStartLoad = function setAutoStartLoad(autoStartLoad) {
this._autoStartLoad = autoStartLoad;
this.el.playerSetAutoStartLoad(this._autoStartLoad);
};
FlasHLS.prototype.setCapLevelToStage = function setCapLevelToStage(capLevelToStage) {
this._capLevelToStage = capLevelToStage;
this.el.playerSetCapLevelToStage(this._capLevelToStage);
};
FlasHLS.prototype.setMaxLevelCappingMode = function setMaxLevelCappingMode(maxLevelCappingMode) {
this._maxLevelCappingMode = maxLevelCappingMode;
this.el.playerSetMaxLevelCappingMode(this._maxLevelCappingMode);
};
FlasHLS.prototype.setSetMinBufferLength = function setSetMinBufferLength(minBufferLength) {
this._minBufferLength = minBufferLength;
this.el.playerSetMinBufferLength(this._minBufferLength);
};
FlasHLS.prototype.setMinBufferLengthCapping = function setMinBufferLengthCapping(minBufferLengthCapping) {
this._minBufferLengthCapping = minBufferLengthCapping;
this.el.playerSetMinBufferLengthCapping(this._minBufferLengthCapping);
};
FlasHLS.prototype.setMaxBufferLength = function setMaxBufferLength(maxBufferLength) {
this._maxBufferLength = maxBufferLength;
this.el.playerSetMaxBufferLength(this._maxBufferLength);
};
FlasHLS.prototype.setMaxBackBufferLength = function setMaxBackBufferLength(maxBackBufferLength) {
this._maxBackBufferLength = maxBackBufferLength;
this.el.playerSetMaxBackBufferLength(this._maxBackBufferLength);
};
FlasHLS.prototype.setLowBufferLength = function setLowBufferLength(lowBufferLength) {
this._lowBufferLength = lowBufferLength;
this.el.playerSetLowBufferLength(this._lowBufferLength);
};
FlasHLS.prototype.setMediaTimePeriod = function setMediaTimePeriod(mediaTimePeriod) {
this._mediaTimePeriod = mediaTimePeriod;
this.el.playerSetMediaTimePeriod(this._mediaTimePeriod);
};
FlasHLS.prototype.setFpsDroppedMonitoringPeriod = function setFpsDroppedMonitoringPeriod(fpsDroppedMonitoringPeriod) {
this._fpsDroppedMonitoringPeriod = fpsDroppedMonitoringPeriod;
this.el.playerSetFpsDroppedMonitoringPeriod(this._fpsDroppedMonitoringPeriod);
};
FlasHLS.prototype.setFpsDroppedMonitoringThreshold = function setFpsDroppedMonitoringThreshold(fpsDroppedMonitoringThreshold) {
this._fpsDroppedMonitoringThreshold = fpsDroppedMonitoringThreshold;
this.el.playerSetFpsDroppedMonitoringThreshold(this._fpsDroppedMonitoringThreshold);
};
FlasHLS.prototype.setCapLevelonFPSDrop = function setCapLevelonFPSDrop(capLevelonFPSDrop) {
this._capLevelonFPSDrop = capLevelonFPSDrop;
this.el.playerSetCapLevelonFPSDrop(this._capLevelonFPSDrop);
};
FlasHLS.prototype.setSmoothAutoSwitchonFPSDrop = function setSmoothAutoSwitchonFPSDrop(smoothAutoSwitchonFPSDrop) {
this._smoothAutoSwitchonFPSDrop = smoothAutoSwitchonFPSDrop;
this.el.playerSetSmoothAutoSwitchonFPSDrop(this._smoothAutoSwitchonFPSDrop);
};
FlasHLS.prototype.setSwitchDownOnLevelError = function setSwitchDownOnLevelError(switchDownOnLevelError) {
this._switchDownOnLevelError = switchDownOnLevelError;
this.el.playerSetSwitchDownOnLevelError(this._switchDownOnLevelError);
};
FlasHLS.prototype.setSeekMode = function setSeekMode(seekMode) {
this._seekMode = seekMode;
this.el.playerSetSeekMode(this._seekMode);
};
FlasHLS.prototype.setKeyLoadMaxRetry = function setKeyLoadMaxRetry(keyLoadMaxRetry) {
this._keyLoadMaxRetry = keyLoadMaxRetry;
this.el.playerSetKeyLoadMaxRetry(this._keyLoadMaxRetry);
};
FlasHLS.prototype.setKeyLoadMaxRetryTimeout = function setKeyLoadMaxRetryTimeout(keyLoadMaxRetryTimeout) {
this._keyLoadMaxRetryTimeout = keyLoadMaxRetryTimeout;
this.el.playerSetKeyLoadMaxRetryTimeout(this._keyLoadMaxRetryTimeout);
};
FlasHLS.prototype.setFragmentLoadMaxRetry = function setFragmentLoadMaxRetry(fragmentLoadMaxRetry) {
this._fragmentLoadMaxRetry = fragmentLoadMaxRetry;
this.el.playerSetFragmentLoadMaxRetry(this._fragmentLoadMaxRetry);
};
FlasHLS.prototype.setFragmentLoadMaxRetryTimeout = function setFragmentLoadMaxRetryTimeout(fragmentLoadMaxRetryTimeout) {
this._fragmentLoadMaxRetryTimeout = fragmentLoadMaxRetryTimeout;
this.el.playerSetFragmentLoadMaxRetryTimeout(this._fragmentLoadMaxRetryTimeout);
};
FlasHLS.prototype.setFragmentLoadSkipAfterMaxRetry = function setFragmentLoadSkipAfterMaxRetry(fragmentLoadSkipAfterMaxRetry) {
this._fragmentLoadSkipAfterMaxRetry = fragmentLoadSkipAfterMaxRetry;
this.el.playerSetFragmentLoadSkipAfterMaxRetry(this._fragmentLoadSkipAfterMaxRetry);
};
FlasHLS.prototype.setMaxSkippedFragments = function setMaxSkippedFragments(maxSkippedFragments) {
this._maxSkippedFragments = maxSkippedFragments;
this.el.playerSetMaxSkippedFragments(this._maxSkippedFragments);
};
FlasHLS.prototype.setFlushLiveURLCache = function setFlushLiveURLCache(flushLiveURLCache) {
this._flushLiveURLCache = flushLiveURLCache;
this.el.playerSetFlushLiveURLCache(this._flushLiveURLCache);
};
FlasHLS.prototype.setInitialLiveManifestSize = function setInitialLiveManifestSize(initialLiveManifestSize) {
this._initialLiveManifestSize = initialLiveManifestSize;
this.el.playerSetInitialLiveManifestSize(this._initialLiveManifestSize);
};
FlasHLS.prototype.setManifestLoadMaxRetry = function setManifestLoadMaxRetry(manifestLoadMaxRetry) {
this._manifestLoadMaxRetry = manifestLoadMaxRetry;
this.el.playerSetManifestLoadMaxRetry(this._manifestLoadMaxRetry);
};
FlasHLS.prototype.setManifestLoadMaxRetryTimeout = function setManifestLoadMaxRetryTimeout(manifestLoadMaxRetryTimeout) {
this._manifestLoadMaxRetryTimeout = manifestLoadMaxRetryTimeout;
this.el.playerSetManifestLoadMaxRetryTimeout(this._manifestLoadMaxRetryTimeout);
};
FlasHLS.prototype.setManifestRedundantLoadmaxRetry = function setManifestRedundantLoadmaxRetry(manifestRedundantLoadmaxRetry) {
this._manifestRedundantLoadmaxRetry = manifestRedundantLoadmaxRetry;
this.el.playerSetManifestRedundantLoadmaxRetry(this._manifestRedundantLoadmaxRetry);
};
FlasHLS.prototype.setStartFromBitrate = function setStartFromBitrate(startFromBitrate) {
this._startFromBitrate = startFromBitrate;
this.el.playerSetStartFromBitrate(this._startFromBitrate);
};
FlasHLS.prototype.setStartFromLevel = function setStartFromLevel(startFromLevel) {
this._startFromLevel = startFromLevel;
this.el.playerSetStartFromLevel(this._startFromLevel);
};
FlasHLS.prototype.setAutoStartMaxDuration = function setAutoStartMaxDuration(autoStartMaxDuration) {
this._autoStartMaxDuration = autoStartMaxDuration;
this.el.playerSetAutoStartMaxDuration(this._autoStartMaxDuration);
};
FlasHLS.prototype.setSeekFromLevel = function setSeekFromLevel(seekFromLevel) {
this._seekFromLevel = seekFromLevel;
this.el.playerSetSeekFromLevel(this._seekFromLevel);
};
FlasHLS.prototype.setUseHardwareVideoDecoder = function setUseHardwareVideoDecoder(useHardwareVideoDecoder) {
this._useHardwareVideoDecoder = useHardwareVideoDecoder;
this.el.playerSetUseHardwareVideoDecoder(this._useHardwareVideoDecoder);
};
FlasHLS.prototype.setSetLogInfo = function setSetLogInfo(hlsLogEnabled) {
this._hlsLogEnabled = hlsLogEnabled;
this.el.playerSetLogInfo(this._hlsLogEnabled);
};
FlasHLS.prototype.setLogDebug = function setLogDebug(logDebug) {
this._logDebug = logDebug;
this.el.playerSetLogDebug(this._logDebug);
};
FlasHLS.prototype.setLogDebug2 = function setLogDebug2(logDebug2) {
this._logDebug2 = logDebug2;
this.el.playerSetLogDebug2(this._logDebug2);
};
FlasHLS.prototype.setLogWarn = function setLogWarn(logWarn) {
this._logWarn = logWarn;
this.el.playerSetLogWarn(this._logWarn);
};
FlasHLS.prototype.setLogError = function setLogError(logError) {
this._logError = logError;
this.el.playerSetLogError(this._logError);
};
FlasHLS.prototype._levelChanged = function _levelChanged(level) {
var currentLevel = this.el.getLevels()[level];
if (currentLevel) {
this.highDefinition = currentLevel.height >= 720 || currentLevel.bitrate / 1000 >= 2000;
this.trigger(_events2.default.PLAYBACK_HIGHDEFINITIONUPDATE, this.highDefinition);
if (!this._levels || this._levels.length === 0) this._fillLevels();
this.trigger(_events2.default.PLAYBACK_BITRATE, {
height: currentLevel.height,
width: currentLevel.width,
bandwidth: currentLevel.bitrate,
bitrate: currentLevel.bitrate,
level: level
});
this.trigger(_events2.default.PLAYBACK_LEVEL_SWITCH_END);
}
};
FlasHLS.prototype._updateTime = function _updateTime(timeMetrics) {
if (this._currentState === 'IDLE') return;
var duration = this._normalizeDuration(timeMetrics.duration);
var position = Math.min(Math.max(timeMetrics.position, 0), duration);
var previousDVRStatus = this._dvrEnabled;
var livePlayback = this._playbackType === _playback2.default.LIVE;
this._dvrEnabled = livePlayback && duration > this._hlsMinimumDvrSize;
if (duration === 100 || livePlayback === undefined) return;
if (this._dvrEnabled !== previousDVRStatus) {
this._updateSettings();
this.trigger(_events2.default.PLAYBACK_SETTINGSUPDATE, this.name);
}
if (livePlayback && !this._dvrEnabled) position = duration;
this.trigger(_events2.default.PLAYBACK_TIMEUPDATE, { current: position, total: duration }, this.name);
};
FlasHLS.prototype.play = function play() {
this.trigger(_events2.default.PLAYBACK_PLAY_INTENT);
if (this._currentState === 'PAUSED') this.el.playerResume();else if (!this._srcLoaded && this._currentState !== 'PLAYING') this._firstPlay();else this.el.playerPlay();
};
FlasHLS.prototype.getPlaybackType = function getPlaybackType() {
return this._playbackType ? this._playbackType : null;
};
FlasHLS.prototype.getCurrentTime = function getCurrentTime() {
return this.el.getPosition();
};
FlasHLS.prototype.getCurrentLevelIndex = function getCurrentLevelIndex() {
return this._currentLevel;
};
FlasHLS.prototype.getCurrentLevel = function getCurrentLevel() {
return this.levels[this.currentLevel];
};
FlasHLS.prototype.getCurrentBitrate = function getCurrentBitrate() {
return this.levels[this.currentLevel].bitrate;
};
FlasHLS.prototype.setCurrentLevel = function setCurrentLevel(level) {
this.currentLevel = level;
};
FlasHLS.prototype.isHighDefinitionInUse = function isHighDefinitionInUse() {
return this.highDefinition;
};
FlasHLS.prototype.getLevels = function getLevels() {
return this.levels;
};
FlasHLS.prototype._setPlaybackState = function _setPlaybackState(state) {
if (['PLAYING_BUFFERING', 'PAUSED_BUFFERING'].indexOf(state) >= 0) {
this._bufferingState = true;
this.trigger(_events2.default.PLAYBACK_BUFFERING, this.name);
this._updateCurrentState(state);
} else if (['PLAYING', 'PAUSED'].indexOf(state) >= 0) {
if (['PLAYING_BUFFERING', 'PAUSED_BUFFERING', 'IDLE'].indexOf(this._currentState) >= 0) {
this._bufferingState = false;
this.trigger(_events2.default.PLAYBACK_BUFFERFULL, this.name);
}
this._updateCurrentState(state);
} else if (state === 'IDLE') {
this._srcLoaded = false;
if (this._loop && ['PLAYING_BUFFERING', 'PLAYING'].indexOf(this._currentState) >= 0) {
this.play();
this.seek(0);
} else {
this._updateCurrentState(state);
this._hasEnded = true;
this.trigger(_events2.default.PLAYBACK_TIMEUPDATE, { current: 0, total: this.getDuration() }, this.name);
this.trigger(_events2.default.PLAYBACK_ENDED, this.name);
}
}
};
FlasHLS.prototype._updateCurrentState = function _updateCurrentState(state) {
this._currentState = state;
if (state !== 'IDLE') this._hasEnded = false;
this._updatePlaybackType();
if (state === 'PLAYING') this.trigger(_events2.default.PLAYBACK_PLAY, this.name);else if (state === 'PAUSED') this.trigger(_events2.default.PLAYBACK_PAUSE, this.name);
};
FlasHLS.prototype._updatePlaybackType = function _updatePlaybackType() {
this._playbackType = this.el.getType();
if (this._playbackType) {
this._playbackType = this._playbackType.toLowerCase();
if (this._playbackType === _playback2.default.VOD) this._startReportingProgress();else this._stopReportingProgress();
}
this.trigger(_events2.default.PLAYBACK_PLAYBACKSTATE, { type: this._playbackType });
};
FlasHLS.prototype._startReportingProgress = function _startReportingProgress() {
if (!this._reportingProgress) this._reportingProgress = true;
};
FlasHLS.prototype._stopReportingProgress = function _stopReportingProgress() {
this._reportingProgress = false;
};
FlasHLS.prototype._onFragmentLoaded = function _onFragmentLoaded(loadmetrics) {
this.trigger(_events2.default.PLAYBACK_FRAGMENT_LOADED, loadmetrics);
if (this._reportingProgress && this.getCurrentTime()) {
var buffered = this.getCurrentTime() + this.el.getbufferLength();
this.trigger(_events2.default.PLAYBACK_PROGRESS, {
start: this.getCurrentTime(),
current: buffered,
total: this.el.getDuration()
});
}
};
FlasHLS.prototype._onLevelEndlist = function _onLevelEndlist() {
this._updatePlaybackType();
};
FlasHLS.prototype._firstPlay = function _firstPlay() {
var _this4 = this;
this._shouldPlayOnManifestLoaded = true;
if (this.el.playerLoad) {
_mediator2.default.once(this.cid + ':manifestloaded', function (duration, loadmetrics) {
return _this4._manifestLoaded(duration, loadmetrics);
});
this._setFlashSettings(); //ensure flushLiveURLCache will work (#327)
this.el.playerLoad(this._src);
this._srcLoaded = true;
}
};
FlasHLS.prototype.volume = function volume(value) {
var _this5 = this;
if (this.isReady) this.el.playerVolume(value);else this.listenToOnce(this, _events2.default.PLAYBACK_BUFFERFULL, function () {
return _this5.volume(value);
});
};
FlasHLS.prototype.pause = function pause() {
if (this._playbackType !== _playback2.default.LIVE || this._dvrEnabled) {
this.el.playerPause();
if (this._playbackType === _playback2.default.LIVE && this._dvrEnabled) this._updateDvr(true);
}
};
FlasHLS.prototype.stop = function stop() {
this._srcLoaded = false;
this.el.playerStop();
this.trigger(_events2.default.PLAYBACK_STOP);
this.trigger(_events2.default.PLAYBACK_TIMEUPDATE, { current: 0, total: 0 }, this.name);
};
FlasHLS.prototype.isPlaying = function isPlaying() {
if (this._currentState) return !!this._currentState.match(/playing/i);
return false;
};
FlasHLS.prototype.getDuration = function getDuration() {
return this._normalizeDuration(this.el.getDuration());
};
FlasHLS.prototype._normalizeDuration = function _normalizeDuration(duration) {
if (this._playbackType === _playback2.default.LIVE) {
// estimate 10 seconds of buffer time for live streams for seek positions
duration = Math.max(0, duration - 10);
}
return duration;
};
FlasHLS.prototype.seekPercentage = function seekPercentage(percentage) {
var duration = this.el.getDuration();
var time = 0;
if (percentage > 0) time = duration * percentage / 100;
this.seek(time);
};
FlasHLS.prototype.seek = function seek(time) {
var duration = this.getDuration();
if (this._playbackType === _playback2.default.LIVE) {
// seek operations to a time within 3 seconds from live stream will position playhead back to live
var dvrInUse = duration - time > 3;
this._updateDvr(dvrInUse);
}
this.el.playerSeek(time);
this.trigger(_events2.default.PLAYBACK_TIMEUPDATE, { current: time, total: duration }, this.name);
};
FlasHLS.prototype._updateDvr = function _updateDvr(dvrInUse) {
var previousDvrInUse = !!this._dvrInUse;
this._dvrInUse = dvrInUse;
if (this._dvrInUse !== previousDvrInUse) {
this._updateSettings();
this.trigger(_events2.default.PLAYBACK_DVR, this._dvrInUse);
this.trigger(_events2.default.PLAYBACK_STATS_ADD, { 'dvr': this._dvrInUse });
}
};
FlasHLS.prototype._flashPlaybackError = function _flashPlaybackError(code, url, message) {
var error = {
code: code,
description: message,
level: _error2.default.Levels.FATAL,
raw: { code: code, url: url, message: message }
};
var formattedError = this.createError(error);
this.trigger(_events2.default.PLAYBACK_ERROR, formattedError);
this.trigger(_events2.default.PLAYBACK_STOP);
};
FlasHLS.prototype._manifestLoaded = function _manifestLoaded(duration, loadmetrics) {
if (this._shouldPlayOnManifestLoaded) {
this._shouldPlayOnManifestLoaded = false;
// this method initialises the player (and starts playback)
// this needs to happen before PLAYBACK_LOADEDMETADATA is fired
// as the user may call seek() in a LOADEDMETADATA listener.
/// when playerPlay() is called the player seeks to 0
this.el.playerPlay();
}
this._fillLevels();
this.trigger(_events2.default.PLAYBACK_LOADEDMETADATA, { duration: duration, data: loadmetrics });
};
FlasHLS.prototype._fillLevels = function _fillLevels() {
var levels = this.el.getLevels();
var levelsLength = levels.length;
this._levels = [];
for (var index = 0; index < levelsLength; index++) {
this._levels.push({ id: index, label: levels[index].height + 'p', level: levels[index] });
}this.trigger(_events2.default.PLAYBACK_LEVELS_AVAILABLE, this._levels);
};
FlasHLS.prototype.destroy = function destroy() {
this.stopListening();
this.$el.remove();
};
FlasHLS.prototype._updateSettings = function _updateSettings() {
this.settings = _clapprZepto2.default.extend({}, this._defaultSettings);
if (this._playbackType === _playback2.default.VOD || this._dvrInUse) {
this.settings.left = ['playpause', 'position', 'duration'];
this.settings.seekEnabled = true;
} else if (this._dvrEnabled) {
this.settings.left = ['playpause'];
this.settings.seekEnabled = true;
} else {
this.settings.seekEnabled = false;
}
};
FlasHLS.prototype._createCallbacks = function _createCallbacks() {
var _this6 = this;
if (!window.Clappr) window.Clappr = {};
if (!window.Clappr.flashlsCallbacks) window.Clappr.flashlsCallbacks = {};
this.flashlsEvents = new _flashls_events2.default(this.cid);
window.Clappr.flashlsCallbacks[this.cid] = function (eventName, args) {
_this6.flashlsEvents[eventName].apply(_this6.flashlsEvents, args);
};
};
FlasHLS.prototype.render = function render() {
_BaseFlashPlayback.prototype.render.call(this);
this._createCallbacks();
return this;
};
(0, _createClass3.default)(FlasHLS, [{
key: 'isReady',
get: function get() {
return this._isReadyState;
}
}, {
key: 'dvrEnabled',
get: function get() {
return !!this._dvrEnabled;
}
}]);
return FlasHLS;
}(_base_flash_playback2.default);
exports.default = FlasHLS;
FlasHLS.canPlay = function (resource, mimeType) {
var resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
return _browser2.default.hasFlash && (resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'm3u8' || mimeType === 'application/x-mpegURL' || mimeType === 'application/vnd.apple.mpegurl');
};
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/flashls/flashls_events.js":
/*!*************************************************!*\
!*** ./src/playbacks/flashls/flashls_events.js ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _mediator = __webpack_require__(/*! ../../components/mediator */ "./src/components/mediator.js");
var _mediator2 = _interopRequireDefault(_mediator);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var HLSEvents = function () {
function HLSEvents(instanceId) {
(0, _classCallCheck3.default)(this, HLSEvents);
this.instanceId = instanceId;
}
HLSEvents.prototype.ready = function ready() {
_mediator2.default.trigger(this.instanceId + ':flashready');
};
HLSEvents.prototype.videoSize = function videoSize(width, height) {
_mediator2.default.trigger(this.instanceId + ':videosizechanged', width, height);
};
HLSEvents.prototype.complete = function complete() {
_mediator2.default.trigger(this.instanceId + ':complete');
};
HLSEvents.prototype.error = function error(code, url, message) {
_mediator2.default.trigger(this.instanceId + ':error', code, url, message);
};
HLSEvents.prototype.manifest = function manifest(duration, loadmetrics) {
_mediator2.default.trigger(this.instanceId + ':manifestloaded', duration, loadmetrics);
};
HLSEvents.prototype.audioLevelLoaded = function audioLevelLoaded(loadmetrics) {
_mediator2.default.trigger(this.instanceId + ':audiolevelloaded', loadmetrics);
};
HLSEvents.prototype.levelLoaded = function levelLoaded(loadmetrics) {
_mediator2.default.trigger(this.instanceId + ':levelloaded', loadmetrics);
};
HLSEvents.prototype.levelEndlist = function levelEndlist(level) {
_mediator2.default.trigger(this.instanceId + ':levelendlist', level);
};
HLSEvents.prototype.fragmentLoaded = function fragmentLoaded(loadmetrics) {
_mediator2.default.trigger(this.instanceId + ':fragmentloaded', loadmetrics);
};
HLSEvents.prototype.fragmentPlaying = function fragmentPlaying(playmetrics) {
_mediator2.default.trigger(this.instanceId + ':fragmentplaying', playmetrics);
};
HLSEvents.prototype.position = function position(timemetrics) {
_mediator2.default.trigger(this.instanceId + ':timeupdate', timemetrics);
};
HLSEvents.prototype.state = function state(newState) {
_mediator2.default.trigger(this.instanceId + ':playbackstate', newState);
};
HLSEvents.prototype.seekState = function seekState(newState) {
_mediator2.default.trigger(this.instanceId + ':seekstate', newState);
};
HLSEvents.prototype.switch = function _switch(newLevel) {
_mediator2.default.trigger(this.instanceId + ':levelchanged', newLevel);
};
HLSEvents.prototype.audioTracksListChange = function audioTracksListChange(trackList) {
_mediator2.default.trigger(this.instanceId + ':audiotracklistchanged', trackList);
};
HLSEvents.prototype.audioTrackChange = function audioTrackChange(trackId) {
_mediator2.default.trigger(this.instanceId + ':audiotrackchanged', trackId);
};
return HLSEvents;
}();
exports.default = HLSEvents;
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/flashls/index.js":
/*!****************************************!*\
!*** ./src/playbacks/flashls/index.js ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _flashls = __webpack_require__(/*! ./flashls */ "./src/playbacks/flashls/flashls.js");
var _flashls2 = _interopRequireDefault(_flashls);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _flashls2.default;
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/flashls/public/HLSPlayer.swf":
/*!****************************************************!*\
!*** ./src/playbacks/flashls/public/HLSPlayer.swf ***!
\****************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "<%=baseUrl%>/8fa12a459188502b9f0d39b8a67d9e6c.swf";
/***/ }),
/***/ "./src/playbacks/hls/hls.js":
/*!**********************************!*\
!*** ./src/playbacks/hls/hls.js ***!
\**********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _toConsumableArray2 = __webpack_require__(/*! babel-runtime/helpers/toConsumableArray */ "./node_modules/babel-runtime/helpers/toConsumableArray.js");
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _stringify = __webpack_require__(/*! babel-runtime/core-js/json/stringify */ "./node_modules/babel-runtime/core-js/json/stringify.js");
var _stringify2 = _interopRequireDefault(_stringify);
var _extends2 = __webpack_require__(/*! babel-runtime/helpers/extends */ "./node_modules/babel-runtime/helpers/extends.js");
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");
var _createClass3 = _interopRequireDefault(_createClass2);
var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");
var _inherits3 = _interopRequireDefault(_inherits2);
var _html5_video = __webpack_require__(/*! ../../playbacks/html5_video */ "./src/playbacks/html5_video/index.js");
var _html5_video2 = _interopRequireDefault(_html5_video);
var _hls = __webpack_require__(/*! hls.js */ "./node_modules/hls.js/dist/hls.js");
var _hls2 = _interopRequireDefault(_hls);
var _events = __webpack_require__(/*! ../../base/events */ "./src/base/events.js");
var _events2 = _interopRequireDefault(_events);
var _playback = __webpack_require__(/*! ../../base/playback */ "./src/base/playback.js");
var _playback2 = _interopRequireDefault(_playback);
var _utils = __webpack_require__(/*! ../../base/utils */ "./src/base/utils.js");
var _log = __webpack_require__(/*! ../../plugins/log */ "./src/plugins/log/index.js");
var _log2 = _interopRequireDefault(_log);
var _error = __webpack_require__(/*! ../../components/error */ "./src/components/error/index.js");
var _error2 = _interopRequireDefault(_error);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var AUTO = -1; // Copyright 2014 Globo.com Player authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
var HLS = function (_HTML5VideoPlayback) {
(0, _inherits3.default)(HLS, _HTML5VideoPlayback);
(0, _createClass3.default)(HLS, [{
key: 'name',
get: function get() {
return 'hls';
}
}, {
key: 'levels',
get: function get() {
return this._levels || [];
}
}, {
key: 'currentLevel',
get: function get() {
if (this._currentLevel === null || this._currentLevel === undefined) return AUTO;else return this._currentLevel; //0 is a valid level ID
},
set: function set(id) {
this._currentLevel = id;
this.trigger(_events2.default.PLAYBACK_LEVEL_SWITCH_START);
if (this.options.playback.hlsUseNextLevel) this._hls.nextLevel = this._currentLevel;else this._hls.currentLevel = this._currentLevel;
}
}, {
key: 'isReady',
get: function get() {
return this._isReadyState;
}
}, {
key: '_startTime',
get: function get() {
if (this._playbackType === _playback2.default.LIVE && this._playlistType !== 'EVENT') return this._extrapolatedStartTime;
return this._playableRegionStartTime;
}
}, {
key: '_now',
get: function get() {
return (0, _utils.now)();
}
// the time in the video element which should represent the start of the sliding window
// extrapolated to increase in real time (instead of jumping as the early segments are removed)
}, {
key: '_extrapolatedStartTime',
get: function get() {
if (!this._localStartTimeCorrelation) return this._playableRegionStartTime;
var corr = this._localStartTimeCorrelation;
var timePassed = this._now - corr.local;
var extrapolatedWindowStartTime = (corr.remote + timePassed) / 1000;
// cap at the end of the extrapolated window duration
return Math.min(extrapolatedWindowStartTime, this._playableRegionStartTime + this._extrapolatedWindowDuration);
}
// the time in the video element which should represent the end of the content
// extrapolated to increase in real time (instead of jumping as segments are added)
}, {
key: '_extrapolatedEndTime',
get: function get() {
var actualEndTime = this._playableRegionStartTime + this._playableRegionDuration;
if (!this._localEndTimeCorrelation) return actualEndTime;
var corr = this._localEndTimeCorrelation;
var timePassed = this._now - corr.local;
var extrapolatedEndTime = (corr.remote + timePassed) / 1000;
return Math.max(actualEndTime - this._extrapolatedWindowDuration, Math.min(extrapolatedEndTime, actualEndTime));
}
}, {
key: '_duration',
get: function get() {
return this._extrapolatedEndTime - this._startTime;
}
// Returns the duration (seconds) of the window that the extrapolated start time is allowed
// to move in before being capped.
// The extrapolated start time should never reach the cap at the end of the window as the
// window should slide as chunks are removed from the start.
// This also applies to the extrapolated end time in the same way.
//
// If chunks aren't being removed for some reason that the start time will reach and remain fixed at
// playableRegionStartTime + extrapolatedWindowDuration
//
// <-- window duration -->
// I.e playableRegionStartTime |-----------------------|
// | --> . . .
// . --> | --> . .
// . . --> | --> .
// . . . --> |
// . . . .
// extrapolatedStartTime
}, {
key: '_extrapolatedWindowDuration',
get: function get() {
if (this._segmentTargetDuration === null) return 0;
return this._extrapolatedWindowNumSegments * this._segmentTargetDuration;
}
}], [{
key: 'HLSJS',
get: function get() {
return _hls2.default;
}
}]);
function HLS() {
(0, _classCallCheck3.default)(this, HLS);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
// backwards compatibility (TODO: remove on 0.3.0)
var _this = (0, _possibleConstructorReturn3.default)(this, _HTML5VideoPlayback.call.apply(_HTML5VideoPlayback, [this].concat(args)));
_this.options.playback = (0, _extends3.default)({}, _this.options, _this.options.playback);
_this._minDvrSize = typeof _this.options.hlsMinimumDvrSize === 'undefined' ? 60 : _this.options.hlsMinimumDvrSize;
// The size of the start time extrapolation window measured as a multiple of segments.
// Should be 2 or higher, or 0 to disable. Should only need to be increased above 2 if more than one segment is
// removed from the start of the playlist at a time. E.g if the playlist is cached for 10 seconds and new chunks are
// added/removed every 5.
_this._extrapolatedWindowNumSegments = !_this.options.playback || typeof _this.options.playback.extrapolatedWindowNumSegments === 'undefined' ? 2 : _this.options.playback.extrapolatedWindowNumSegments;
_this._playbackType = _playback2.default.VOD;
_this._lastTimeUpdate = { current: 0, total: 0 };
_this._lastDuration = null;
// for hls streams which have dvr with a sliding window,
// the content at the start of the playlist is removed as new
// content is appended at the end.
// this means the actual playable start time will increase as the
// start content is deleted
// For streams with dvr where the entire recording is kept from the
// beginning this should stay as 0
_this._playableRegionStartTime = 0;
// {local, remote} remote is the time in the video element that should represent 0
// local is the system time when the 'remote' measurment took place
_this._localStartTimeCorrelation = null;
// {local, remote} remote is the time in the video element that should represents the end
// local is the system time when the 'remote' measurment took place
_this._localEndTimeCorrelation = null;
// if content is removed from the beginning then this empty area should
// be ignored. "playableRegionDuration" excludes the empty area
_this._playableRegionDuration = 0;
// #EXT-X-PROGRAM-DATE-TIME
_this._programDateTime = 0;
// true when the actual duration is longer than hlsjs's live sync point
// when this is false playableRegionDuration will be the actual duration
// when this is true playableRegionDuration will exclude the time after the sync point
_this._durationExcludesAfterLiveSyncPoint = false;
// #EXT-X-TARGETDURATION
_this._segmentTargetDuration = null;
// #EXT-X-PLAYLIST-TYPE
_this._playlistType = null;
_this._recoverAttemptsRemaining = _this.options.hlsRecoverAttempts || 16;
return _this;
}
HLS.prototype._setup = function _setup() {
var _this2 = this;
this._ccIsSetup = false;
this._ccTracksUpdated = false;
this._hls = new _hls2.default((0, _utils.assign)({}, this.options.playback.hlsjsConfig));
this._hls.on(_hls2.default.Events.MEDIA_ATTACHED, function () {
return _this2._hls.loadSource(_this2.options.src);
});
this._hls.on(_hls2.default.Events.LEVEL_LOADED, function (evt, data) {
return _this2._updatePlaybackType(evt, data);
});
this._hls.on(_hls2.default.Events.LEVEL_UPDATED, function (evt, data) {
return _this2._onLevelUpdated(evt, data);
});
this._hls.on(_hls2.default.Events.LEVEL_SWITCHING, function (evt, data) {
return _this2._onLevelSwitch(evt, data);
});
this._hls.on(_hls2.default.Events.FRAG_LOADED, function (evt, data) {
return _this2._onFragmentLoaded(evt, data);
});
this._hls.on(_hls2.default.Events.ERROR, function (evt, data) {
return _this2._onHLSJSError(evt, data);
});
this._hls.on(_hls2.default.Events.SUBTITLE_TRACK_LOADED, function (evt, data) {
return _this2._onSubtitleLoaded(evt, data);
});
this._hls.on(_hls2.default.Events.SUBTITLE_TRACKS_UPDATED, function () {
return _this2._ccTracksUpdated = true;
});
this._hls.attachMedia(this.el);
};
HLS.prototype.render = function render() {
this._ready();
return _HTML5VideoPlayback.prototype.render.call(this);
};
HLS.prototype._ready = function _ready() {
this._isReadyState = true;
this.trigger(_events2.default.PLAYBACK_READY, this.name);
};
HLS.prototype._recover = function _recover(evt, data, error) {
if (!this._recoveredDecodingError) {
this._recoveredDecodingError = true;
this._hls.recoverMediaError();
} else if (!this._recoveredAudioCodecError) {
this._recoveredAudioCodecError = true;
this._hls.swapAudioCodec();
this._hls.recoverMediaError();
} else {
_log2.default.error('hlsjs: failed to recover', { evt: evt, data: data });
error.level = _error2.default.Levels.FATAL;
var formattedError = this.createError(error);
this.trigger(_events2.default.PLAYBACK_ERROR, formattedError);
this.stop();
}
};
// override
HLS.prototype._setupSrc = function _setupSrc(srcUrl) {// eslint-disable-line no-unused-vars
// this playback manages the src on the video element itself
};
HLS.prototype._startTimeUpdateTimer = function _startTimeUpdateTimer() {
var _this3 = this;
if (this._timeUpdateTimer) return;
this._timeUpdateTimer = setInterval(function () {
_this3._onDurationChange();
_this3._onTimeUpdate();
}, 100);
};
HLS.prototype._stopTimeUpdateTimer = function _stopTimeUpdateTimer() {
if (!this._timeUpdateTimer) return;
clearInterval(this._timeUpdateTimer);
this._timeUpdateTimer = null;
};
HLS.prototype.getProgramDateTime = function getProgramDateTime() {
return this._programDateTime;
};
// the duration on the video element itself should not be used
// as this does not necesarily represent the duration of the stream
// https://github.com/clappr/clappr/issues/668#issuecomment-157036678
HLS.prototype.getDuration = function getDuration() {
return this._duration;
};
HLS.prototype.getCurrentTime = function getCurrentTime() {
// e.g. can be < 0 if user pauses near the start
// eventually they will then be kicked to the end by hlsjs if they run out of buffer
// before the official start time
return Math.max(0, this.el.currentTime - this._startTime);
};
// the time that "0" now represents relative to when playback started
// for a stream with a sliding window this will increase as content is
// removed from the beginning
HLS.prototype.getStartTimeOffset = function getStartTimeOffset() {
return this._startTime;
};
HLS.prototype.seekPercentage = function seekPercentage(percentage) {
var seekTo = this._duration;
if (percentage > 0) seekTo = this._duration * (percentage / 100);
this.seek(seekTo);
};
HLS.prototype.seek = function seek(time) {
if (time < 0) {
_log2.default.warn('Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point.');
time = this.getDuration();
}
// assume live if time within 3 seconds of end of stream
this.dvrEnabled && this._updateDvr(time < this.getDuration() - 3);
time += this._startTime;
_HTML5VideoPlayback.prototype.seek.call(this, time);
};
HLS.prototype.seekToLivePoint = function seekToLivePoint() {
this.seek(this.getDuration());
};
HLS.prototype._updateDvr = function _updateDvr(status) {
this.trigger(_events2.default.PLAYBACK_DVR, status);
this.trigger(_events2.default.PLAYBACK_STATS_ADD, { 'dvr': status });
};
HLS.prototype._updateSettings = function _updateSettings() {
if (this._playbackType === _playback2.default.VOD) this.settings.left = ['playpause', 'position', 'duration'];else if (this.dvrEnabled) this.settings.left = ['playpause'];else this.settings.left = ['playstop'];
this.settings.seekEnabled = this.isSeekEnabled();
this.trigger(_events2.default.PLAYBACK_SETTINGSUPDATE);
};
HLS.prototype._onHLSJSError = function _onHLSJSError(evt, data) {
var error = {
code: data.type + '_' + data.details,
description: this.name + ' error: type: ' + data.type + ', details: ' + data.details,
raw: data
};
var formattedError = void 0;
if (data.response) error.description += ', response: ' + (0, _stringify2.default)(data.response);
// only report/handle errors if they are fatal
// hlsjs should automatically handle non fatal errors
if (data.fatal) {
if (this._recoverAttemptsRemaining > 0) {
this._recoverAttemptsRemaining -= 1;
switch (data.type) {
case _hls2.default.ErrorTypes.NETWORK_ERROR:
switch (data.details) {
// The following network errors cannot be recovered with HLS.startLoad()
// For more details, see https://github.com/video-dev/hls.js/blob/master/doc/design.md#error-detection-and-handling
// For "level load" fatal errors, see https://github.com/video-dev/hls.js/issues/1138
case _hls2.default.ErrorDetails.MANIFEST_LOAD_ERROR:
case _hls2.default.ErrorDetails.MANIFEST_LOAD_TIMEOUT:
case _hls2.default.ErrorDetails.MANIFEST_PARSING_ERROR:
case _hls2.default.ErrorDetails.LEVEL_LOAD_ERROR:
case _hls2.default.ErrorDetails.LEVEL_LOAD_TIMEOUT:
_log2.default.error('hlsjs: unrecoverable network fatal error.', { evt: evt, data: data });
formattedError = this.createError(error);
this.trigger(_events2.default.PLAYBACK_ERROR, formattedError);
this.stop();
break;
default:
_log2.default.warn('hlsjs: trying to recover from network error.', { evt: evt, data: data });
error.level = _error2.default.Levels.WARN;
this.createError(error);
this._hls.startLoad();
break;
}
break;
case _hls2.default.ErrorTypes.MEDIA_ERROR:
_log2.default.warn('hlsjs: trying to recover from media error.', { evt: evt, data: data });
error.level = _error2.default.Levels.WARN;
this.createError(error);
this._recover(evt, data, error);
break;
default:
_log2.default.error('hlsjs: could not recover from error.', { evt: evt, data: data });
formattedError = this.createError(error);
this.trigger(_events2.default.PLAYBACK_ERROR, formattedError);
this.stop();
break;
}
} else {
_log2.default.error('hlsjs: could not recover from error after maximum number of attempts.', { evt: evt, data: data });
formattedError = this.createError(error);
this.trigger(_events2.default.PLAYBACK_ERROR, formattedError);
this.stop();
}
} else {
// Transforms HLSJS.ErrorDetails.KEY_LOAD_ERROR non-fatal error to
// playback fatal error if triggerFatalErrorOnResourceDenied playback
// option is set. HLSJS.ErrorTypes.KEY_SYSTEM_ERROR are fatal errors
// and therefore already handled.
if (this.options.playback.triggerFatalErrorOnResourceDenied && this._keyIsDenied(data)) {
_log2.default.error('hlsjs: could not load decrypt key.', { evt: evt, data: data });
formattedError = this.createError(error);
this.trigger(_events2.default.PLAYBACK_ERROR, formattedError);
this.stop();
return;
}
error.level = _error2.default.Levels.WARN;
this.createError(error);
_log2.default.warn('hlsjs: non-fatal error occurred', { evt: evt, data: data });
}
};
HLS.prototype._keyIsDenied = function _keyIsDenied(data) {
return data.type === _hls2.default.ErrorTypes.NETWORK_ERROR && data.details === _hls2.default.ErrorDetails.KEY_LOAD_ERROR && data.response && data.response.code >= 400;
};
HLS.prototype._onTimeUpdate = function _onTimeUpdate() {
var update = { current: this.getCurrentTime(), total: this.getDuration(), firstFragDateTime: this.getProgramDateTime() };
var isSame = this._lastTimeUpdate && update.current === this._lastTimeUpdate.current && update.total === this._lastTimeUpdate.total;
if (isSame) return;
this._lastTimeUpdate = update;
this.trigger(_events2.default.PLAYBACK_TIMEUPDATE, update, this.name);
};
HLS.prototype._onDurationChange = function _onDurationChange() {
var duration = this.getDuration();
if (this._lastDuration === duration) return;
this._lastDuration = duration;
_HTML5VideoPlayback.prototype._onDurationChange.call(this);
};
HLS.prototype._onProgress = function _onProgress() {
if (!this.el.buffered.length) return;
var buffered = [];
var bufferedPos = 0;
for (var i = 0; i < this.el.buffered.length; i++) {
buffered = [].concat((0, _toConsumableArray3.default)(buffered), [{
// for a stream with sliding window dvr something that is buffered my slide off the start of the timeline
start: Math.max(0, this.el.buffered.start(i) - this._playableRegionStartTime),
end: Math.max(0, this.el.buffered.end(i) - this._playableRegionStartTime)
}]);
if (this.el.currentTime >= buffered[i].start && this.el.currentTime <= buffered[i].end) bufferedPos = i;
}
var progress = {
start: buffered[bufferedPos].start,
current: buffered[bufferedPos].end,
total: this.getDuration()
};
this.trigger(_events2.default.PLAYBACK_PROGRESS, progress, buffered);
};
HLS.prototype.play = function play() {
if (!this._hls) this._setup();
_HTML5VideoPlayback.prototype.play.call(this);
this._startTimeUpdateTimer();
};
HLS.prototype.pause = function pause() {
if (!this._hls) return;
_HTML5VideoPlayback.prototype.pause.call(this);
if (this.dvrEnabled) this._updateDvr(true);
};
HLS.prototype.stop = function stop() {
this._stopTimeUpdateTimer();
if (this._hls) {
_HTML5VideoPlayback.prototype.stop.call(this);
this._hls.destroy();
delete this._hls;
}
};
HLS.prototype.destroy = function destroy() {
this._stopTimeUpdateTimer();
if (this._hls) {
this._hls.destroy();
delete this._hls;
}
_HTML5VideoPlayback.prototype.destroy.call(this);
};
HLS.prototype._updatePlaybackType = function _updatePlaybackType(evt, data) {
this._playbackType = data.details.live ? _playback2.default.LIVE : _playback2.default.VOD;
this._onLevelUpdated(evt, data);
// Live stream subtitle tracks detection hack (may not immediately available)
if (this._ccTracksUpdated && this._playbackType === _playback2.default.LIVE && this.hasClosedCaptionsTracks) this._onSubtitleLoaded();
};
HLS.prototype._fillLevels = function _fillLevels() {
this._levels = this._hls.levels.map(function (level, index) {
return { id: index, level: level, label: level.bitrate / 1000 + 'Kbps' };
});
this.trigger(_events2.default.PLAYBACK_LEVELS_AVAILABLE, this._levels);
};
HLS.prototype._onLevelUpdated = function _onLevelUpdated(evt, data) {
this._segmentTargetDuration = data.details.targetduration;
this._playlistType = data.details.type || null;
var startTimeChanged = false;
var durationChanged = false;
var fragments = data.details.fragments;
var previousPlayableRegionStartTime = this._playableRegionStartTime;
var previousPlayableRegionDuration = this._playableRegionDuration;
if (fragments.length === 0) return;
// #EXT-X-PROGRAM-DATE-TIME
if (fragments[0].rawProgramDateTime) this._programDateTime = fragments[0].rawProgramDateTime;
if (this._playableRegionStartTime !== fragments[0].start) {
startTimeChanged = true;
this._playableRegionStartTime = fragments[0].start;
}
if (startTimeChanged) {
if (!this._localStartTimeCorrelation) {
// set the correlation to map to middle of the extrapolation window
this._localStartTimeCorrelation = {
local: this._now,
remote: (fragments[0].start + this._extrapolatedWindowDuration / 2) * 1000
};
} else {
// check if the correlation still works
var corr = this._localStartTimeCorrelation;
var timePassed = this._now - corr.local;
// this should point to a time within the extrapolation window
var startTime = (corr.remote + timePassed) / 1000;
if (startTime < fragments[0].start) {
// our start time is now earlier than the first chunk
// (maybe the chunk was removed early)
// reset correlation so that it sits at the beginning of the first available chunk
this._localStartTimeCorrelation = {
local: this._now,
remote: fragments[0].start * 1000
};
} else if (startTime > previousPlayableRegionStartTime + this._extrapolatedWindowDuration) {
// start time was past the end of the old extrapolation window (so would have been capped)
// see if now that time would be inside the window, and if it would be set the correlation
// so that it resumes from the time it was at at the end of the old window
// update the correlation so that the time starts counting again from the value it's on now
this._localStartTimeCorrelation = {
local: this._now,
remote: Math.max(fragments[0].start, previousPlayableRegionStartTime + this._extrapolatedWindowDuration) * 1000
};
}
}
}
var newDuration = data.details.totalduration;
// if it's a live stream then shorten the duration to remove access
// to the area after hlsjs's live sync point
// seeks to areas after this point sometimes have issues
if (this._playbackType === _playback2.default.LIVE) {
var fragmentTargetDuration = data.details.targetduration;
var hlsjsConfig = this.options.playback.hlsjsConfig || {};
var liveSyncDurationCount = hlsjsConfig.liveSyncDurationCount || _hls2.default.DefaultConfig.liveSyncDurationCount;
var hiddenAreaDuration = fragmentTargetDuration * liveSyncDurationCount;
if (hiddenAreaDuration <= newDuration) {
newDuration -= hiddenAreaDuration;
this._durationExcludesAfterLiveSyncPoint = true;
} else {
this._durationExcludesAfterLiveSyncPoint = false;
}
}
if (newDuration !== this._playableRegionDuration) {
durationChanged = true;
this._playableRegionDuration = newDuration;
}
// Note the end time is not the playableRegionDuration
// The end time will always increase even if content is removed from the beginning
var endTime = fragments[0].start + newDuration;
var previousEndTime = previousPlayableRegionStartTime + previousPlayableRegionDuration;
var endTimeChanged = endTime !== previousEndTime;
if (endTimeChanged) {
if (!this._localEndTimeCorrelation) {
// set the correlation to map to the end
this._localEndTimeCorrelation = {
local: this._now,
remote: endTime * 1000
};
} else {
// check if the correlation still works
var _corr = this._localEndTimeCorrelation;
var _timePassed = this._now - _corr.local;
// this should point to a time within the extrapolation window from the end
var extrapolatedEndTime = (_corr.remote + _timePassed) / 1000;
if (extrapolatedEndTime > endTime) {
this._localEndTimeCorrelation = {
local: this._now,
remote: endTime * 1000
};
} else if (extrapolatedEndTime < endTime - this._extrapolatedWindowDuration) {
// our extrapolated end time is now earlier than the extrapolation window from the actual end time
// (maybe a chunk became available early)
// reset correlation so that it sits at the beginning of the extrapolation window from the end time
this._localEndTimeCorrelation = {
local: this._now,
remote: (endTime - this._extrapolatedWindowDuration) * 1000
};
} else if (extrapolatedEndTime > previousEndTime) {
// end time was past the old end time (so would have been capped)
// set the correlation so that it resumes from the time it was at at the end of the old window
this._localEndTimeCorrelation = {
local: this._now,
remote: previousEndTime * 1000
};
}
}
}
// now that the values have been updated call any methods that use on them so they get the updated values
// immediately
durationChanged && this._onDurationChange();
startTimeChanged && this._onProgress();
};
HLS.prototype._onFragmentLoaded = function _onFragmentLoaded(evt, data) {
this.trigger(_events2.default.PLAYBACK_FRAGMENT_LOADED, data);
};
HLS.prototype._onSubtitleLoaded = function _onSubtitleLoaded() {
// This event may be triggered multiple times
// Setup CC only once (disable CC by default)
if (!this._ccIsSetup) {
this.trigger(_events2.default.PLAYBACK_SUBTITLE_AVAILABLE);
var trackId = this._playbackType === _playback2.default.LIVE ? -1 : this.closedCaptionsTrackId;
this.closedCaptionsTrackId = trackId;
this._ccIsSetup = true;
}
};
HLS.prototype._onLevelSwitch = function _onLevelSwitch(evt, data) {
if (!this.levels.length) this._fillLevels();
this.trigger(_events2.default.PLAYBACK_LEVEL_SWITCH_END);
this.trigger(_events2.default.PLAYBACK_LEVEL_SWITCH, data);
var currentLevel = this._hls.levels[data.level];
if (currentLevel) {
// TODO should highDefinition be private and maybe have a read only accessor if it's used somewhere
this.highDefinition = currentLevel.height >= 720 || currentLevel.bitrate / 1000 >= 2000;
this.trigger(_events2.default.PLAYBACK_HIGHDEFINITIONUPDATE, this.highDefinition);
this.trigger(_events2.default.PLAYBACK_BITRATE, {
height: currentLevel.height,
width: currentLevel.width,
bandwidth: currentLevel.bitrate,
bitrate: currentLevel.bitrate,
level: data.level
});
}
};
HLS.prototype.getPlaybackType = function getPlaybackType() {
return this._playbackType;
};
HLS.prototype.isSeekEnabled = function isSeekEnabled() {
return this._playbackType === _playback2.default.VOD || this.dvrEnabled;
};
(0, _createClass3.default)(HLS, [{
key: 'dvrEnabled',
get: function get() {
// enabled when:
// - the duration does not include content after hlsjs's live sync point
// - the playable region duration is longer than the configured duration to enable dvr after
// - the playback type is LIVE.
return this._durationExcludesAfterLiveSyncPoint && this._duration >= this._minDvrSize && this.getPlaybackType() === _playback2.default.LIVE;
}
}]);
return HLS;
}(_html5_video2.default);
exports.default = HLS;
HLS.canPlay = function (resource, mimeType) {
var resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
var isHls = resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'm3u8' || (0, _utils.listContainsIgnoreCase)(mimeType, ['application/vnd.apple.mpegurl', 'application/x-mpegURL']);
return !!(_hls2.default.isSupported() && isHls);
};
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/hls/index.js":
/*!************************************!*\
!*** ./src/playbacks/hls/index.js ***!
\************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _hls = __webpack_require__(/*! ./hls */ "./src/playbacks/hls/hls.js");
var _hls2 = _interopRequireDefault(_hls);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _hls2.default;
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/html5_audio/html5_audio.js":
/*!**************************************************!*\
!*** ./src/playbacks/html5_audio/html5_audio.js ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");
var _inherits3 = _interopRequireDefault(_inherits2);
var _events = __webpack_require__(/*! ../../base/events */ "./src/base/events.js");
var _events2 = _interopRequireDefault(_events);
var _playback = __webpack_require__(/*! ../../base/playback */ "./src/base/playback.js");
var _playback2 = _interopRequireDefault(_playback);
var _html5_video = __webpack_require__(/*! ../../playbacks/html5_video */ "./src/playbacks/html5_video/index.js");
var _html5_video2 = _interopRequireDefault(_html5_video);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// TODO: remove this playback and change HTML5Video to HTML5Playback (breaking change, only after 0.3.0)
var HTML5Audio = function (_HTML5Video) {
(0, _inherits3.default)(HTML5Audio, _HTML5Video);
function HTML5Audio() {
(0, _classCallCheck3.default)(this, HTML5Audio);
return (0, _possibleConstructorReturn3.default)(this, _HTML5Video.apply(this, arguments));
}
HTML5Audio.prototype.updateSettings = function updateSettings() {
this.settings.left = ['playpause', 'position', 'duration'];
this.settings.seekEnabled = this.isSeekEnabled();
this.trigger(_events2.default.PLAYBACK_SETTINGSUPDATE);
};
HTML5Audio.prototype.getPlaybackType = function getPlaybackType() {
return _playback2.default.AOD;
};
(0, _createClass3.default)(HTML5Audio, [{
key: 'name',
get: function get() {
return 'html5_audio';
}
}, {
key: 'tagName',
get: function get() {
return 'audio';
}
}, {
key: 'isAudioOnly',
get: function get() {
return true;
}
}]);
return HTML5Audio;
}(_html5_video2.default); // Copyright 2014 Globo.com Player authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
exports.default = HTML5Audio;
HTML5Audio.canPlay = function (resourceUrl, mimeType) {
var mimetypes = {
'wav': ['audio/wav'],
'mp3': ['audio/mp3', 'audio/mpeg;codecs="mp3"'],
'aac': ['audio/mp4;codecs="mp4a.40.5"'],
'oga': ['audio/ogg']
};
return _html5_video2.default._canPlay('audio', mimetypes, resourceUrl, mimeType);
};
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/html5_audio/index.js":
/*!********************************************!*\
!*** ./src/playbacks/html5_audio/index.js ***!
\********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _html5_audio = __webpack_require__(/*! ./html5_audio */ "./src/playbacks/html5_audio/html5_audio.js");
var _html5_audio2 = _interopRequireDefault(_html5_audio);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _html5_audio2.default;
module.exports = exports['default'];
/***/ }),
/***/ "./src/playbacks/html5_video/html5_video.js":
/*!**************************************************!*\
!*** ./src/playbacks/html5_video/html5_video.js ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _from = __webpack_require__(/*! babel-runtime/core-js/array/from */ "./node_modules/babel-runtime/core-js/array/from.js");
var _from2 = _interopRequireDefault(_from);
var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");
var _createClass3 = _interopRequireDefault(_createClass2);
var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");
var _inherits3 = _interopRequireDefault(_inherits2);
var _toConsumableArray2 = __webpack_require__(/*! babel-runtime/helpers/toConsumableArray */ "./node_modules/babel-runtime/helpers/toConsumableArray.js");
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _keys = __webpack_require__(/*! babel-runtime/core-js/object/keys */ "./node_modules/babel-runtime/core-js/object/keys.js");
var _keys2 = _interopRequireDefault(_keys);
var _utils = __webpack_require__(/*! ../../base/utils */ "./src/base/utils.js");
var _playback = __webpack_require__(/*! ../../base/playback */ "./src/base/playback.js");
var _playback2 = _interopRequireDefault(_playback);
var _browser = __webpack_require__(/*! ../../components/browser */ "./src/components/browser/index.js");
var _browser2 = _interopRequireDefault(_browser);
var _error = __webpack_require__(/*! ../../components/error */ "./src/components/error/index.js");
var _error2 = _interopRequireDefault(_error);
var _events = __webpack_require__(/*! ../../base/events */ "./src/base/events.js");
var _events2 = _interopRequireDefault(_events);
var _log = __webpack_require__(/*! ../../plugins/log */ "./src/plugins/log/index.js");
var _log2 = _interopRequireDefault(_log);
var _clapprZepto = __webpack_require__(/*! clappr-zepto */ "./node_modules/clappr-zepto/zepto.js");
var _clapprZepto2 = _interopRequireDefault(_clapprZepto);
var _template = __webpack_require__(/*! ../../base/template */ "./src/base/template.js");
var _template2 = _interopRequireDefault(_template);
var _tracks = __webpack_require__(/*! ./public/tracks.html */ "./src/playbacks/html5_video/public/tracks.html");
var _tracks2 = _interopRequireDefault(_tracks);
__webpack_require__(/*! ./public/style.scss */ "./src/playbacks/html5_video/public/style.scss");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Copyright 2014 Globo.com Player authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
var MIMETYPES = {
'mp4': ['avc1.42E01E', 'avc1.58A01E', 'avc1.4D401E', 'avc1.64001E', 'mp4v.20.8', 'mp4v.20.240', 'mp4a.40.2'].map(function (codec) {
return 'video/mp4; codecs="' + codec + ', mp4a.40.2"';
}),
'ogg': ['video/ogg; codecs="theora, vorbis"', 'video/ogg; codecs="dirac"', 'video/ogg; codecs="theora, speex"'],
'3gpp': ['video/3gpp; codecs="mp4v.20.8, samr"'],
'webm': ['video/webm; codecs="vp8, vorbis"'],
'mkv': ['video/x-matroska; codecs="theora, vorbis"'],
'm3u8': ['application/x-mpegurl']
};
MIMETYPES['ogv'] = MIMETYPES['ogg'];
MIMETYPES['3gp'] = MIMETYPES['3gpp'];
var AUDIO_MIMETYPES = {
'wav': ['audio/wav'],
'mp3': ['audio/mp3', 'audio/mpeg;codecs="mp3"'],
'aac': ['audio/mp4;codecs="mp4a.40.5"'],
'oga': ['audio/ogg']
};
var KNOWN_AUDIO_MIMETYPES = (0, _keys2.default)(AUDIO_MIMETYPES).reduce(function (acc, k) {
return [].concat((0, _toConsumableArray3.default)(acc), (0, _toConsumableArray3.default)(AUDIO_MIMETYPES[k]));
}, []);
var UNKNOWN_ERROR = { code: 'unknown', message: 'unknown'
// TODO: rename this Playback to HTML5Playback (breaking change, only after 0.3.0)
};
var HTML5Video = function (_Playback) {
(0, _inherits3.default)(HTML5Video, _Playback);
(0, _createClass3.default)(HTML5Video, [{
key: 'name',
get: function get() {
return 'html5_video';
}
}, {
key: 'tagName',
get: function get() {
return this.isAudioOnly ? 'audio' : 'video';
}
}, {
key: 'isAudioOnly',
get: function get() {
var resourceUrl = this.options.src;
var mimeTypes = HTML5Video._mimeTypesForUrl(resourceUrl, AUDIO_MIMETYPES, this.options.mimeType);
return this.options.playback && this.options.playback.audioOnly || this.options.audioOnly || KNOWN_AUDIO_MIMETYPES.indexOf(mimeTypes[0]) >= 0;
}
}, {
key: 'attributes',
get: function get() {
return {
'data-html5-video': ''
};
}
}, {
key: 'events',
get: function get() {
return {
'canplay': '_onCanPlay',
'canplaythrough': '_handleBufferingEvents',
'durationchange': '_onDurationChange',
'ended': '_onEnded',
'error': '_onError',
'loadeddata': '_onLoadedData',
'loadedmetadata': '_onLoadedMetadata',
'pause': '_onPause',
'playing': '_onPlaying',
'progress': '_onProgress',
'seeking': '_onSeeking',
'seeked': '_onSeeked',
'stalled': '_handleBufferingEvents',
'timeupdate': '_onTimeUpdate',
'waiting': '_onWaiting'
};
}
/**
* Determine if the playback has ended.
* @property ended
* @type Boolean
*/
}, {
key: 'ended',
get: function get() {
return this.el.ended;
}
/**
* Determine if the playback is having to buffer in order for
* playback to be smooth.
* This is related to the PLAYBACK_BUFFERING and PLAYBACK_BUFFERFULL events
* @property buffering
* @type Boolean
*/
}, {
key: 'buffering',
get: function get() {
return this._isBuffering;
}
}]);
function HTML5Video() {
(0, _classCallCheck3.default)(this, HTML5Video);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var _this = (0, _possibleConstructorReturn3.default)(this, _Playback.call.apply(_Playback, [this].concat(args)));
_this._destroyed = false;
_this._loadStarted = false;
_this._isBuffering = false;
_this._playheadMoving = false;
_this._playheadMovingTimer = null;
_this._stopped = false;
_this._ccTrackId = -1;
_this._setupSrc(_this.options.src);
// backwards compatibility (TODO: remove on 0.3.0)
_this.options.playback || (_this.options.playback = _this.options || {});
_this.options.playback.disableContextMenu = _this.options.playback.disableContextMenu || _this.options.disableVideoTagContextMenu;
var playbackConfig = _this.options.playback;
var preload = playbackConfig.preload || (_browser2.default.isSafari ? 'auto' : _this.options.preload);
var posterUrl = void 0; // FIXME: poster plugin should always convert poster to object with expected properties ?
if (_this.options.poster) {
if (typeof _this.options.poster === 'string') posterUrl = _this.options.poster;else if (typeof _this.options.poster.url === 'string') posterUrl = _this.options.poster.url;
}
_clapprZepto2.default.extend(_this.el, {
muted: _this.options.mute,
defaultMuted: _this.options.mute,
loop: _this.options.loop,
poster: posterUrl,
preload: preload || 'metadata',
controls: (playbackConfig.controls || _this.options.useVideoTagDefaultControls) && 'controls',
crossOrigin: playbackConfig.crossOrigin,
'x-webkit-playsinline': playbackConfig.playInline
});
playbackConfig.playInline && _this.$el.attr({ playsinline: 'playsinline' });
playbackConfig.crossOrigin && _this.$el.attr({ crossorigin: playbackConfig.crossOrigin });
// TODO should settings be private?
_this.settings = { default: ['seekbar'] };
_this.settings.left = ['playpause', 'position', 'duration'];
_this.settings.right = ['fullscreen', 'volume', 'hd-indicator'];
playbackConfig.externalTracks && _this._setupExternalTracks(playbackConfig.externalTracks);
_this.options.autoPlay && _this.attemptAutoPlay();
return _this;
}
// See Playback.attemptAutoPlay()
HTML5Video.prototype.attemptAutoPlay = function attemptAutoPlay() {
var _this2 = this;
this.canAutoPlay(function (result, error) {
error && _log2.default.warn(_this2.name, 'autoplay error.', { result: result, error: error });
// https://github.com/clappr/clappr/issues/1076
result && process.nextTick(function () {
return !_this2._destroyed && _this2.play();
});
});
};
// See Playback.canAutoPlay()
HTML5Video.prototype.canAutoPlay = function canAutoPlay(cb) {
if (this.options.disableCanAutoPlay) cb(true, null);
var opts = {
timeout: this.options.autoPlayTimeout || 500,
inline: this.options.playback.playInline || false,
muted: this.options.mute || false // Known issue: mediacontrols may asynchronously mute video
// Use current video element if recycling feature enabled with mobile devices
};if (_browser2.default.isMobile && _utils.DomRecycler.options.recycleVideo) opts.element = this.el;
// Desktop browser autoplay policy may require user action
// Mobile browser autoplay require user consent and video recycling feature enabled
// It may returns a false positive with source-less player consent
(0, _utils.canAutoPlayMedia)(cb, opts);
};
HTML5Video.prototype._setupExternalTracks = function _setupExternalTracks(tracks) {
this._externalTracks = tracks.map(function (track) {
return {
kind: track.kind || 'subtitles', // Default is 'subtitles'
label: track.label,
lang: track.lang,
src: track.src
};
});
};
/**
* Sets the source url on the