|
2731 | 2731 | if (vimeoDescId !== undefined && vimeoDescId !== "") { |
2732 | 2732 | this.vimeoDescId = this.getVimeoId(vimeoDescId); |
2733 | 2733 | } |
| 2734 | + let vimeoSignId = options.vimeoSignId ?? data.vimeoSignSrc; |
| 2735 | + if (vimeoSignId !== undefined && vimeoSignId !== "") { |
| 2736 | + // getVimeoId() sets a shared flag; keep the main video's value. |
| 2737 | + let mainUrlHasParams = this.vimeoUrlHasParams; |
| 2738 | + this.vimeoSignId = this.getVimeoId(vimeoSignId); |
| 2739 | + this.vimeoSignUrlHasParams = this.vimeoUrlHasParams; |
| 2740 | + this.vimeoUrlHasParams = mainUrlHasParams; |
| 2741 | + } |
2734 | 2742 |
|
2735 | 2743 | // Skin |
2736 | 2744 | let skin = options.skin ?? data.skin; |
|
6519 | 6527 | }; |
6520 | 6528 |
|
6521 | 6529 | AblePlayer.prototype.syncSignVideo = function(options) { |
| 6530 | + if (this.hasSignLanguage && this.vimeoSignPlayer && options) { |
| 6531 | + const sign = this.vimeoSignPlayer; |
| 6532 | + const thisObj = this; |
| 6533 | + const ignore = function(error) { |
| 6534 | + if (thisObj.debug) ; |
| 6535 | + }; |
| 6536 | + if (typeof options.time !== 'undefined') { |
| 6537 | + sign.setCurrentTime(options.time).catch(ignore); |
| 6538 | + } |
| 6539 | + if (typeof options.rate !== 'undefined') { |
| 6540 | + sign.setPlaybackRate(options.rate).catch(ignore); |
| 6541 | + } |
| 6542 | + if (typeof options.pause !== 'undefined') { |
| 6543 | + sign.pause().catch(ignore); |
| 6544 | + } |
| 6545 | + if (typeof options.play !== 'undefined') { |
| 6546 | + sign.play().catch(ignore); |
| 6547 | + } |
| 6548 | + if (typeof options.volume !== 'undefined') { |
| 6549 | + sign.setVolume(0).catch(ignore); |
| 6550 | + } |
| 6551 | + return; |
| 6552 | + } |
6522 | 6553 | if (this.hasSignLanguage && ( this.signVideo || this.signYoutube ) ) { |
6523 | 6554 | if (options && typeof options.time !== 'undefined') { |
6524 | 6555 | if ( this.signVideo ) { |
|
10092 | 10123 | thisObj.startedPlaying = true; |
10093 | 10124 | thisObj.paused = false; |
10094 | 10125 | thisObj.refreshControls('playpause'); |
| 10126 | + thisObj.syncSignVideo( { 'play' : true } ); |
10095 | 10127 | }); |
10096 | 10128 | this.vimeoPlayer.on('ended', function(e) { |
10097 | 10129 | // Triggered any time the video playback reaches the end. |
|
10145 | 10177 | thisObj.clickedPlay = false; // done with this variable |
10146 | 10178 | thisObj.onMediaPause(); |
10147 | 10179 | thisObj.refreshControls('playpause'); |
| 10180 | + thisObj.syncSignVideo( { 'pause' : true } ); |
10148 | 10181 | }); |
10149 | 10182 | this.vimeoPlayer.on('playbackratechange',function(e) { |
10150 | 10183 | // Triggered when the playback rate of the video in the player changes. |
|
12468 | 12501 | } |
12469 | 12502 | }; |
12470 | 12503 |
|
| 12504 | + // Migrate a legacy Able-Player cookie into localStorage, then delete the cookie. |
| 12505 | + // Only used when the Cookies library is unavailable. |
| 12506 | + AblePlayer.prototype.migrateCookiePrefs = function() { |
| 12507 | + var match = document.cookie.match( /(?:^|;\s*)Able-Player=([^;]*)/ ); |
| 12508 | + if ( ! match ) { |
| 12509 | + return; |
| 12510 | + } |
| 12511 | + try { |
| 12512 | + var parsed = JSON.parse( decodeURIComponent( match[1] ) ); |
| 12513 | + if ( parsed && typeof parsed === 'object' && ! Array.isArray( parsed ) ) { |
| 12514 | + // Copy only expected keys, with expected types. |
| 12515 | + var clean = { |
| 12516 | + preferences: {}, |
| 12517 | + sign: {}, |
| 12518 | + transcript: {}, |
| 12519 | + voices: [] |
| 12520 | + }; |
| 12521 | + [ 'preferences', 'sign', 'transcript' ].forEach( function( key ) { |
| 12522 | + if ( parsed[key] && typeof parsed[key] === 'object' && ! Array.isArray( parsed[key] ) ) { |
| 12523 | + Object.keys( parsed[key] ).forEach( function( k ) { |
| 12524 | + if ( k !== '__proto__' && k !== 'constructor' && k !== 'prototype' ) { |
| 12525 | + clean[key][k] = parsed[key][k]; |
| 12526 | + } |
| 12527 | + } ); |
| 12528 | + } |
| 12529 | + } ); |
| 12530 | + if ( Array.isArray( parsed.voices ) ) { |
| 12531 | + clean.voices = parsed.voices; |
| 12532 | + } |
| 12533 | + // Don't overwrite preferences already in localStorage. |
| 12534 | + if ( localStorage.getItem( 'Able-Player' ) === null ) { |
| 12535 | + localStorage.setItem( 'Able-Player', JSON.stringify( clean ) ); |
| 12536 | + } |
| 12537 | + } |
| 12538 | + } catch ( err ) { |
| 12539 | + // Invalid cookie; discard it. |
| 12540 | + } |
| 12541 | + var secure = location.protocol === 'https:' ? '; Secure' : ''; |
| 12542 | + var expired = 'Able-Player=; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Strict' + secure; |
| 12543 | + document.cookie = expired + '; path=/'; |
| 12544 | + document.cookie = expired; |
| 12545 | + }; |
| 12546 | + |
12471 | 12547 | AblePlayer.prototype.getPref = function() { |
12472 | 12548 |
|
12473 | 12549 | var defaultPrefs = { |
|
12482 | 12558 | if ( typeof Cookies !== 'undefined' ) { |
12483 | 12559 | preferences = JSON.parse( Cookies.get('Able-Player') ); |
12484 | 12560 | } else { |
| 12561 | + this.migrateCookiePrefs(); |
12485 | 12562 | preferences = JSON.parse( localStorage.getItem('Able-Player') ); |
12486 | 12563 | } |
12487 | 12564 | } |
@@ -13979,22 +14056,31 @@ |
13979 | 14056 | }; |
13980 | 14057 | } |
13981 | 14058 |
|
13982 | | - /* global YT */ |
| 14059 | + /* global YT, Vimeo */ |
13983 | 14060 |
|
13984 | 14061 | function addSignFunctions(AblePlayer) { |
13985 | 14062 | AblePlayer.prototype.initSignLanguage = function() { |
13986 | | - let firstSource, localSignSrc, remoteSignSrc, hasLocalSrc, hasRemoteSrc, hasRemoteSource, ytSignSrc, signSrc, signVideo; |
| 14063 | + let firstSource, localSignSrc, remoteSignSrc, vimeoSignSrc, hasLocalSrc, hasRemoteSrc, hasRemoteSource, hasVimeoSign, ytSignSrc, signSrc, signVideo; |
13987 | 14064 |
|
13988 | 14065 | this.hasSignLanguage = false; |
13989 | | - // Sign language is only currently supported in HTML5 player and YouTube. |
| 14066 | + // Sign language is supported on all players. |
13990 | 14067 | firstSource = this.sources[0] ?? null; |
13991 | 14068 | localSignSrc = firstSource ? firstSource.getAttribute('data-sign-src') : null; |
13992 | 14069 | remoteSignSrc = firstSource ? firstSource.getAttribute('data-youtube-sign-src') : null; |
| 14070 | + vimeoSignSrc = firstSource ? firstSource.getAttribute('data-vimeo-sign-src') : null; |
13993 | 14071 | hasLocalSrc = ( localSignSrc !== null && localSignSrc !== "" ); |
13994 | 14072 | // YouTube src can either be on a `source` element or on the `video` element. |
13995 | 14073 | hasRemoteSrc = ( this.$media.data('youtube-sign-src') !== undefined && this.$media.data('youtube-sign-src') !== "" ); |
13996 | 14074 | hasRemoteSource = ( remoteSignSrc !== null && remoteSignSrc !== '' ); |
13997 | | - if ( ! this.isIOS() && ( hasLocalSrc || hasRemoteSrc || hasRemoteSource ) && ( this.player === 'html5' || this.player === 'youtube' ) ) { |
| 14075 | + // Vimeo src can also be on either element. |
| 14076 | + if ( ! this.vimeoSignId && vimeoSignSrc ) { |
| 14077 | + let mainUrlHasParams = this.vimeoUrlHasParams; |
| 14078 | + this.vimeoSignId = this.getVimeoId( vimeoSignSrc ); |
| 14079 | + this.vimeoSignUrlHasParams = this.vimeoUrlHasParams; |
| 14080 | + this.vimeoUrlHasParams = mainUrlHasParams; |
| 14081 | + } |
| 14082 | + hasVimeoSign = !! this.vimeoSignId; |
| 14083 | + if ( ! this.isIOS() && ( hasLocalSrc || hasRemoteSrc || hasRemoteSource || hasVimeoSign ) && ( this.player === 'html5' || this.player === 'youtube' || this.player === 'vimeo' ) ) { |
13998 | 14084 | // check to see if there's a sign language video accompanying this video |
13999 | 14085 | // check only the first source |
14000 | 14086 | // If sign language is provided, it must be provided for all sources |
|
14007 | 14093 | } else if ( hasRemoteSource ) { |
14008 | 14094 | this.signYoutubeId = ytSignSrc; |
14009 | 14095 | } |
14010 | | - if ( this.signFile || this.signYoutubeId ) { |
| 14096 | + if ( this.signFile || this.signYoutubeId || this.vimeoSignId ) { |
14011 | 14097 | if (this.isIOS()) { |
14012 | 14098 | // iOS does not allow multiple videos to play simultaneously |
14013 | 14099 | // Therefore, sign language as rendered by Able Player unfortunately won't work |
|
14028 | 14114 |
|
14029 | 14115 | signVideoId = this.mediaId + '-sign'; |
14030 | 14116 |
|
14031 | | - if ( this.signFile || this.signYoutubeId ) { |
| 14117 | + if ( this.signFile || this.signYoutubeId || this.vimeoSignId ) { |
14032 | 14118 | if ( null !== this.$signDivLocation ) { |
14033 | 14119 | this.$signDivLocation.addClass( 'able-sign-window able-fixed' ); |
14034 | 14120 | this.$signWindow = this.$signDivLocation; |
|
14086 | 14172 | this.$signWindow.append( this.$signVideo ); |
14087 | 14173 | } else if ( this.signYoutubeId ) { |
14088 | 14174 | this.signYoutube = this.initYouTubeSignPlayer(); |
| 14175 | + } else if ( this.vimeoSignId ) { |
| 14176 | + this.signVimeo = this.initVimeoSignPlayer(); |
14089 | 14177 | } |
14090 | 14178 |
|
14091 | 14179 | // make it draggable |
|
14104 | 14192 | }; |
14105 | 14193 |
|
14106 | 14194 |
|
| 14195 | + AblePlayer.prototype.initVimeoSignPlayer = function () { |
| 14196 | + |
| 14197 | + var thisObj, containerId, id, options; |
| 14198 | + thisObj = this; |
| 14199 | + containerId = this.mediaId + '_vimeo_sign'; |
| 14200 | + id = purify.sanitize( String( this.vimeoSignId ) ); |
| 14201 | + |
| 14202 | + this.vimeoSignPlayerReady = false; |
| 14203 | + this.$signWindow.append( $('<div>').attr('id', containerId) ); |
| 14204 | + |
| 14205 | + options = this.vimeoSignUrlHasParams ? { url: id } : { id: id }; |
| 14206 | + options.controls = false; |
| 14207 | + options.muted = true; |
| 14208 | + options.autoplay = false; |
| 14209 | + |
| 14210 | + this.vimeoSignPlayer = new Vimeo.Player( containerId, options ); |
| 14211 | + return this.vimeoSignPlayer.ready().then( function() { |
| 14212 | + $('#' + containerId).children('iframe').attr({ |
| 14213 | + 'tabindex': '-1', |
| 14214 | + 'aria-hidden': true |
| 14215 | + }); |
| 14216 | + thisObj.vimeoSignPlayer.setVolume(0).catch(function() {}); |
| 14217 | + if ( thisObj.startTime ) { |
| 14218 | + thisObj.vimeoSignPlayer.setCurrentTime( thisObj.startTime ).catch(function() {}); |
| 14219 | + } |
| 14220 | + thisObj.vimeoSignPlayerReady = true; |
| 14221 | + }).catch( function() {} ); |
| 14222 | + }; |
| 14223 | + |
14107 | 14224 | AblePlayer.prototype.initYouTubeSignPlayer = function () { |
14108 | 14225 |
|
14109 | 14226 | var thisObj, deferred, promise; |
|
0 commit comments