Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions scripts/ableplayer-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class AblePlayer {
this.okToPlay = false;
}

let data = media[0].dataset;
let data = $(media)[0].dataset;

// loop (Boolean; if present always resolves to true, regardless of value)
this.loop = (data.loop !== undefined) ? true : false;
Expand Down Expand Up @@ -269,8 +269,8 @@ class AblePlayer {
let seekbarScope = options.seekbarScope ?? data.seekbarScope;
this.seekbarScope = (seekbarScope === 'chapter' || seekbarScope === 'chapters') ? 'chapter' : 'video';

// YouTube
let youTubeId = options.youTubeId ?? data.youTubeId;
// YouTube converts to youtube in data attributes.
let youTubeId = options.youTubeId ?? data.youtubeId;
if (youTubeId !== undefined && youTubeId !== "") {
this.youTubeId = this.getYouTubeId(youTubeId);
if (!this.hasPoster) {
Expand All @@ -279,17 +279,17 @@ class AblePlayer {
}
}

let youTubeDescId = options.youTubeDescId ?? data.youTubeDescId;
let youTubeDescId = options.youTubeDescId ?? data.youtubeDescId;
if (youTubeDescId !== undefined && youTubeDescId !== "") {
this.youTubeDescId = this.getYouTubeId(youTubeDescId);
}

let youTubeSignId = options.youTubeSignId ?? data.youTubeSignId;
let youTubeSignId = options.youTubeSignId ?? data.youtubeSignSrc;
if (youTubeSignId !== undefined && youTubeSignId !== "") {
this.youTubeSignId = this.getYouTubeId(youTubeSignId);
}

let youTubeNoCookie = options.youTubeNoCookie ?? data.youTubeNoCookie;
let youTubeNoCookie = options.youTubeNoCookie ?? data.youtubeNoCookie;
this.youTubeNoCookie = (youTubeNoCookie !== undefined && youTubeNoCookie) ? true : false;

// Vimeo
Expand Down
2 changes: 1 addition & 1 deletion scripts/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,7 @@ function addControlFunctions(AblePlayer) {
}
}
// Change the transcript language if the transcript is not currently visible.
if ( ( ! this.$transcriptArea.is(':visible') && source === 'captions' ) || source === 'init' || source === 'transcript' ) {
if ( ( source === 'captions' && typeof this.$transcriptArea !== 'undefined' && ! this.$transcriptArea.is(':visible') ) || source === 'init' || source === 'transcript' ) {
console.log('syncTrackLanguages: transcript is not visible, so changing transcript language to ' + language);
this.transcriptCaptions = captions;
this.transcriptChapters = chapters;
Expand Down
12 changes: 8 additions & 4 deletions scripts/description.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function addDescriptionFunctions(AblePlayer) {
// readDescriptionsAloud == true if text description is to be announced audibly; otherwise false
// descReader == either 'browser' or 'screenreader'

var deferred, promise;
var deferred, promise, firstSource;

deferred = new this.defer();
promise = deferred.promise();
Expand All @@ -35,8 +35,9 @@ function addDescriptionFunctions(AblePlayer) {
// check to see if there's an open-described version of this video
// checks only the first source since if a described version is provided,
// it must be provided for all sources
this.descFile = this.sources[0].getAttribute('data-desc-src');
if (typeof this.descFile !== 'undefined') {
firstSource = this.sources[0] ?? null;
this.descFile = firstSource ? this.sources[0].getAttribute('data-desc-src') : null;
if ( this.descFile !== null && this.descFile !== '' ) {
this.hasOpenDesc = true;
} else {
// there's no open-described version via data-desc-src,
Expand Down Expand Up @@ -121,7 +122,10 @@ function addDescriptionFunctions(AblePlayer) {
} else if (this.player === 'vimeo') {
return (this.activeVimeoId === this.vimeoDescId);
} else {
return (this.sources[0].getAttribute('data-desc-src') === this.sources[0].getAttribute('src'));
const firstSource = this.sources[0] ?? null;
const descSrc = firstSource ? firstSource.getAttribute('data-desc-src') : null;
const activeSrc = firstSource ? firstSource.getAttribute('src') : null;
return ( descSrc !== null && descSrc === activeSrc );
}
};

Expand Down
17 changes: 11 additions & 6 deletions scripts/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ import DOMPurify from 'dompurify';

function addSignFunctions(AblePlayer) {
AblePlayer.prototype.initSignLanguage = function() {
let firstSource, localSignSrc, remoteSignSrc, hasLocalSrc, hasRemoteSrc, hasRemoteSource, ytSignSrc, signSrc, signVideo;

this.hasSignLanguage = false;
// Sign language is only currently supported in HTML5 player and YouTube.
var hasLocalSrc = ( this.sources[0].getAttribute('data-sign-src') !== undefined && this.sources[0].getAttribute('data-sign-src') !== "" );
firstSource = this.sources[0] ?? null;
localSignSrc = firstSource ? firstSource.getAttribute('data-sign-src') : null;
remoteSignSrc = firstSource ? firstSource.getAttribute('data-youtube-sign-src') : null;
hasLocalSrc = ( localSignSrc !== null && localSignSrc !== "" );
// YouTube src can either be on a `source` element or on the `video` element.
var hasRemoteSrc = ( this.$media.data('youtube-sign-src') !== undefined && this.$media.data('youtube-sign-src') !== "" );
var hasRemoteSource = ( this.sources[0].getAttribute('data-youtube-sign-src') !== undefined && this.sources[0].getAttribute('data-youtube-sign-src') !== '' );
hasRemoteSrc = ( this.$media.data('youtube-sign-src') !== undefined && this.$media.data('youtube-sign-src') !== "" );
hasRemoteSource = ( remoteSignSrc !== null && remoteSignSrc !== '' );
if ( ! this.isIOS() && ( hasLocalSrc || hasRemoteSrc || hasRemoteSource ) && ( this.player === 'html5' || this.player === 'youtube' ) ) {
// check to see if there's a sign language video accompanying this video
// check only the first source
// If sign language is provided, it must be provided for all sources
let ytSignSrc = this.youTubeSignId ?? DOMPurify.sanitize( this.sources[0].getAttribute('data-youtube-sign-src') );
let signSrc = DOMPurify.sanitize( this.sources[0].getAttribute('data-sign-src') );
let signVideo = DOMPurify.sanitize( this.$media.data('youtube-sign-src') );
ytSignSrc = this.youTubeSignId ?? DOMPurify.sanitize( remoteSignSrc );
signSrc = DOMPurify.sanitize( localSignSrc );
signVideo = DOMPurify.sanitize( this.$media.data('youtube-sign-src') );
this.signFile = (hasLocalSrc ) ? signSrc : false;
if ( hasRemoteSrc ) {
this.signYoutubeId = signVideo;
Expand Down
7 changes: 6 additions & 1 deletion scripts/vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,12 @@ function addVimeoFunctions(AblePlayer) {
// this is likely already a vimeo ID
return url;
} else {
urlObject = new URL(url);
// Try to parse as a URL. If that fails, return the string as-is. It's probably an ID.
try {
urlObject = new URL(url);
} catch (e) {
return url;
}
}
if ( 'vimeo.com' === urlObject.hostname || 'player.vimeo.com' === urlObject.hostname ) {
// this is a full Vimeo URL
Expand Down
Loading