Skip to content

Commit 0db5202

Browse files
committed
Update YouTube support
1 parent 8a9957f commit 0db5202

11 files changed

Lines changed: 459 additions & 26 deletions

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ The following attributes are supported on the \<video\> element only:
198198
default to 360.
199199
- **poster** - path to an image file. Will be displayed in the player
200200
until the video is played.
201+
- **data-youtube-id** - optional; 11-character YouTube ID, to play the YouTube video using *Able Player*.
202+
- **data-youtube-desc-id** - optional; 11-character YouTube ID of the described version of a video. See the section below on *YouTube Support* for additional information.
201203

202204
The following additional features are supported by *Able Player*:
203205

@@ -340,12 +342,20 @@ Features of the interactive transcript include the following:
340342
YouTube Support
341343
---------------
342344

343-
To play a YouTube video in *Able Player*, simply include the **data-youtube-id** attribute
345+
To play a YouTube video in *Able Player*, simply include a **data-youtube-id** attribute
344346
on the \<video\> element. The value of this attribute must be the video's 11-character YouTube ID.
345347

346-
Currently we are unable to access captions via the YouTube API, so even if the video is already
347-
captioned on YouTube, captions will need to be included redundantly within *Able Player*
348-
as described above in the Closed Captions section.
348+
If captions are available on the YouTube video, they will be displayed automatically for users
349+
who have captions turned on when watching other YouTube videos.
350+
351+
If a described version is available of the video, include a **data-youtube-desc-id** attribute
352+
on the \<video\> element as well. The value of this attribute must be the 11-character YouTube ID
353+
of the described version. If users have "Description on by Default" checked within their *Able Player*
354+
preferences, the described version of the video will automatically play by default.
355+
356+
Adjustable playback rate is available for some videos, but only if the user has opted in on using
357+
the HTML5 player in YouTube.
358+
To opt in, visit the <a href="https://www.youtube.com/html5">YouTube HTML5 Video Player</a> page.
349359

350360
MIME Types
351361
----------

build/ableplayer.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,12 @@
102102
this.youtubeId = $(media).data('youtube-id');
103103
}
104104

105-
if ($(media).data('debug') !== undefined && $(media).data('debug') !== "false") {
106-
this.debug = true;
105+
if ($(media).data('youtube-desc-id') !== undefined && $(media).data('youtube-desc-id') !== "") {
106+
this.youtubeDescId = $(media).data('youtube-desc-id');
107107
}
108108

109-
if ($(media).data('youtube-id') !== undefined && $(media).data('youtube-id') !== "") {
110-
// move this to <source> element
111-
this.youtubeId = $(media).data('youtube-id');
109+
if ($(media).data('debug') !== undefined && $(media).data('debug') !== "false") {
110+
this.debug = true;
112111
}
113112

114113
if ($(media).data('volume') !== undefined && $(media).data('volume') !== "") {
@@ -715,8 +714,19 @@
715714
var containerId = thisObj.mediaId + '_youtube';
716715
thisObj.$mediaContainer.prepend($('<div>').attr('id', containerId));
717716

717+
var youTubeId;
718+
// if a described version is available && user prefers desription
719+
// give them the described version
720+
if (thisObj.youtubeDescId && thisObj.prefDesc) {
721+
youTubeId = thisObj.youtubeDescId;
722+
// TODO: add alert informing the user that the described version is being loaded
723+
}
724+
else {
725+
youTubeId = thisObj.youtubeId;
726+
}
727+
718728
thisObj.youtubePlayer = new YT.Player(containerId, {
719-
videoId: thisObj.youtubeId,
729+
videoId: youTubeId,
720730
height: thisObj.playerHeight.toString(),
721731
width: thisObj.playerWidth.toString(),
722732
playerVars: {
@@ -1907,7 +1917,8 @@
19071917

19081918
this.injectOffscreenHeading();
19091919

1910-
if (this.mediaType === 'video') {
1920+
// youtube adds its own big play button
1921+
if (this.mediaType === 'video' && this.player !== 'youtube') {
19111922
this.injectBigPlayButton();
19121923

19131924
// add container that captions or description will be appended to
@@ -4131,6 +4142,10 @@ console.log('number of matching parent elements: ' + prevHeading.length);
41314142
}
41324143
else if (this.player === 'youtube') {
41334144
// Youtube always supports a finite list of playback rates. Only expose controls if more than one is available.
4145+
console.log('how many playbackrates are supported?');
4146+
var ytrates = this.youtubePlayer.getAvailablePlaybackRates();
4147+
console.log(ytrates.length + '. They are: ');
4148+
console.log(ytrates);
41344149
return (this.youtubePlayer.getAvailablePlaybackRates().length > 1);
41354150
}
41364151
};
@@ -4548,6 +4563,8 @@ console.log('fast forwarding ' + this.seekInterval + ' seconds');
45484563
}
45494564
else if (this.player === 'youtube') {
45504565
var rates = this.youtubePlayer.getAvailablePlaybackRates();
4566+
console.log('available playback rates:');
4567+
console.log(rates);
45514568
var currentRate = this.getPlaybackRate();
45524569
var index = rates.indexOf(currentRate);
45534570
if (index === -1) {

media/itaccess.jpg

102 KB
Loading

0 commit comments

Comments
 (0)