Added the Porter Stemmer module to improve searches. This doesn't deal with some...
[yaffs-website] / node_modules / video.js / es5 / tracks / video-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 `VideoTrack`.
31  *
32  * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#videotrack}
33  * @extends Track
34  */
35 var VideoTrack = function (_Track) {
36   _inherits(VideoTrack, _Track);
37
38   /**
39    * Create an instance of this class.
40    *
41    * @param {Object} [options={}]
42    *        Object of option names and values
43    *
44    * @param {string} [options.kind='']
45    *        A valid {@link VideoTrack~Kind}
46    *
47    * @param {string} [options.id='vjs_track_' + Guid.newGUID()]
48    *        A unique id for this AudioTrack.
49    *
50    * @param {string} [options.label='']
51    *        The menu label for this track.
52    *
53    * @param {string} [options.language='']
54    *        A valid two character language code.
55    *
56    * @param {boolean} [options.selected]
57    *        If this track is the one that is currently playing.
58    */
59   function VideoTrack() {
60     var _this, _ret;
61
62     var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
63
64     _classCallCheck(this, VideoTrack);
65
66     var settings = (0, _mergeOptions2['default'])(options, {
67       kind: _trackEnums.VideoTrackKind[options.kind] || ''
68     });
69
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);
73     var selected = false;
74
75     if (browser.IS_IE8) {
76       for (var prop in VideoTrack.prototype) {
77         if (prop !== 'constructor') {
78           track[prop] = VideoTrack.prototype[prop];
79         }
80       }
81     }
82
83     /**
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.
87      *
88      * @fires VideoTrack#selectedchange
89      */
90     Object.defineProperty(track, 'selected', {
91       get: function get() {
92         return selected;
93       },
94       set: function set(newSelected) {
95         // an invalid or unchanged value
96         if (typeof newSelected !== 'boolean' || newSelected === selected) {
97           return;
98         }
99         selected = newSelected;
100
101         /**
102          * An event that fires when selected changes on this track. This allows
103          * the VideoTrackList 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 VideoTrack#selectedchange
109          * @type {EventTarget~Event}
110          */
111         this.trigger('selectedchange');
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.selected) {
119       track.selected = settings.selected;
120     }
121
122     return _ret = track, _possibleConstructorReturn(_this, _ret);
123   }
124
125   return VideoTrack;
126 }(_track2['default']);
127
128 exports['default'] = VideoTrack;