QualityOption.js
1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
var _ = require('underscore'),
events = require('../events');
module.exports = function(videojs) {
var MenuItem = videojs.getComponent('MenuItem');
/**
* A MenuItem to represent a video resolution
*
* @class QualityOption
* @extends videojs.MenuItem
*/
return videojs.extend(MenuItem, {
/**
* @inheritdoc
*/
constructor: function(player, options) {
var source = options.source;
if (!_.isObject(source)) {
throw new Error('was not provided a "source" object, but rather: ' + (typeof source));
}
options = _.extend({
selectable: true,
label: source.label,
}, options);
MenuItem.call(this, player, options);
this.source = source;
},
/**
* @inheritdoc
*/
handleClick: function(event) {
MenuItem.prototype.handleClick.call(this, event);
this.player().trigger(events.QUALITY_REQUESTED, this.source);
},
});
};