Skip to content

Commit 4415775

Browse files
committed
Improve logic for identifying appropriate sign src.
YouTube source can either be on a `source` element or on the `video` element, because the cases of "local with remote sign" requires `source` but `youtube with remote sign` only requires `video`.
1 parent 14f73ae commit 4415775

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

‎scripts/sign.js‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
(function ($) {
22
AblePlayer.prototype.initSignLanguage = function() {
3+
this.hasSignLanguage = false;
34
// Sign language is only currently supported in HTML5 player and YouTube.
45
var hasLocalSrc = ( this.$media.data('sign-src') !== undefined && this.$media.data('sign-src') !== "" );
6+
// YouTube src can either be on a `source` element or on the `video` element.
57
var hasRemoteSrc = ( this.$media.data('youtube-sign-src') !== undefined && this.$media.data('youtube-sign-src') !== "" );
6-
if ( ! this.isIOS() && ( hasLocalSrc || hasRemoteSrc ) ) {
7-
this.hasSignLanguage = true;
8-
if ( hasRemoteSrc ) {
9-
this.signYoutubeId = this.youTubeSignId;
10-
}
11-
}
12-
if (this.player === 'html5' || this.player === 'youtube' ) {
8+
var hasRemoteSource = ( this.$sources.first().attr('data-youtube-sign-src') !== undefined && this.$sources.first().attr('data-youtube-sign-src') !== '' );
9+
if ( ! this.isIOS() && ( hasLocalSrc || hasRemoteSrc || hasRemoteSource ) && ( this.player === 'html5' || this.player === 'youtube' ) ) {
1310
// check to see if there's a sign language video accompanying this video
1411
// check only the first source
1512
// If sign language is provided, it must be provided for all sources
16-
this.signYoutubeId = this.youTubeSignId ?? DOMPurify.sanitize( this.$sources.first().attr('data-youtube-sign-src') );
13+
let ytSignSrc = this.youTubeSignId ?? DOMPurify.sanitize( this.$sources.first().attr('data-youtube-sign-src') );
1714
let signSrc = DOMPurify.sanitize( this.$sources.first().attr('data-sign-src') );
1815
let signVideo = DOMPurify.sanitize( this.$media.data('youtube-sign-src') );
19-
this.signFile = ( signVideo ) ? signVideo : signSrc;
20-
if (this.signFile || this.signYoutubeId) {
16+
this.signFile = (hasLocalSrc ) ? signSrc : false;
17+
if ( hasRemoteSrc ) {
18+
this.signYoutubeId = signVideo;
19+
} else if ( hasRemoteSource ) {
20+
this.signYoutubeId = ytSignSrc;
21+
}
22+
if ( this.signFile || this.signYoutubeId ) {
2123
if (this.isIOS()) {
2224
// iOS does not allow multiple videos to play simultaneously
2325
// Therefore, sign language as rendered by Able Player unfortunately won't work
24-
this.hasSignLanguage = false;
2526
if (this.debug) {
2627
console.log('Sign language has been disabled due to iOS restrictions');
2728
}
@@ -32,11 +33,7 @@
3233
this.hasSignLanguage = true;
3334
this.injectSignPlayerCode();
3435
}
35-
} else {
36-
this.hasSignLanguage = false;
3736
}
38-
} else {
39-
this.hasSignLanguage = false;
4037
}
4138
};
4239

0 commit comments

Comments
 (0)