a56900b37f2f5452f52897ae6cce8064fd4ba39f
[yaffs-website] / node_modules / video.js / es5 / tracks / track.js
1 'use strict';
2
3 exports.__esModule = true;
4
5 var _browser = require('../utils/browser.js');
6
7 var browser = _interopRequireWildcard(_browser);
8
9 var _document = require('global/document');
10
11 var _document2 = _interopRequireDefault(_document);
12
13 var _guid = require('../utils/guid.js');
14
15 var Guid = _interopRequireWildcard(_guid);
16
17 var _eventTarget = require('../event-target');
18
19 var _eventTarget2 = _interopRequireDefault(_eventTarget);
20
21 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
22
23 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; } }
24
25 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26
27 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; }
28
29 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * @file track.js
31                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
32
33
34 /**
35  * A Track class that contains all of the common functionality for {@link AudioTrack},
36  * {@link VideoTrack}, and {@link TextTrack}.
37  *
38  * > Note: This class should not be used directly
39  *
40  * @see {@link https://html.spec.whatwg.org/multipage/embedded-content.html}
41  * @extends EventTarget
42  * @abstract
43  */
44 var Track = function (_EventTarget) {
45   _inherits(Track, _EventTarget);
46
47   /**
48    * Create an instance of this class.
49    *
50    * @param {Object} [options={}]
51    *        Object of option names and values
52    *
53    * @param {string} [options.kind='']
54    *        A valid kind for the track type you are creating.
55    *
56    * @param {string} [options.id='vjs_track_' + Guid.newGUID()]
57    *        A unique id for this AudioTrack.
58    *
59    * @param {string} [options.label='']
60    *        The menu label for this track.
61    *
62    * @param {string} [options.language='']
63    *        A valid two character language code.
64    *
65    * @abstract
66    */
67   function Track() {
68     var _ret;
69
70     var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
71
72     _classCallCheck(this, Track);
73
74     var _this = _possibleConstructorReturn(this, _EventTarget.call(this));
75
76     var track = _this; // eslint-disable-line
77
78     if (browser.IS_IE8) {
79       track = _document2['default'].createElement('custom');
80       for (var prop in Track.prototype) {
81         if (prop !== 'constructor') {
82           track[prop] = Track.prototype[prop];
83         }
84       }
85     }
86
87     var trackProps = {
88       id: options.id || 'vjs_track_' + Guid.newGUID(),
89       kind: options.kind || '',
90       label: options.label || '',
91       language: options.language || ''
92     };
93
94     /**
95      * @member {string} id
96      *         The id of this track. Cannot be changed after creation.
97      *
98      * @readonly
99      */
100
101     /**
102      * @member {string} kind
103      *         The kind of track that this is. Cannot be changed after creation.
104      *
105      * @readonly
106      */
107
108     /**
109      * @member {string} label
110      *         The label of this track. Cannot be changed after creation.
111      *
112      * @readonly
113      */
114
115     /**
116      * @member {string} language
117      *         The two letter language code for this track. Cannot be changed after
118      *         creation.
119      *
120      * @readonly
121      */
122
123     var _loop = function _loop(key) {
124       Object.defineProperty(track, key, {
125         get: function get() {
126           return trackProps[key];
127         },
128         set: function set() {}
129       });
130     };
131
132     for (var key in trackProps) {
133       _loop(key);
134     }
135
136     return _ret = track, _possibleConstructorReturn(_this, _ret);
137   }
138
139   return Track;
140 }(_eventTarget2['default']);
141
142 exports['default'] = Track;