3 exports.__esModule = true;
5 var _trackEnums = require('./track-enums');
7 var _track = require('./track');
9 var _track2 = _interopRequireDefault(_track);
11 var _mergeOptions = require('../utils/merge-options');
13 var _mergeOptions2 = _interopRequireDefault(_mergeOptions);
15 var _browser = require('../utils/browser.js');
17 var browser = _interopRequireWildcard(_browser);
19 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
21 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
23 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
27 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
30 * A representation of a single `VideoTrack`.
32 * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#videotrack}
35 var VideoTrack = function (_Track) {
36 _inherits(VideoTrack, _Track);
39 * Create an instance of this class.
41 * @param {Object} [options={}]
42 * Object of option names and values
44 * @param {string} [options.kind='']
45 * A valid {@link VideoTrack~Kind}
47 * @param {string} [options.id='vjs_track_' + Guid.newGUID()]
48 * A unique id for this AudioTrack.
50 * @param {string} [options.label='']
51 * The menu label for this track.
53 * @param {string} [options.language='']
54 * A valid two character language code.
56 * @param {boolean} [options.selected]
57 * If this track is the one that is currently playing.
59 function VideoTrack() {
62 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
64 _classCallCheck(this, VideoTrack);
66 var settings = (0, _mergeOptions2['default'])(options, {
67 kind: _trackEnums.VideoTrackKind[options.kind] || ''
70 // on IE8 this will be a document element
71 // for every other browser this will be a normal object
72 var track = (_this = _possibleConstructorReturn(this, _Track.call(this, settings)), _this);
76 for (var prop in VideoTrack.prototype) {
77 if (prop !== 'constructor') {
78 track[prop] = VideoTrack.prototype[prop];
84 * @member {boolean} selected
85 * If this `VideoTrack` is selected or not. When setting this will
86 * fire {@link VideoTrack#selectedchange} if the state of selected changed.
88 * @fires VideoTrack#selectedchange
90 Object.defineProperty(track, 'selected', {
94 set: function set(newSelected) {
95 // an invalid or unchanged value
96 if (typeof newSelected !== 'boolean' || newSelected === selected) {
99 selected = newSelected;
102 * An event that fires when selected changes on this track. This allows
103 * the VideoTrackList that holds this track to act accordingly.
105 * > Note: This is not part of the spec! Native tracks will do
106 * this internally without an event.
108 * @event VideoTrack#selectedchange
109 * @type {EventTarget~Event}
111 this.trigger('selectedchange');
115 // if the user sets this track to selected then
116 // set selected to that true value otherwise
118 if (settings.selected) {
119 track.selected = settings.selected;
122 return _ret = track, _possibleConstructorReturn(_this, _ret);
126 }(_track2['default']);
128 exports['default'] = VideoTrack;