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 `AudioTrack`. If it is part of an {@link AudioTrackList}
31 * only one `AudioTrack` in the list will be enabled at a time.
33 * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotrack}
36 var AudioTrack = function (_Track) {
37 _inherits(AudioTrack, _Track);
40 * Create an instance of this class.
42 * @param {Object} [options={}]
43 * Object of option names and values
45 * @param {AudioTrack~Kind} [options.kind='']
46 * A valid audio track kind
48 * @param {string} [options.id='vjs_track_' + Guid.newGUID()]
49 * A unique id for this AudioTrack.
51 * @param {string} [options.label='']
52 * The menu label for this track.
54 * @param {string} [options.language='']
55 * A valid two character language code.
57 * @param {boolean} [options.enabled]
58 * If this track is the one that is currently playing. If this track is part of
59 * an {@link AudioTrackList}, only one {@link AudioTrack} will be enabled.
61 function AudioTrack() {
64 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
66 _classCallCheck(this, AudioTrack);
68 var settings = (0, _mergeOptions2['default'])(options, {
69 kind: _trackEnums.AudioTrackKind[options.kind] || ''
71 // on IE8 this will be a document element
72 // for every other browser this will be a normal object
73 var track = (_this = _possibleConstructorReturn(this, _Track.call(this, settings)), _this);
77 for (var prop in AudioTrack.prototype) {
78 if (prop !== 'constructor') {
79 track[prop] = AudioTrack.prototype[prop];
84 * @member {boolean} enabled
85 * If this `AudioTrack` is enabled or not. When setting this will
86 * fire {@link AudioTrack#enabledchange} if the state of enabled is changed.
88 * @fires VideoTrack#selectedchange
90 Object.defineProperty(track, 'enabled', {
94 set: function set(newEnabled) {
95 // an invalid or unchanged value
96 if (typeof newEnabled !== 'boolean' || newEnabled === enabled) {
102 * An event that fires when enabled changes on this track. This allows
103 * the AudioTrackList 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 AudioTrack#enabledchange
109 * @type {EventTarget~Event}
111 this.trigger('enabledchange');
115 // if the user sets this track to selected then
116 // set selected to that true value otherwise
118 if (settings.enabled) {
119 track.enabled = settings.enabled;
121 track.loaded_ = true;
123 return _ret = track, _possibleConstructorReturn(_this, _ret);
127 }(_track2['default']);
129 exports['default'] = AudioTrack;