@antmedia/web_player 2.11.1 → 2.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/web_player.js +4 -6
- package/dist/es/{plugin-ca799d0d.js → plugin-50e1316e.js} +134 -144
- package/dist/es/{video.es-0951ae41.js → video.es-be70c095.js} +36 -41
- package/dist/es/{videojs-webrtc-plugin-327afa5e.js → videojs-webrtc-plugin-7054aa21.js} +1 -1
- package/dist/es/videojs-webrtc-plugin-f56e1f9e.js +3 -0
- package/dist/es/{video.es-22056625.js → videojs-webrtc-plugin.es-2a0dfc29.js} +14968 -5052
- package/dist/es/videojs-webrtc-plugin.es-333788d9.js +7673 -0
- package/dist/es/{videojs-webrtc-plugin.es-f41400f7.js → videojs-webrtc-plugin.es-777bf41a.js} +1747 -1697
- package/dist/es/{videojs-webrtc-plugin.es-bd0b1a6d.js → videojs-webrtc-plugin.es-9544f6e0.js} +1563 -1672
- package/dist/es/web_player.js +7 -9
- package/dist/index.d.ts +17 -1
- package/dist/{plugin-84ab2cdd.js → plugin-bec9dc4a.js} +136 -146
- package/dist/{video.es-474303e7.js → video.es-df9af03d.js} +36 -43
- package/dist/{videojs-webrtc-plugin-bdf9fa8b.js → videojs-webrtc-plugin-3becde8c.js} +1 -1
- package/dist/videojs-webrtc-plugin-77a9860b.js +5 -0
- package/dist/{videojs-webrtc-plugin.es-72234e77.js → videojs-webrtc-plugin.es-0787d11e.js} +1575 -1684
- package/dist/{video.es-72122d04.js → videojs-webrtc-plugin.es-493b195e.js} +14964 -5052
- package/dist/videojs-webrtc-plugin.es-8f4ea4e4.js +7675 -0
- package/dist/{videojs-webrtc-plugin.es-ac81d249.js → videojs-webrtc-plugin.es-ee6d0333.js} +1757 -1707
- package/dist/web_player.js +7 -9
- package/package.json +3 -5
- package/rollup.config.module.cjs +6 -2
- package/src/web_player.js +4 -6
- package/test/embedded-player.test.js +1 -1
- package/tsconfig.json +0 -1
- package/dist/aframe-master-42bb78a9.js +0 -7139
- package/dist/dash.all.min-84806d51.js +0 -36
- package/dist/es/aframe-master-a6146619.js +0 -7137
- package/dist/es/dash.all.min-4a2772b6.js +0 -34
- package/dist/es/inheritsLoose-91dc2acc.js +0 -15
- package/dist/es/video-js.min-8b4dfe88.js +0 -3
- package/dist/es/videojs-contrib-quality-levels.es-1ea32822.js +0 -276
- package/dist/es/videojs-contrib-quality-levels.es-5f5b5f23.js +0 -287
- package/dist/es/videojs-hls-quality-selector.es-3c54e1cd.js +0 -391
- package/dist/es/videojs-webrtc-plugin-b9e4da27.js +0 -3
- package/dist/inheritsLoose-281376c7.js +0 -17
- package/dist/video-js.min-7e4ae47a.js +0 -5
- package/dist/videojs-contrib-quality-levels.es-6c3be3eb.js +0 -278
- package/dist/videojs-contrib-quality-levels.es-ef3cec9e.js +0 -289
- package/dist/videojs-hls-quality-selector.es-562309df.js +0 -393
- package/dist/videojs-webrtc-plugin-d30c3e7a.js +0 -5
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var video_es = require('./video.es-474303e7.js');
|
|
4
|
-
require('./_commonjsHelpers-ed042b00.js');
|
|
5
|
-
|
|
6
|
-
/*! @name videojs-contrib-quality-levels @version 4.1.0 @license Apache-2.0 */
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A single QualityLevel.
|
|
10
|
-
*
|
|
11
|
-
* interface QualityLevel {
|
|
12
|
-
* readonly attribute DOMString id;
|
|
13
|
-
* attribute DOMString label;
|
|
14
|
-
* readonly attribute long width;
|
|
15
|
-
* readonly attribute long height;
|
|
16
|
-
* readonly attribute long bitrate;
|
|
17
|
-
* attribute boolean enabled;
|
|
18
|
-
* };
|
|
19
|
-
*
|
|
20
|
-
* @class QualityLevel
|
|
21
|
-
*/
|
|
22
|
-
class QualityLevel {
|
|
23
|
-
/**
|
|
24
|
-
* Creates a QualityLevel
|
|
25
|
-
*
|
|
26
|
-
* @param {Representation|Object} representation The representation of the quality level
|
|
27
|
-
* @param {string} representation.id Unique id of the QualityLevel
|
|
28
|
-
* @param {number=} representation.width Resolution width of the QualityLevel
|
|
29
|
-
* @param {number=} representation.height Resolution height of the QualityLevel
|
|
30
|
-
* @param {number} representation.bandwidth Bitrate of the QualityLevel
|
|
31
|
-
* @param {number=} representation.frameRate Frame-rate of the QualityLevel
|
|
32
|
-
* @param {Function} representation.enabled Callback to enable/disable QualityLevel
|
|
33
|
-
*/
|
|
34
|
-
constructor(representation) {
|
|
35
|
-
let level = this; // eslint-disable-line
|
|
36
|
-
|
|
37
|
-
level.id = representation.id;
|
|
38
|
-
level.label = level.id;
|
|
39
|
-
level.width = representation.width;
|
|
40
|
-
level.height = representation.height;
|
|
41
|
-
level.bitrate = representation.bandwidth;
|
|
42
|
-
level.frameRate = representation.frameRate;
|
|
43
|
-
level.enabled_ = representation.enabled;
|
|
44
|
-
Object.defineProperty(level, 'enabled', {
|
|
45
|
-
/**
|
|
46
|
-
* Get whether the QualityLevel is enabled.
|
|
47
|
-
*
|
|
48
|
-
* @return {boolean} True if the QualityLevel is enabled.
|
|
49
|
-
*/
|
|
50
|
-
get() {
|
|
51
|
-
return level.enabled_();
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* Enable or disable the QualityLevel.
|
|
55
|
-
*
|
|
56
|
-
* @param {boolean} enable true to enable QualityLevel, false to disable.
|
|
57
|
-
*/
|
|
58
|
-
set(enable) {
|
|
59
|
-
level.enabled_(enable);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return level;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* A list of QualityLevels.
|
|
68
|
-
*
|
|
69
|
-
* interface QualityLevelList : EventTarget {
|
|
70
|
-
* getter QualityLevel (unsigned long index);
|
|
71
|
-
* readonly attribute unsigned long length;
|
|
72
|
-
* readonly attribute long selectedIndex;
|
|
73
|
-
*
|
|
74
|
-
* void addQualityLevel(QualityLevel qualityLevel)
|
|
75
|
-
* void removeQualityLevel(QualityLevel remove)
|
|
76
|
-
* QualityLevel? getQualityLevelById(DOMString id);
|
|
77
|
-
*
|
|
78
|
-
* attribute EventHandler onchange;
|
|
79
|
-
* attribute EventHandler onaddqualitylevel;
|
|
80
|
-
* attribute EventHandler onremovequalitylevel;
|
|
81
|
-
* };
|
|
82
|
-
*
|
|
83
|
-
* @extends videojs.EventTarget
|
|
84
|
-
* @class QualityLevelList
|
|
85
|
-
*/
|
|
86
|
-
class QualityLevelList extends video_es.videojs.EventTarget {
|
|
87
|
-
/**
|
|
88
|
-
* Creates a QualityLevelList.
|
|
89
|
-
*/
|
|
90
|
-
constructor() {
|
|
91
|
-
super();
|
|
92
|
-
let list = this; // eslint-disable-line
|
|
93
|
-
|
|
94
|
-
list.levels_ = [];
|
|
95
|
-
list.selectedIndex_ = -1;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get the index of the currently selected QualityLevel.
|
|
99
|
-
*
|
|
100
|
-
* @returns {number} The index of the selected QualityLevel. -1 if none selected.
|
|
101
|
-
* @readonly
|
|
102
|
-
*/
|
|
103
|
-
Object.defineProperty(list, 'selectedIndex', {
|
|
104
|
-
get() {
|
|
105
|
-
return list.selectedIndex_;
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Get the length of the list of QualityLevels.
|
|
111
|
-
*
|
|
112
|
-
* @returns {number} The length of the list.
|
|
113
|
-
* @readonly
|
|
114
|
-
*/
|
|
115
|
-
Object.defineProperty(list, 'length', {
|
|
116
|
-
get() {
|
|
117
|
-
return list.levels_.length;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
list[Symbol.iterator] = () => list.levels_.values();
|
|
121
|
-
return list;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Adds a quality level to the list.
|
|
126
|
-
*
|
|
127
|
-
* @param {Representation|Object} representation The representation of the quality level
|
|
128
|
-
* @param {string} representation.id Unique id of the QualityLevel
|
|
129
|
-
* @param {number=} representation.width Resolution width of the QualityLevel
|
|
130
|
-
* @param {number=} representation.height Resolution height of the QualityLevel
|
|
131
|
-
* @param {number} representation.bandwidth Bitrate of the QualityLevel
|
|
132
|
-
* @param {number=} representation.frameRate Frame-rate of the QualityLevel
|
|
133
|
-
* @param {Function} representation.enabled Callback to enable/disable QualityLevel
|
|
134
|
-
* @return {QualityLevel} the QualityLevel added to the list
|
|
135
|
-
* @method addQualityLevel
|
|
136
|
-
*/
|
|
137
|
-
addQualityLevel(representation) {
|
|
138
|
-
let qualityLevel = this.getQualityLevelById(representation.id);
|
|
139
|
-
|
|
140
|
-
// Do not add duplicate quality levels
|
|
141
|
-
if (qualityLevel) {
|
|
142
|
-
return qualityLevel;
|
|
143
|
-
}
|
|
144
|
-
const index = this.levels_.length;
|
|
145
|
-
qualityLevel = new QualityLevel(representation);
|
|
146
|
-
if (!('' + index in this)) {
|
|
147
|
-
Object.defineProperty(this, index, {
|
|
148
|
-
get() {
|
|
149
|
-
return this.levels_[index];
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
this.levels_.push(qualityLevel);
|
|
154
|
-
this.trigger({
|
|
155
|
-
qualityLevel,
|
|
156
|
-
type: 'addqualitylevel'
|
|
157
|
-
});
|
|
158
|
-
return qualityLevel;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Removes a quality level from the list.
|
|
163
|
-
*
|
|
164
|
-
* @param {QualityLevel} qualityLevel The QualityLevel to remove from the list.
|
|
165
|
-
* @return {QualityLevel|null} the QualityLevel removed or null if nothing removed
|
|
166
|
-
* @method removeQualityLevel
|
|
167
|
-
*/
|
|
168
|
-
removeQualityLevel(qualityLevel) {
|
|
169
|
-
let removed = null;
|
|
170
|
-
for (let i = 0, l = this.length; i < l; i++) {
|
|
171
|
-
if (this[i] === qualityLevel) {
|
|
172
|
-
removed = this.levels_.splice(i, 1)[0];
|
|
173
|
-
if (this.selectedIndex_ === i) {
|
|
174
|
-
this.selectedIndex_ = -1;
|
|
175
|
-
} else if (this.selectedIndex_ > i) {
|
|
176
|
-
this.selectedIndex_--;
|
|
177
|
-
}
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (removed) {
|
|
182
|
-
this.trigger({
|
|
183
|
-
qualityLevel,
|
|
184
|
-
type: 'removequalitylevel'
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
return removed;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Searches for a QualityLevel with the given id.
|
|
192
|
-
*
|
|
193
|
-
* @param {string} id The id of the QualityLevel to find.
|
|
194
|
-
* @return {QualityLevel|null} The QualityLevel with id, or null if not found.
|
|
195
|
-
* @method getQualityLevelById
|
|
196
|
-
*/
|
|
197
|
-
getQualityLevelById(id) {
|
|
198
|
-
for (let i = 0, l = this.length; i < l; i++) {
|
|
199
|
-
const level = this[i];
|
|
200
|
-
if (level.id === id) {
|
|
201
|
-
return level;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Resets the list of QualityLevels to empty
|
|
209
|
-
*
|
|
210
|
-
* @method dispose
|
|
211
|
-
*/
|
|
212
|
-
dispose() {
|
|
213
|
-
this.selectedIndex_ = -1;
|
|
214
|
-
this.levels_.length = 0;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* change - The selected QualityLevel has changed.
|
|
220
|
-
* addqualitylevel - A QualityLevel has been added to the QualityLevelList.
|
|
221
|
-
* removequalitylevel - A QualityLevel has been removed from the QualityLevelList.
|
|
222
|
-
*/
|
|
223
|
-
QualityLevelList.prototype.allowedEvents_ = {
|
|
224
|
-
change: 'change',
|
|
225
|
-
addqualitylevel: 'addqualitylevel',
|
|
226
|
-
removequalitylevel: 'removequalitylevel'
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
// emulate attribute EventHandler support to allow for feature detection
|
|
230
|
-
for (const event in QualityLevelList.prototype.allowedEvents_) {
|
|
231
|
-
QualityLevelList.prototype['on' + event] = null;
|
|
232
|
-
}
|
|
233
|
-
var version = "4.1.0";
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Initialization function for the qualityLevels plugin. Sets up the QualityLevelList and
|
|
237
|
-
* event handlers.
|
|
238
|
-
*
|
|
239
|
-
* @param {Player} player Player object.
|
|
240
|
-
* @param {Object} options Plugin options object.
|
|
241
|
-
* @return {QualityLevelList} a list of QualityLevels
|
|
242
|
-
*/
|
|
243
|
-
const initPlugin = function (player, options) {
|
|
244
|
-
const originalPluginFn = player.qualityLevels;
|
|
245
|
-
const qualityLevelList = new QualityLevelList();
|
|
246
|
-
const disposeHandler = function () {
|
|
247
|
-
qualityLevelList.dispose();
|
|
248
|
-
player.qualityLevels = originalPluginFn;
|
|
249
|
-
player.off('dispose', disposeHandler);
|
|
250
|
-
};
|
|
251
|
-
player.on('dispose', disposeHandler);
|
|
252
|
-
player.qualityLevels = () => qualityLevelList;
|
|
253
|
-
player.qualityLevels.VERSION = version;
|
|
254
|
-
return qualityLevelList;
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* A video.js plugin.
|
|
259
|
-
*
|
|
260
|
-
* In the plugin function, the value of `this` is a video.js `Player`
|
|
261
|
-
* instance. You cannot rely on the player being in a "ready" state here,
|
|
262
|
-
* depending on how the plugin is invoked. This may or may not be important
|
|
263
|
-
* to you; if not, remove the wait for "ready"!
|
|
264
|
-
*
|
|
265
|
-
* @param {Object} options Plugin options object
|
|
266
|
-
* @return {QualityLevelList} a list of QualityLevels
|
|
267
|
-
*/
|
|
268
|
-
const qualityLevels = function (options) {
|
|
269
|
-
return initPlugin(this, video_es.videojs.obj.merge({}, options));
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
// Register the plugin with video.js.
|
|
273
|
-
video_es.videojs.registerPlugin('qualityLevels', qualityLevels);
|
|
274
|
-
|
|
275
|
-
// Include the version number.
|
|
276
|
-
qualityLevels.VERSION = version;
|
|
277
|
-
|
|
278
|
-
exports.default = qualityLevels;
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var video_es = require('./video.es-72122d04.js');
|
|
4
|
-
require('./_commonjsHelpers-ed042b00.js');
|
|
5
|
-
|
|
6
|
-
/*! @name videojs-contrib-quality-levels @version 2.2.1 @license Apache-2.0 */
|
|
7
|
-
function _inheritsLoose(subClass, superClass) {
|
|
8
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
9
|
-
subClass.prototype.constructor = subClass;
|
|
10
|
-
subClass.__proto__ = superClass;
|
|
11
|
-
}
|
|
12
|
-
function _assertThisInitialized(self) {
|
|
13
|
-
if (self === void 0) {
|
|
14
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15
|
-
}
|
|
16
|
-
return self;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A single QualityLevel.
|
|
21
|
-
*
|
|
22
|
-
* interface QualityLevel {
|
|
23
|
-
* readonly attribute DOMString id;
|
|
24
|
-
* attribute DOMString label;
|
|
25
|
-
* readonly attribute long width;
|
|
26
|
-
* readonly attribute long height;
|
|
27
|
-
* readonly attribute long bitrate;
|
|
28
|
-
* attribute boolean enabled;
|
|
29
|
-
* };
|
|
30
|
-
*
|
|
31
|
-
* @class QualityLevel
|
|
32
|
-
*/
|
|
33
|
-
var QualityLevel =
|
|
34
|
-
/**
|
|
35
|
-
* Creates a QualityLevel
|
|
36
|
-
*
|
|
37
|
-
* @param {Representation|Object} representation The representation of the quality level
|
|
38
|
-
* @param {string} representation.id Unique id of the QualityLevel
|
|
39
|
-
* @param {number=} representation.width Resolution width of the QualityLevel
|
|
40
|
-
* @param {number=} representation.height Resolution height of the QualityLevel
|
|
41
|
-
* @param {number} representation.bandwidth Bitrate of the QualityLevel
|
|
42
|
-
* @param {number=} representation.frameRate Frame-rate of the QualityLevel
|
|
43
|
-
* @param {Function} representation.enabled Callback to enable/disable QualityLevel
|
|
44
|
-
*/
|
|
45
|
-
function QualityLevel(representation) {
|
|
46
|
-
var level = this; // eslint-disable-line
|
|
47
|
-
|
|
48
|
-
level.id = representation.id;
|
|
49
|
-
level.label = level.id;
|
|
50
|
-
level.width = representation.width;
|
|
51
|
-
level.height = representation.height;
|
|
52
|
-
level.bitrate = representation.bandwidth;
|
|
53
|
-
level.frameRate = representation.frameRate;
|
|
54
|
-
level.enabled_ = representation.enabled;
|
|
55
|
-
Object.defineProperty(level, 'enabled', {
|
|
56
|
-
/**
|
|
57
|
-
* Get whether the QualityLevel is enabled.
|
|
58
|
-
*
|
|
59
|
-
* @return {boolean} True if the QualityLevel is enabled.
|
|
60
|
-
*/
|
|
61
|
-
get: function get() {
|
|
62
|
-
return level.enabled_();
|
|
63
|
-
},
|
|
64
|
-
/**
|
|
65
|
-
* Enable or disable the QualityLevel.
|
|
66
|
-
*
|
|
67
|
-
* @param {boolean} enable true to enable QualityLevel, false to disable.
|
|
68
|
-
*/
|
|
69
|
-
set: function set(enable) {
|
|
70
|
-
level.enabled_(enable);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
return level;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* A list of QualityLevels.
|
|
78
|
-
*
|
|
79
|
-
* interface QualityLevelList : EventTarget {
|
|
80
|
-
* getter QualityLevel (unsigned long index);
|
|
81
|
-
* readonly attribute unsigned long length;
|
|
82
|
-
* readonly attribute long selectedIndex;
|
|
83
|
-
*
|
|
84
|
-
* void addQualityLevel(QualityLevel qualityLevel)
|
|
85
|
-
* void removeQualityLevel(QualityLevel remove)
|
|
86
|
-
* QualityLevel? getQualityLevelById(DOMString id);
|
|
87
|
-
*
|
|
88
|
-
* attribute EventHandler onchange;
|
|
89
|
-
* attribute EventHandler onaddqualitylevel;
|
|
90
|
-
* attribute EventHandler onremovequalitylevel;
|
|
91
|
-
* };
|
|
92
|
-
*
|
|
93
|
-
* @extends videojs.EventTarget
|
|
94
|
-
* @class QualityLevelList
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
var QualityLevelList = /*#__PURE__*/
|
|
98
|
-
function (_videojs$EventTarget) {
|
|
99
|
-
_inheritsLoose(QualityLevelList, _videojs$EventTarget);
|
|
100
|
-
function QualityLevelList() {
|
|
101
|
-
var _this;
|
|
102
|
-
_this = _videojs$EventTarget.call(this) || this;
|
|
103
|
-
var list = _assertThisInitialized(_assertThisInitialized(_this)); // eslint-disable-line
|
|
104
|
-
|
|
105
|
-
list.levels_ = [];
|
|
106
|
-
list.selectedIndex_ = -1;
|
|
107
|
-
/**
|
|
108
|
-
* Get the index of the currently selected QualityLevel.
|
|
109
|
-
*
|
|
110
|
-
* @returns {number} The index of the selected QualityLevel. -1 if none selected.
|
|
111
|
-
* @readonly
|
|
112
|
-
*/
|
|
113
|
-
|
|
114
|
-
Object.defineProperty(list, 'selectedIndex', {
|
|
115
|
-
get: function get() {
|
|
116
|
-
return list.selectedIndex_;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
/**
|
|
120
|
-
* Get the length of the list of QualityLevels.
|
|
121
|
-
*
|
|
122
|
-
* @returns {number} The length of the list.
|
|
123
|
-
* @readonly
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
Object.defineProperty(list, 'length', {
|
|
127
|
-
get: function get() {
|
|
128
|
-
return list.levels_.length;
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
return list || _assertThisInitialized(_this);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Adds a quality level to the list.
|
|
135
|
-
*
|
|
136
|
-
* @param {Representation|Object} representation The representation of the quality level
|
|
137
|
-
* @param {string} representation.id Unique id of the QualityLevel
|
|
138
|
-
* @param {number=} representation.width Resolution width of the QualityLevel
|
|
139
|
-
* @param {number=} representation.height Resolution height of the QualityLevel
|
|
140
|
-
* @param {number} representation.bandwidth Bitrate of the QualityLevel
|
|
141
|
-
* @param {number=} representation.frameRate Frame-rate of the QualityLevel
|
|
142
|
-
* @param {Function} representation.enabled Callback to enable/disable QualityLevel
|
|
143
|
-
* @return {QualityLevel} the QualityLevel added to the list
|
|
144
|
-
* @method addQualityLevel
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
var _proto = QualityLevelList.prototype;
|
|
148
|
-
_proto.addQualityLevel = function addQualityLevel(representation) {
|
|
149
|
-
var qualityLevel = this.getQualityLevelById(representation.id); // Do not add duplicate quality levels
|
|
150
|
-
|
|
151
|
-
if (qualityLevel) {
|
|
152
|
-
return qualityLevel;
|
|
153
|
-
}
|
|
154
|
-
var index = this.levels_.length;
|
|
155
|
-
qualityLevel = new QualityLevel(representation);
|
|
156
|
-
if (!('' + index in this)) {
|
|
157
|
-
Object.defineProperty(this, index, {
|
|
158
|
-
get: function get() {
|
|
159
|
-
return this.levels_[index];
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
this.levels_.push(qualityLevel);
|
|
164
|
-
this.trigger({
|
|
165
|
-
qualityLevel: qualityLevel,
|
|
166
|
-
type: 'addqualitylevel'
|
|
167
|
-
});
|
|
168
|
-
return qualityLevel;
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* Removes a quality level from the list.
|
|
172
|
-
*
|
|
173
|
-
* @param {QualityLevel} remove QualityLevel to remove to the list.
|
|
174
|
-
* @return {QualityLevel|null} the QualityLevel removed or null if nothing removed
|
|
175
|
-
* @method removeQualityLevel
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
|
-
_proto.removeQualityLevel = function removeQualityLevel(qualityLevel) {
|
|
179
|
-
var removed = null;
|
|
180
|
-
for (var i = 0, l = this.length; i < l; i++) {
|
|
181
|
-
if (this[i] === qualityLevel) {
|
|
182
|
-
removed = this.levels_.splice(i, 1)[0];
|
|
183
|
-
if (this.selectedIndex_ === i) {
|
|
184
|
-
this.selectedIndex_ = -1;
|
|
185
|
-
} else if (this.selectedIndex_ > i) {
|
|
186
|
-
this.selectedIndex_--;
|
|
187
|
-
}
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (removed) {
|
|
192
|
-
this.trigger({
|
|
193
|
-
qualityLevel: qualityLevel,
|
|
194
|
-
type: 'removequalitylevel'
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
return removed;
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* Searches for a QualityLevel with the given id.
|
|
201
|
-
*
|
|
202
|
-
* @param {string} id The id of the QualityLevel to find.
|
|
203
|
-
* @return {QualityLevel|null} The QualityLevel with id, or null if not found.
|
|
204
|
-
* @method getQualityLevelById
|
|
205
|
-
*/
|
|
206
|
-
|
|
207
|
-
_proto.getQualityLevelById = function getQualityLevelById(id) {
|
|
208
|
-
for (var i = 0, l = this.length; i < l; i++) {
|
|
209
|
-
var level = this[i];
|
|
210
|
-
if (level.id === id) {
|
|
211
|
-
return level;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return null;
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* Resets the list of QualityLevels to empty
|
|
218
|
-
*
|
|
219
|
-
* @method dispose
|
|
220
|
-
*/
|
|
221
|
-
|
|
222
|
-
_proto.dispose = function dispose() {
|
|
223
|
-
this.selectedIndex_ = -1;
|
|
224
|
-
this.levels_.length = 0;
|
|
225
|
-
};
|
|
226
|
-
return QualityLevelList;
|
|
227
|
-
}(video_es.videojs.EventTarget);
|
|
228
|
-
/**
|
|
229
|
-
* change - The selected QualityLevel has changed.
|
|
230
|
-
* addqualitylevel - A QualityLevel has been added to the QualityLevelList.
|
|
231
|
-
* removequalitylevel - A QualityLevel has been removed from the QualityLevelList.
|
|
232
|
-
*/
|
|
233
|
-
|
|
234
|
-
QualityLevelList.prototype.allowedEvents_ = {
|
|
235
|
-
change: 'change',
|
|
236
|
-
addqualitylevel: 'addqualitylevel',
|
|
237
|
-
removequalitylevel: 'removequalitylevel'
|
|
238
|
-
}; // emulate attribute EventHandler support to allow for feature detection
|
|
239
|
-
|
|
240
|
-
for (var event in QualityLevelList.prototype.allowedEvents_) {
|
|
241
|
-
QualityLevelList.prototype['on' + event] = null;
|
|
242
|
-
}
|
|
243
|
-
var version = "2.2.1";
|
|
244
|
-
var registerPlugin = video_es.videojs.registerPlugin || video_es.videojs.plugin;
|
|
245
|
-
/**
|
|
246
|
-
* Initialization function for the qualityLevels plugin. Sets up the QualityLevelList and
|
|
247
|
-
* event handlers.
|
|
248
|
-
*
|
|
249
|
-
* @param {Player} player Player object.
|
|
250
|
-
* @param {Object} options Plugin options object.
|
|
251
|
-
* @function initPlugin
|
|
252
|
-
*/
|
|
253
|
-
|
|
254
|
-
var initPlugin = function initPlugin(player, options) {
|
|
255
|
-
var originalPluginFn = player.qualityLevels;
|
|
256
|
-
var qualityLevelList = new QualityLevelList();
|
|
257
|
-
var disposeHandler = function disposeHandler() {
|
|
258
|
-
qualityLevelList.dispose();
|
|
259
|
-
player.qualityLevels = originalPluginFn;
|
|
260
|
-
player.off('dispose', disposeHandler);
|
|
261
|
-
};
|
|
262
|
-
player.on('dispose', disposeHandler);
|
|
263
|
-
player.qualityLevels = function () {
|
|
264
|
-
return qualityLevelList;
|
|
265
|
-
};
|
|
266
|
-
player.qualityLevels.VERSION = version;
|
|
267
|
-
return qualityLevelList;
|
|
268
|
-
};
|
|
269
|
-
/**
|
|
270
|
-
* A video.js plugin.
|
|
271
|
-
*
|
|
272
|
-
* In the plugin function, the value of `this` is a video.js `Player`
|
|
273
|
-
* instance. You cannot rely on the player being in a "ready" state here,
|
|
274
|
-
* depending on how the plugin is invoked. This may or may not be important
|
|
275
|
-
* to you; if not, remove the wait for "ready"!
|
|
276
|
-
*
|
|
277
|
-
* @param {Object} options Plugin options object
|
|
278
|
-
* @function qualityLevels
|
|
279
|
-
*/
|
|
280
|
-
|
|
281
|
-
var qualityLevels = function qualityLevels(options) {
|
|
282
|
-
return initPlugin(this, video_es.videojs.mergeOptions({}, options));
|
|
283
|
-
}; // Register the plugin with video.js.
|
|
284
|
-
|
|
285
|
-
registerPlugin('qualityLevels', qualityLevels); // Include the version number.
|
|
286
|
-
|
|
287
|
-
qualityLevels.VERSION = version;
|
|
288
|
-
|
|
289
|
-
exports.default = qualityLevels;
|