videojs-per-source-behaviors
Version:
A Video.js plugin for enhancing a player with behaviors related to changing media sources.
2,446 lines (2,373 loc) • 88.1 kB
JavaScript
/*! @name videojs-per-source-behaviors @version 3.0.1 @license Apache-2.0 */
(function (QUnit, sinon, videojs) {
'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var QUnit__default = /*#__PURE__*/_interopDefaultLegacy(QUnit);
var sinon__default = /*#__PURE__*/_interopDefaultLegacy(sinon);
var videojs__default = /*#__PURE__*/_interopDefaultLegacy(videojs);
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function getAugmentedNamespace(n) {
if (n.__esModule) return n;
var a = Object.defineProperty({}, '__esModule', {value: true});
Object.keys(n).forEach(function (k) {
var d = Object.getOwnPropertyDescriptor(n, k);
Object.defineProperty(a, k, d.get ? d : {
enumerable: true,
get: function () {
return n[k];
}
});
});
return a;
}
var _nodeResolve_empty = {};
var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
'default': _nodeResolve_empty
});
var require$$0 = /*@__PURE__*/getAugmentedNamespace(_nodeResolve_empty$1);
var topLevel = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof window !== 'undefined' ? window : {};
var minDoc = require$$0;
var doccy;
if (typeof document !== 'undefined') {
doccy = document;
} else {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
if (!doccy) {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
}
}
var document_1 = doccy;
var version = "3.0.1";
function cov_3iwuhzg04() {
var path = "/Users/pgoneill/dev/videojs-per-source-behaviors/src/plugin.js";
var hash = "28e5ffb81b0bcf77fbd929182a7d8e6a4ec0acb5";
var global = new Function("return this")();
var gcv = "__coverage__";
var coverageData = {
path: "/Users/pgoneill/dev/videojs-per-source-behaviors/src/plugin.js",
statementMap: {
"0": {
start: {
line: 4,
column: 14
},
end: {
line: 4,
column: 38
}
},
"1": {
start: {
line: 7,
column: 23
},
end: {
line: 7,
column: 63
}
},
"2": {
start: {
line: 17,
column: 29
},
end: {
line: 22,
column: 1
}
},
"3": {
start: {
line: 30,
column: 24
},
end: {
line: 33,
column: 1
}
},
"4": {
start: {
line: 41,
column: 18
},
end: {
line: 46,
column: 1
}
},
"5": {
start: {
line: 57,
column: 18
},
end: {
line: 57,
column: 50
}
},
"6": {
start: {
line: 57,
column: 25
},
end: {
line: 57,
column: 50
}
},
"7": {
start: {
line: 68,
column: 22
},
end: {
line: 68,
column: 90
}
},
"8": {
start: {
line: 68,
column: 29
},
end: {
line: 68,
column: 90
}
},
"9": {
start: {
line: 82,
column: 20
},
end: {
line: 97,
column: 1
}
},
"10": {
start: {
line: 85,
column: 2
},
end: {
line: 87,
column: 3
}
},
"11": {
start: {
line: 86,
column: 4
},
end: {
line: 86,
column: 17
}
},
"12": {
start: {
line: 91,
column: 2
},
end: {
line: 93,
column: 3
}
},
"13": {
start: {
line: 92,
column: 4
},
end: {
line: 92,
column: 56
}
},
"14": {
start: {
line: 96,
column: 2
},
end: {
line: 96,
column: 32
}
},
"15": {
start: {
line: 99,
column: 14
},
end: {
line: 99,
column: 15
}
},
"16": {
start: {
line: 104,
column: 27
},
end: {
line: 346,
column: 1
}
},
"17": {
start: {
line: 105,
column: 26
},
end: {
line: 105,
column: 28
}
},
"18": {
start: {
line: 107,
column: 17
},
end: {
line: 107,
column: 22
}
},
"19": {
start: {
line: 109,
column: 18
},
end: {
line: 109,
column: 22
}
},
"20": {
start: {
line: 123,
column: 29
},
end: {
line: 187,
column: 3
}
},
"21": {
start: {
line: 124,
column: 4
},
end: {
line: 186,
column: 6
}
},
"22": {
start: {
line: 127,
column: 6
},
end: {
line: 129,
column: 7
}
},
"23": {
start: {
line: 128,
column: 8
},
end: {
line: 128,
column: 15
}
},
"24": {
start: {
line: 131,
column: 29
},
end: {
line: 131,
column: 51
}
},
"25": {
start: {
line: 132,
column: 26
},
end: {
line: 132,
column: 43
}
},
"26": {
start: {
line: 136,
column: 19
},
end: {
line: 136,
column: 26
}
},
"27": {
start: {
line: 140,
column: 29
},
end: {
line: 140,
column: 60
}
},
"28": {
start: {
line: 141,
column: 30
},
end: {
line: 141,
column: 59
}
},
"29": {
start: {
line: 142,
column: 31
},
end: {
line: 142,
column: 67
}
},
"30": {
start: {
line: 146,
column: 30
},
end: {
line: 161,
column: 7
}
},
"31": {
start: {
line: 147,
column: 24
},
end: {
line: 147,
column: 57
}
},
"32": {
start: {
line: 150,
column: 8
},
end: {
line: 152,
column: 9
}
},
"33": {
start: {
line: 151,
column: 10
},
end: {
line: 151,
column: 17
}
},
"34": {
start: {
line: 154,
column: 8
},
end: {
line: 156,
column: 9
}
},
"35": {
start: {
line: 155,
column: 10
},
end: {
line: 155,
column: 28
}
},
"36": {
start: {
line: 158,
column: 8
},
end: {
line: 160,
column: 9
}
},
"37": {
start: {
line: 159,
column: 10
},
end: {
line: 159,
column: 39
}
},
"38": {
start: {
line: 174,
column: 6
},
end: {
line: 174,
column: 94
}
},
"39": {
start: {
line: 178,
column: 6
},
end: {
line: 180,
column: 7
}
},
"40": {
start: {
line: 179,
column: 8
},
end: {
line: 179,
column: 26
}
},
"41": {
start: {
line: 182,
column: 6
},
end: {
line: 182,
column: 33
}
},
"42": {
start: {
line: 183,
column: 6
},
end: {
line: 183,
column: 33
}
},
"43": {
start: {
line: 185,
column: 6
},
end: {
line: 185,
column: 30
}
},
"44": {
start: {
line: 189,
column: 2
},
end: {
line: 246,
column: 4
}
},
"45": {
start: {
line: 197,
column: 6
},
end: {
line: 197,
column: 40
}
},
"46": {
start: {
line: 198,
column: 6
},
end: {
line: 198,
column: 28
}
},
"47": {
start: {
line: 199,
column: 6
},
end: {
line: 199,
column: 22
}
},
"48": {
start: {
line: 200,
column: 6
},
end: {
line: 200,
column: 22
}
},
"49": {
start: {
line: 210,
column: 6
},
end: {
line: 210,
column: 22
}
},
"50": {
start: {
line: 220,
column: 6
},
end: {
line: 220,
column: 23
}
},
"51": {
start: {
line: 221,
column: 6
},
end: {
line: 221,
column: 22
}
},
"52": {
start: {
line: 231,
column: 6
},
end: {
line: 231,
column: 23
}
},
"53": {
start: {
line: 242,
column: 6
},
end: {
line: 242,
column: 23
}
},
"54": {
start: {
line: 263,
column: 2
},
end: {
line: 263,
column: 39
}
},
"55": {
start: {
line: 281,
column: 2
},
end: {
line: 281,
column: 44
}
},
"56": {
start: {
line: 284,
column: 2
},
end: {
line: 286,
column: 5
}
},
"57": {
start: {
line: 285,
column: 4
},
end: {
line: 285,
column: 31
}
},
"58": {
start: {
line: 288,
column: 2
},
end: {
line: 345,
column: 5
}
},
"59": {
start: {
line: 291,
column: 4
},
end: {
line: 297,
column: 5
}
},
"60": {
start: {
line: 296,
column: 6
},
end: {
line: 296,
column: 13
}
},
"61": {
start: {
line: 304,
column: 4
},
end: {
line: 310,
column: 5
}
},
"62": {
start: {
line: 308,
column: 6
},
end: {
line: 308,
column: 24
}
},
"63": {
start: {
line: 309,
column: 6
},
end: {
line: 309,
column: 37
}
},
"64": {
start: {
line: 314,
column: 26
},
end: {
line: 314,
column: 28
}
},
"65": {
start: {
line: 316,
column: 28
},
end: {
line: 317,
column: 54
}
},
"66": {
start: {
line: 317,
column: 6
},
end: {
line: 317,
column: 54
}
},
"67": {
start: {
line: 319,
column: 4
},
end: {
line: 319,
column: 23
}
},
"68": {
start: {
line: 320,
column: 4
},
end: {
line: 320,
column: 43
}
},
"69": {
start: {
line: 322,
column: 4
},
end: {
line: 344,
column: 10
}
},
"70": {
start: {
line: 323,
column: 25
},
end: {
line: 323,
column: 42
}
},
"71": {
start: {
line: 325,
column: 6
},
end: {
line: 325,
column: 23
}
},
"72": {
start: {
line: 326,
column: 6
},
end: {
line: 326,
column: 28
}
},
"73": {
start: {
line: 327,
column: 6
},
end: {
line: 327,
column: 46
}
},
"74": {
start: {
line: 329,
column: 6
},
end: {
line: 343,
column: 7
}
},
"75": {
start: {
line: 333,
column: 8
},
end: {
line: 333,
column: 59
}
},
"76": {
start: {
line: 333,
column: 40
},
end: {
line: 333,
column: 57
}
},
"77": {
start: {
line: 334,
column: 8
},
end: {
line: 334,
column: 35
}
},
"78": {
start: {
line: 336,
column: 8
},
end: {
line: 340,
column: 11
}
},
"79": {
start: {
line: 342,
column: 8
},
end: {
line: 342,
column: 31
}
},
"80": {
start: {
line: 348,
column: 0
},
end: {
line: 348,
column: 37
}
},
"81": {
start: {
line: 350,
column: 0
},
end: {
line: 350,
column: 57
}
}
},
fnMap: {
"0": {
name: "(anonymous_0)",
decl: {
start: {
line: 57,
column: 18
},
end: {
line: 57,
column: 19
}
},
loc: {
start: {
line: 57,
column: 25
},
end: {
line: 57,
column: 50
}
},
line: 57
},
"1": {
name: "(anonymous_1)",
decl: {
start: {
line: 68,
column: 22
},
end: {
line: 68,
column: 23
}
},
loc: {
start: {
line: 68,
column: 29
},
end: {
line: 68,
column: 90
}
},
line: 68
},
"2": {
name: "(anonymous_2)",
decl: {
start: {
line: 82,
column: 20
},
end: {
line: 82,
column: 21
}
},
loc: {
start: {
line: 82,
column: 30
},
end: {
line: 97,
column: 1
}
},
line: 82
},
"3": {
name: "(anonymous_3)",
decl: {
start: {
line: 104,
column: 27
},
end: {
line: 104,
column: 28
}
},
loc: {
start: {
line: 104,
column: 38
},
end: {
line: 346,
column: 1
}
},
line: 104
},
"4": {
name: "(anonymous_4)",
decl: {
start: {
line: 123,
column: 29
},
end: {
line: 123,
column: 30
}
},
loc: {
start: {
line: 123,
column: 40
},
end: {
line: 187,
column: 3
}
},
line: 123
},
"5": {
name: "(anonymous_5)",
decl: {
start: {
line: 124,
column: 11
},
end: {
line: 124,
column: 12
}
},
loc: {
start: {
line: 124,
column: 35
},
end: {
line: 186,
column: 5
}
},
line: 124
},
"6": {
name: "(anonymous_6)",
decl: {
start: {
line: 146,
column: 30
},
end: {
line: 146,
column: 31
}
},
loc: {
start: {
line: 146,
column: 46
},
end: {
line: 161,
column: 7
}
},
line: 146
},
"7": {
name: "disable",
decl: {
start: {
line: 196,
column: 23
},
end: {
line: 196,
column: 30
}
},
loc: {
start: {
line: 196,
column: 33
},
end: {
line: 201,
column: 5
}
},
line: 196
},
"8": {
name: "(anonymous_8)",
decl: {
start: {
line: 209,
column: 4
},
end: {
line: 209,
column: 5
}
},
loc: {
start: {
line: 209,
column: 15
},
end: {
line: 211,
column: 5
}
},
line: 209
},
"9": {
name: "(anonymous_9)",
decl: {
start: {
line: 219,
column: 4
},
end: {
line: 219,
column: 5
}
},
loc: {
start: {
line: 219,
column: 13
},
end: {
line: 222,
column: 5
}
},
line: 219
},
"10": {
name: "(anonymous_10)",
decl: {
start: {
line: 230,
column: 4
},
end: {
line: 230,
column: 5
}
},
loc: {
start: {
line: 230,
column: 14
},
end: {
line: 232,
column: 5
}
},
line: 230
},
"11": {
name: "(anonymous_11)",
decl: {
start: {
line: 241,
column: 4
},
end: {
line: 241,
column: 5
}
},
loc: {
start: {
line: 241,
column: 18
},
end: {
line: 243,
column: 5
}
},
line: 241
},
"12": {
name: "(anonymous_12)",
decl: {
start: {
line: 284,
column: 21
},
end: {
line: 284,
column: 22
}
},
loc: {
start: {
line: 284,
column: 27
},
end: {
line: 286,
column: 3
}
},
line: 284
},
"13": {
name: "(anonymous_13)",
decl: {
start: {
line: 288,
column: 32
},
end: {
line: 288,
column: 33
}
},
loc: {
start: {
line: 288,
column: 39
},
end: {
line: 345,
column: 3
}
},
line: 288
},
"14": {
name: "(anonymous_14)",
decl: {
start: {
line: 316,
column: 28
},
end: {
line: 316,
column: 29
}
},
loc: {
start: {
line: 317,
column: 6
},
end: {
line: 317,
column: 54
}
},
line: 317
},
"15": {
name: "(anonymous_15)",
decl: {
start: {
line: 322,
column: 37
},
end: {
line: 322,
column: 38
}
},
loc: {
start: {
line: 322,
column: 43
},
end: {
line: 344,
column: 5
}
},
line: 322
},
"16": {
name: "(anonymous_16)",
decl: {
start: {
line: 333,
column: 32
},
end: {
line: 333,
column: 33
}
},
loc: {
start: {
line: 333,
column: 40
},
end: {
line: 333,
column: 57
}
},
line: 333
}
},
branchMap: {
"0": {
loc: {
start: {
line: 7,
column: 23
},
end: {
line: 7,
column: 63
}
},
type: "binary-expr",
locations: [{
start: {
line: 7,
column: 23
},
end: {
line: 7,
column: 45
}
}, {
start: {
line: 7,
column: 49
},
end: {
line: 7,
column: 63
}
}],
line: 7
},
"1": {
loc: {
start: {
line: 68,
column: 29
},
end: {
line: 68,
column: 90
}
},
type: "binary-expr",
locations: [{
start: {
line: 68,
column: 29
},
end: {
line: 68,
column: 49
}
}, {
start: {
line: 68,
column: 53
},
end: {
line: 68,
column: 90
}
}],
line: 68
},
"2": {
loc: {
start: {
line: 85,
column: 2
},
end: {
line: 87,
column: 3
}
},
type: "if",
locations: [{
start: {
line: 85,
column: 2
},
end: {
line: 87,
column: 3
}
}, {
start: {
line: 85,
column: 2
},
end: {
line: 87,
column: 3
}
}],
line: 85
},
"3": {
loc: {
start: {
line: 91,
column: 2
},
end: {
line: 93,
column: 3
}
},
type: "if",
locations: [{
start: {
line: 91,
column: 2
},
end: {
line: 93,
column: 3
}
}, {
start: {
line: 91,
column: 2
},
end: {
line: 93,
column: 3
}
}],
line: 91
},
"4": {
loc: {
start: {
line: 92,
column: 11
},
end: {
line: 92,
column: 55
}
},
type: "binary-expr",
locations: [{
start: {
line: 92,
column: 11
},
end: {
line: 92,
column: 29
}
}, {
start: {
line: 92,
column: 33
},
end: {
line: 92,
column: 55
}
}],
line: 92
},
"5": {
loc: {
start: {
line: 127,
column: 6
},
end: {
line: 129,
column: 7
}
},
type: "if",
locations: [{
start: {
line: 127,
column: 6
},
end: {
line: 129,
column: 7
}
}, {
start: {
line: 127,
column: 6
},
end: {
line: 129,
column: 7
}
}],
line: 127
},
"6": {
loc: {
start: {
line: 141,
column: 30
},
end: {
line: 141,
column: 59
}
},
type: "cond-expr",
locations: [{
start: {
line: 141,
column: 47
},
end: {
line: 141,
column: 51
}
}, {
start: {
line: 141,
column: 54
},
end: {
line: 141,
column: 59
}
}],
line: 141
},
"7": {
loc: {
start: {
line: 150,
column: 8
},
end: {
line: 152,
column: 9
}
},
type: "if",
locations: [{
start: {
line: 150,
column: 8
},
end: {
line: 152,
column: 9
}
}, {
start: {
line: 150,
column: 8
},
end: {
line: 152,
column: 9
}
}],
line: 150
},
"8": {
loc: {
start: {
line: 154,
column: 8
},
end: {
line: 156,
column: 9
}
},
type: "if",
locations: [{
start: {
line: 154,
column: 8
},
end: {
line: 156,
column: 9
}
}, {
start: {
line: 154,
column: 8
},
end: {
line: 156,
column: 9
}
}],
line: 154
},
"9": {
loc: {
start: {
line: 154,
column: 12
},
end: {
line: 154,
column: 28
}
},
type: "binary-expr",
locations: [{
start: {
line: 154,
column: 12
},
end: {
line: 154,
column: 19
}
}, {
start: {
line: 154,
column: 23
},
end: {
line: 154,
column: 28
}
}],
line: 154
},
"10": {
loc: {
start: {
line: 158,
column: 8
},
end: {
line: 160,
column: 9
}
},
type: "if",
locations: [{
start: {
line: 158,
column: 8
},
end: {
line: 160,
column: 9
}
}, {
start: {
line: 158,
column: 8
},
end: {
line: 160,
column: 9
}
}],
line: 158
},
"11": {
loc: {
start: {
line: 178,
column: 6
},
end: {
line: 180,
column: 7
}
},
type: "if",
locations: [{
start: {
line: 178,
column: 6
},
end: {
line: 180,
column: 7
}
}, {
start: {
line: 178,
column: 6
},
end: {
line: 180,
column: 7
}
}],
line: 178
},
"12": {
loc: {
start: {
line: 291,
column: 4
},
end: {
line: 297,
column: 5
}
},
type: "if",
locations: [{
start: {
line: 291,
column: 4
},
end: {
line: 297,
column: 5
}
}, {
start: {
line: 291,
column: 4
},
end: {
line: 297,
column: 5
}
}],
line: 291
},
"13": {
loc: {
start: {
line: 292,
column: 6
},
end: {
line: 294,
column: 26
}
},
type: "binary-expr",
locations: [{
start: {
line: 292,
column: 6
},
end: {
line: 292,
column: 40
}
}, {
start: {
line: 293,
column: 6
},
end: {
line: 293,
column: 20
}
}, {
start: {
line: 294,
column: 6
},
end: {
line: 294,
column: 26
}
}],
line: 292
},
"14": {
loc: {
start: {
line: 304,
column: 4
},
end: {
line: 310,
column: 5
}
},
type: "if",
locations: [{
start: {
line: 304,
column: 4
},
end: {
line: 310,
column: 5
}
}, {
start: {
line: 304,
column: 4
},
end: {
line: 310,
column: 5
}
}],
line: 304
},
"15": {
loc: {
start: {
line: 305,
column: 6
},
end: {
line: 306,
column: 42
}
},
type: "binary-expr",
locations: [{
start: {
line: 305,
column: 6
},
end: {
line: 305,
column: 15
}
}, {
start: {
line: 306,
column: 6
},
end: {
line: 306,
column: 42
}
}],
line: 305
},
"16": {
loc: {
start: {
line: 329,
column: 6
},
end: {
line: 343,
column: 7
}
},
type: "if",
locations: [{
start: {
line: 329,
column: 6
},
end: {
line: 343,
column: 7
}
}, {
start: {
line: 329,
column: 6
},
end: {
line: 343,
column: 7
}
}],
line: 329
},
"17": {
loc: {
start: {
line: 329,
column: 10
},
end: {
line: 329,
column: 48
}
},
type: "binary-expr",
locations: [{
start: {
line: 329,
column: 10
},
end: {
line: 329,
column: 20
}
}, {
start: {
line: 329,
column: 24
},
end: {
line: 329,
column: 48
}
}],
line: 329
}
},
s: {
"0": 0,
"1": 0,
"2": 0,
"3": 0,
"4": 0,
"5": 0,
"6": 0,
"7": 0,
"8": 0,
"9": 0,
"10": 0,
"11": 0,
"12": 0,
"13": 0,
"14": 0,
"15": 0,
"16": 0,
"17": 0,
"18": 0,
"19": 0,
"20": 0,
"21": 0,
"22": 0,
"23": 0,
"24": 0,
"25": 0,
"26": 0,
"27": 0,
"28": 0,
"29": 0,
"30": 0,
"31": 0,
"32": 0,
"33": 0,
"34": 0,
"35": 0,
"36": 0,
"37": 0,
"38": 0,
"39": 0,
"40": 0,
"41": 0,
"42": 0,
"43": 0,
"44": 0,
"45": 0,
"46": 0,
"47": 0,
"48": 0,
"49": 0,
"50": 0,
"51": 0,
"52": 0,
"53": 0,
"54": 0,
"55": 0,
"56": 0,
"57": 0,
"58": 0,
"59": 0,
"60": 0,
"61": 0,
"62": 0,
"63": 0,
"64": 0,
"65": 0,
"66": 0,
"67": 0,
"68": 0,
"69": 0,
"70": 0,
"71": 0,
"72": 0,
"73": 0,
"74": 0,
"75": 0,
"76": 0,
"77": 0,
"78": 0,
"79": 0,
"80": 0,
"81": 0
},
f: {
"0": 0,
"1": 0,
"2": 0,
"3": 0,
"4": 0,
"5": 0,
"6": 0,
"7": 0,
"8": 0,
"9": 0,
"10": 0,
"11": 0,
"12": 0,
"13": 0,
"14": 0,
"15": 0,
"16": 0
},
b: {
"0": [0, 0],
"1": [0, 0],
"2": [0, 0],
"3": [0, 0],
"4": [0, 0],
"5": [0, 0],
"6": [0, 0],
"7": [0, 0],
"8": [0, 0],
"9": [0, 0],
"10": [0, 0],
"11": [0, 0],
"12": [0, 0],
"13": [0, 0, 0],
"14": [0, 0],
"15": [0, 0],
"16": [0, 0],
"17": [0, 0]
},
_coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
hash: "28e5ffb81b0bcf77fbd929182a7d8e6a4ec0acb5"
};
var coverage = global[gcv] || (global[gcv] = {});
if (!coverage[path] || coverage[path].hash !== hash) {
coverage[path] = coverageData;
}
var actualCoverage = coverage[path];
{
// @ts-ignore
cov_3iwuhzg04 = function () {
return actualCoverage;
};
}
return actualCoverage;
}
cov_3iwuhzg04();
const Html5 = (cov_3iwuhzg04().s[0]++, videojs__default["default"].getTech('Html5')); // Video.js 5/6 cross-compatibility.
const registerPlugin = (cov_3iwuhzg04().s[1]++, (cov_3iwuhzg04().b[0][0]++, videojs__default["default"].registerPlugin) || (cov_3iwuhzg04().b[0][1]++, videojs__default["default"].plugin));
/**
* For the most part, these are the events that occur early in the lifecycle
* of a source, but there is considerable variability across browsers and
* devices (not to mention properties like autoplay and preload). As such, we
* listen to a bunch of events for source changes.
*
* @type {Array}
*/
const CHANGE_DETECT_EVENTS = (cov_3iwuhzg04().s[2]++, ['abort', 'emptied', 'loadstart', 'play']);
/**
* These events will indicate that the source is "unstable" (i.e. it might be
* about to change).
*
* @type {Array}
*/
const UNSTABLE_EVENTS = (cov_3iwuhzg04().s[3]++, ['abort', 'emptied']);
/**
* These are the ad loading and playback states we care about from
* contrib-ads 5.
*
* @type {Array}
*/
const AD_STATES = (cov_3iwuhzg04().s[4]++, ['ad-playback', 'ads-ready?', 'postroll?', 'preroll?']);
/**
* Whether or not a string represents an "ad state".
*
* @param {string} s
* The string to check
*
* @return {boolean}
* If the string is an ad state
*/
cov_3iwuhzg04().s[5]++;
const isAdState = s => {
cov_3iwuhzg04().f[0]++;
cov_3iwuhzg04().s[6]++;
return AD_STATES.indexOf(s) > -1;
};
/**
* Determine whether or not a player is using contrib-ads 6+.
*
* @param {Player} p
* The player
*
* @return {boolean}
* if the player is using contrib-ads 6+
*/
cov_3iwuhzg04().s[7]++;
const usingAds6Plus = p => {
cov_3iwuhzg04().f[1]++;
cov_3iwuhzg04().s[8]++;
return (cov_3iwuhzg04().b[1][0]++, p.usingPlugin('ads')) && (cov_3iwuhzg04().b[1][1]++, typeof p.ads.inAdBreak === 'function');
};
/**
* Whether or not the player should ignore an event due to ad states.
*
* @param {Player} p
* The player
*
* @param {Event} e
* An event object
*
* @return {boolean}
* If the player is in an ad state
*/
cov_3iwuhzg04().s[9]++;
const ignoreEvent = (p, e) => {
cov_3iwuhzg04().f[2]++;
cov_3iwuhzg04().s[10]++; // No ads, no ad states to ignore!
if (!p.usingPlugin('ads')) {
cov_3iwuhzg04().b[2][0]++;
cov_3iwuhzg04().s[11]++;
return false;
} else {
cov_3iwuhzg04().b[2][1]++;
} // In contrib-ads 6+ we only care about non-loadstart events because
// loadstart events _may_ happen during ad mode.
cov_3iwuhzg04().s[12]++;
if (usingAds6Plus(p)) {
cov_3iwuhzg04().b[3][0]++;
cov_3iwuhzg04().s[13]++;
return (cov_3iwuhzg04().b[4][0]++, p.ads.isInAdMode()) && (cov_3iwuhzg04().b[4][1]++, e.type !== 'loadstart');
} else {
cov_3iwuhzg04().b[3][1]++;
} // contrib-ads 5+
cov_3iwuhzg04().s[14]++;
return isAdState(p.ads.state);
};
let psbGuid = (cov_3iwuhzg04().s[15]++, 0);
/**
* Applies per-source behaviors to a video.js Player object.
*/
cov_3iwuhzg04().s[16]++;
const perSourceBehaviors = function () {
cov_3iwuhzg04().f[3]++;
const perSrcListeners = (cov_3iwuhzg04().s[17]++, []);
let cachedSrc;
let disabled = (cov_3iwuhzg04().s[18]++, false);
let srcChangeTimer;
let srcStable = (cov_3iwuhzg04().s[19]++, true);
/**
* Creates an event binder function of a given type.
*
* @param {boolean} isOne
* Rather than delegating to the player's `one()` method, we want to
* retain full control over when the listener is unbound (particularly
* due to the ability for per-source behaviors to be toggled on and
* off at will).
*
* @return {Function}
* the per source binder function
*/
cov_3iwuhzg04().s[20]++;
const createPerSrcBinder = isOne => {
cov_3iwuhzg04().f[4]++;
cov_3iwuhzg04().s[21]++;
return function (first, second) {
cov_3iwuhzg04().f[5]++;
cov_3iwuhzg04().s[22]++; // Do not bind new listeners when per-source behaviors are disabled.
if (this.perSourceBehaviors.disabled()) {
cov_3iwuhzg04().b[5][0]++;
cov_3iwuhzg04().s[23]++;
return;
} else {
cov_3iwuhzg04().b[5][1]++;
}
const isTargetPlayer = (cov_3iwuhzg04().s[24]++, arguments.length === 2);
const originalSrc = (cov_3iwuhzg04().s[25]++, this.currentSrc()); // This array is the set of arguments to use for `on()` and `off()` methods
// of the player.
const args = (cov_3iwuhzg04().s[26]++, [first]); // Make sure we bind here so that a GUID is set on the original listener
// and that it is bound to the proper context.
const passedListener = (cov_3iwuhzg04().s[27]++, arguments[arguments.length - 1]);
const listenerContext = (cov_3iwuhzg04().s[28]++, isTargetPlayer ? (cov_3iwuhzg04().b[6][0]++, this) : (cov_3iwuhzg04().b[6][1]++, first));
const originalListener = (cov_3iwuhzg04().s[29]++, passedListener.bind(listenerContext)); // The wrapped listener `subargs` are the arguments passed to the original
// listener (i.e. the Event object and an additional data hash).
cov_3iwuhzg04().s[30]++;
const wrappedListener = (...subargs) => {
cov_3iwuhzg04().f[6]++;
const changed = (cov_3iwuhzg04().s[31]++, this.currentSrc() !== originalSrc); // Do not evaluate listeners if per-source behaviors are disabled.
cov_3iwuhzg04().s[32]++;
if (this.perSourceBehaviors.disabled()) {
cov_3iwuhzg04().b[7][0]++;
cov_3iwuhzg04().s[33]++;
return;
} else {
cov_3iwuhzg04().b[7][1]++;
}
cov_3iwuhzg04().s[34]++;
if ((cov_3iwuhzg04().b[9][0]++, changed) || (cov_3iwuhzg04().b[9][1]++, isOne)) {
cov_3iwuhzg04().b[8][0]++;
cov_3iwuhzg04().s[35]++;
this.off(...args);
} else {
cov_3iwuhzg04().b[8][1]++;
}
cov_3iwuhzg04().s[36]++;
if (!changed) {
cov_3iwuhzg04().b[10][0]++;
cov_3iwuhzg04().s[37]++;
originalListener(...subargs);
} else {
cov_3iwuhzg04().b[10][1]++;
}
}; // Make sure the wrapped listener and the original listener share a GUID,
// so that video.js properly removes event bindings when `off()` is passed
// the original listener!
//
// This property is used internally by Video.js for tracking bound
// listeners in its event system. Normally, Video.js creates this `guid`
// through its `bind` method, but that method is deprecated in public
// interfaces.
//
// Basically, this allows us to avoid deprecation warnings from calling
// `videojs.bind` when used with Video.js 8.
cov_3iwuhzg04().s[38]++;
wrappedListener.guid = originalListener.guid = passedListener.guid = `psb-${++psbGuid}`; // If we are targeting a different object from the player, we need to include
// the second argument.
cov_3iwuhzg04().s[39]++;
if (!isTargetPlayer) {
cov_3iwuhzg04().b[11][0]++;
cov_3iwuhzg04().s[40]++;
args.push(second);
} else {
cov_3iwuhzg04().b[11][1]++;
}
cov_3iwuhzg04().s[41]++;
args.push(wrappedListener);
cov_3iwuhzg04().s[42]++;
perSrcListeners.push(args);
cov_3iwuhzg04().s[43]++;
return this.on(...args);
};
};
cov_3iwuhzg04().s[44]++;
this.perSourceBehaviors = {
/**
* Disable per-source behaviors on this player.
*
* @return {boolean}
*/
disable: function disable() {
cov_3iwuhzg04().f[7]++;
cov_3iwuhzg04().s[45]++;
this.clearTimeout(srcChangeTimer);
cov_3iwuhzg04().s[46]++;
srcChangeTimer = null;
cov_3iwuhzg04().s[47]++;
disabled = true;
cov_3iwuhzg04().s[48]++;
return disabled;
}.bind(this),
/**
* Whether per-source behaviors are disabled on this player.
*
* @return {boolean}
* if the per-source behaviors are disabled
*/
disabled() {
cov_3iwuhzg04().f[8]++;
cov_3iwuhzg04().s[49]++;
return disabled;
},
/**
* Enable per-source behaviors on this player.
*
* @return {boolean}
* always returns true
*/
enable() {
cov_3iwuhzg04().f[9]++;
cov_3iwuhzg04().s[50]++;
disabled = false;
cov_3iwuhzg04().s[51]++;
return disabled;
},
/**
* Whether per-source behaviors are disabled on this player.
*
* @return {boolean}
* if the per-source behaviors are enabled
*/
enabled() {
cov_3iwuhzg04().f[10]++;
cov_3iwuhzg04().s[52]++;
return !disabled;
},
/**
* Whether or not the source is "stable". This will return `true` if the
* plugin feels that we may be about to change sources.
*
* @return {boolean}
* Whether the source is stable or not
*/
isSrcStable() {
cov_3iwuhzg04().f[11]++;
cov_3iwuhzg04().s[53]++;
return srcStable;
},
VERSION: version
};
/**
* Bind an event listener on a per-source basis.
*
* @function onPerSrc
* @param {String|Array|Component|Element} first
* The event type(s) or target Component or Element.
*
* @param {Function|String|Array} second
* The event listener or event type(s) (when `first` is target).
*
* @param {Function} third
* The event listener (when `second` is event type(s)).
*
* @return {Player}
*/
cov_3iwuhzg04().s[54]++;
this.onPerSrc = createPerSrcBinder();
/**
* Bind an event listener on a per-source basis. This listener can only
* be called once.
*
* @function onePerSrc
* @param {String|Array|Component|Element} first
* The event type(s) or target Component or Element.
*
* @param {Function|String|Array} second
* The event listener or event type(s) (when `first` is target).
*
* @param {Function} third
* The event listener (when `second` is event type(s)).
*
* @return {Player}
*/
cov_3iwuhzg04().s[55]++;
this.onePerSrc = createPerSrcBinder(true); // Clear out perSrcListeners cache on player dispose.
cov_3iwuhzg04().s[56]++;
this.on('dispose', () => {
cov_3iwuhzg04().f[12]++;
cov_3iwuhzg04().s[57]++;
perSrcListeners.length = 0;
});
cov_3iwuhzg04().s[58]++;
this.on(CHANGE_DETECT_EVENTS, e => {
cov_3iwuhzg04().f[13]++;
cov_3iwuhzg04().s[59]++; // Bail-out conditions.
if ((cov_3iwuhzg04().b[13][0]++, this.perSourceBehaviors.disabled()) || (cov_3iwuhzg04().b[13][1]++, srcChangeTimer) || (cov_3iwuhzg04().b[13][2]++, ignoreEvent(this, e))) {
cov_3iwuhzg04().b[12][0]++;
cov_3iwuhzg04().s[60]++;
return;
} else {
cov_3iwuhzg04().b[12][1]++;
} // If we did not previously detect that we were in an unstable state and
// this was an event that qualifies as unstable, do that now. In the future,
// we may want to restrict the conditions under which this is triggered by
// checking networkState and/or readyState for reasonable values such as
// NETWORK_NO_SOURCE and HAVE_NOTHING.
cov_3iwuhzg04().s[61]++;
if ((cov_3iwuhzg04().b[15][0]++, srcStable) && (cov_3iwuhzg04().b[15][1]++, UNSTABLE_EVENTS.indexOf(e.type) > -1)) {
cov_3iwuhzg04().b[14][0]++;
cov_3iwuhzg04().s[62]++;
srcStable = false;
cov_3iwuhzg04().s[63]++;
this.trigger('sourceunstable');
} else {
cov_3iwuhzg04().b[14][1]++;
} // Track any and all interim events from this one until the next tick
// when we evaluate the timer.
const interimEvents = (cov_3iwuhzg04().s[64]++, []);
cov_3iwuhzg04().s[65]++;
const addInterimEvent = f => {
cov_3iwuhzg04().f[14]++;
cov_3iwuhzg04().s[66]++;
return interimEvents.push({
time: Date.now(),
event: f
});
};
cov_3iwuhzg04().s[67]++;
addInterimEvent(e);
cov_3iwuhzg04().s[68]++;
this.on(Html5.Events, addInterimEvent);
cov_3iwuhzg04().s[69]++;
srcChangeTimer = this.setTimeout(() => {
cov_3iwuhzg04().f[15]++;
const currentSrc = (cov_3iwuhzg04().s[70]++, this.currentSrc());
cov_3iwuh