|
183 | 183 | } |
184 | 184 | }; |
185 | 185 |
|
| 186 | + /** |
| 187 | + * Get data from the YouTube iFrame API. Pushes data into `this.tracks` and `this.captions`. |
| 188 | + * Initiates play to trigger loading the captions module, then stops and collects data. |
| 189 | + * |
| 190 | + * @returns {Promise} promise |
| 191 | + */ |
186 | 192 | AblePlayer.prototype.getYouTubeCaptionTracks = function () { |
187 | 193 |
|
188 | | - // get data via YouTube IFrame Player API, and push data to this.tracks & this.captions |
189 | | - // NOTE: Caption tracks are not available through the IFrame Player API |
190 | | - // until AFTER the video has started playing. |
191 | | - // Therefore, this function plays the video briefly to load the captions module |
192 | | - // then stops the video and collects the data needed to build the cc menu |
193 | | - // This is stupid, but seemingly unavoidable. |
194 | | - // Caption tracks could be obtained through the YouTube Data API |
195 | | - // but this required authors to have a Google API key, |
196 | | - // which would complicate Able Player installation |
197 | | - |
198 | 194 | var deferred = new this.defer(); |
199 | 195 | var promise = deferred.promise(); |
200 | 196 | var thisObj, ytTracks, i, trackLang, trackLabel, isDefaultTrack, apiTriggered = false; |
|
320 | 316 | AblePlayer.prototype.getYouTubeId = function (url) { |
321 | 317 |
|
322 | 318 | // return a YouTube ID, extracted from a full YouTube URL |
323 | | - // Supported URL patterns (with http or https): |
324 | | - // https://youtu.be/xxx |
325 | | - // https://www.youtube.com/watch?v=xxx |
326 | | - // https://www.youtube.com/embed/xxx |
| 319 | + // Supported URL patterns: |
| 320 | + // http|s://youtu.be/xxx |
| 321 | + // http|s://www.youtube.com/watch?v=xxx |
| 322 | + // http|s://www.youtube.com/embed/xxx |
327 | 323 |
|
328 | 324 | // in all supported patterns, the id is the last 11 characters |
329 | 325 | var idStartPos, id; |
|
0 commit comments