mirror of
https://github.com/iv-org/videojs-quality-selector.git
synced 2025-04-25 01:39:20 -04:00
45 lines
1.0 KiB
JavaScript
45 lines
1.0 KiB
JavaScript
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);
|
|
},
|
|
|
|
});
|
|
};
|