Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / node_modules / video.js / es5 / tracks / audio-track.js
1 'use strict';
2
3 exports.__esModule = true;
4
5 var _trackEnums = require('./track-enums');
6
7 var _track = require('./track');
8
9 var _track2 = _interopRequireDefault(_track);
10
11 var _mergeOptions = require('../utils/merge-options');
12
13 var _mergeOptions2 = _interopRequireDefault(_mergeOptions);
14
15 var _browser = require('../utils/browser.js');
16
17 var browser = _interopRequireWildcard(_browser);
18
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; } }
20
21 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
22
23 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
24
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; }
26
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; }
28
29 /**
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.
32  *
33  * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#audiotrack}
34  * @extends Track
35  */
36 var AudioTrack = function (_Track) {
37   _inherits(AudioTrack, _Track);
38
39   /**
40    * Create an instance of this class.
41    *
42    * @param {Object} [options={}]
43    *        Object of option names and values
44    *
45    * @param {AudioTrack~Kind} [options.kind='']
46    *        A valid audio track kind
47    *
48    * @param {string} [options.id='vjs_track_' + Guid.newGUID()]
49    *        A unique id for this AudioTrack.
50    *
51    * @param {string} [options.label='']
52    *        The menu label for this track.
53    *
54    * @param {string} [options.language='']
55    *        A valid two character language code.
56    *
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.
60    */
61   function AudioTrack() {
62     var _this, _ret;
63
64     var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
65
66     _classCallCheck(this, AudioTrack);
67
68     var settings = (0, _mergeOptions2['default'])(options, {
69       kind: _trackEnums.AudioTrackKind[options.kind] || ''
70     });
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);
74     var enabled = false;
75
76     if (browser.IS_IE8) {
77       for (var prop in AudioTrack.prototype) {
78         if (prop !== 'constructor') {
79           track[prop] = AudioTrack.prototype[prop];
80         }
81       }
82     }
83     /**
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.
87      *
88      * @fires VideoTrack#selectedchange
89      */
90     Object.defineProperty(track, 'enabled', {
91       get: function get() {
92         return enabled;
93       },
94       set: function set(newEnabled) {
95         // an invalid or unchanged value
96         if (typeof newEnabled !== 'boolean' || newEnabled === enabled) {
97           return;
98         }
99         enabled = newEnabled;
100
101         /**
102          * An event that fires when enabled changes on this track. This allows
103          * the AudioTrackList that holds this track to act accordingly.
104          *
105          * > Note: This is not part of the spec! Native tracks will do
106          *         this internally without an event.
107          *
108          * @event AudioTrack#enabledchange
109          * @type {EventTarget~Event}
110          */
111         this.trigger('enabledchange');
112       }
113     });
114
115     // if the user sets this track to selected then
116     // set selected to that true value otherwise
117     // we keep it false
118     if (settings.enabled) {
119       track.enabled = settings.enabled;
120     }
121     track.loaded_ = true;
122
123     return _ret = track, _possibleConstructorReturn(_this, _ret);
124   }
125
126   return AudioTrack;
127 }(_track2['default']);
128
129 exports['default'] = AudioTrack;