|
16 | 16 | this.synth.cancel(); |
17 | 17 | } |
18 | 18 |
|
19 | | - if (this.hasSignLanguage && this.signVideo) { |
20 | | - // keep sign languge video in sync |
21 | | - this.signVideo.currentTime = this.startTime; |
22 | | - } |
| 19 | + this.syncSignVideo( {'time' : this.startTime } ); |
23 | 20 |
|
24 | 21 | if (this.player === 'html5') { |
25 | 22 | var seekable; |
|
33 | 30 | // this.seeking will be set to false at that point |
34 | 31 | this.media.currentTime = this.startTime; |
35 | 32 | this.seekStatus = 'complete'; |
36 | | - if (this.hasSignLanguage && this.signVideo) { |
37 | | - // keep sign languge video in sync |
38 | | - this.signVideo.currentTime = this.startTime; |
39 | | - } |
| 33 | + this.syncSignVideo( { 'time' : this.startTime } ); |
40 | 34 | } |
41 | 35 | } |
42 | 36 | else if (this.player === 'youtube') { |
|
46 | 40 | this.$posterImg.hide(); |
47 | 41 | } |
48 | 42 | } |
49 | | - if (this.hasSignLanguage && this.signVideo) { |
50 | | - // keep sign languge video in sync |
51 | | - this.signVideo.currentTime = newTime; |
52 | | - } |
| 43 | + this.syncSignVideo( {'time' : newTime } ); |
53 | 44 | } |
54 | 45 | else if (this.player === 'vimeo') { |
55 | 46 | this.vimeoPlayer.setCurrentTime(newTime).then(function() { |
|
312 | 303 | this.syncSpeechToPlaybackRate(rate); |
313 | 304 | } |
314 | 305 |
|
315 | | - if (this.hasSignLanguage && this.signVideo) { |
316 | | - this.signVideo.playbackRate = rate; |
317 | | - } |
| 306 | + this.syncSignVideo( {'rate' : rate } ); |
318 | 307 |
|
319 | 308 | if (this.player === 'html5') { |
320 | 309 | this.media.playbackRate = rate; |
|
325 | 314 | else if (this.player === 'vimeo') { |
326 | 315 | this.vimeoPlayer.setPlaybackRate(rate); |
327 | 316 | } |
328 | | - if (this.hasSignLanguage && this.signVideo) { |
329 | | - this.signVideo.playbackRate = rate; |
330 | | - } |
| 317 | + this.syncSignVideo( { 'rate' : rate } ); |
331 | 318 | this.playbackRate = rate; |
332 | 319 | this.$speed.text(this.tt.speed + ': ' + rate.toFixed(2).toString() + 'x'); |
333 | 320 | }; |
|
369 | 356 | } |
370 | 357 | }; |
371 | 358 |
|
| 359 | + AblePlayer.prototype.syncSignVideo = function(options) { |
| 360 | + if (this.hasSignLanguage && this.signVideo) { |
| 361 | + if (options && typeof options.time !== 'undefined') { |
| 362 | + this.signVideo.currentTime = options.time; |
| 363 | + } |
| 364 | + if (options && typeof options.rate !== 'undefined') { |
| 365 | + this.signVideo.playbackRate = options.rate; |
| 366 | + } |
| 367 | + if (options && typeof options.pause !== 'undefined') { |
| 368 | + this.signVideo.pause(true); |
| 369 | + } |
| 370 | + if (options && typeof options.play !== 'undefined') { |
| 371 | + this.signVideo.play(true); |
| 372 | + } |
| 373 | + if (options && typeof options.volume !== 'undefined') { |
| 374 | + this.signVideo.volume = 0; |
| 375 | + } |
| 376 | + } |
| 377 | + }; |
| 378 | + |
372 | 379 | AblePlayer.prototype.pauseMedia = function () { |
373 | 380 |
|
374 | 381 | var thisObj = this; |
375 | 382 |
|
376 | | - if (this.hasSignLanguage && this.signVideo) { |
377 | | - this.signVideo.pause(true); |
378 | | - } |
| 383 | + this.syncSignVideo( { 'pause' : true } ); |
379 | 384 |
|
380 | 385 | if (this.player === 'html5') { |
381 | 386 | this.media.pause(true); |
382 | | - if (this.hasSignLanguage && this.signVideo) { |
383 | | - this.signVideo.pause(true); |
384 | | - } |
385 | 387 | } |
386 | 388 | else if (this.player === 'youtube') { |
387 | 389 | this.youTubePlayer.pauseVideo(); |
|
395 | 397 |
|
396 | 398 | var thisObj = this; |
397 | 399 |
|
398 | | - if (this.hasSignLanguage && this.signVideo) { |
399 | | - this.signVideo.play(true); |
400 | | - } |
| 400 | + this.syncSignVideo( { 'play' : true } ); |
401 | 401 |
|
402 | 402 | if (this.player === 'html5') { |
403 | 403 | this.media.play(true); |
404 | | - if (this.hasSignLanguage && this.signVideo) { |
405 | | - this.signVideo.play(true); |
406 | | - } |
407 | 404 | } |
408 | 405 | else if (this.player === 'youtube') { |
409 | 406 |
|
|
662 | 659 | } // end if context == 'timeline' or 'init' |
663 | 660 |
|
664 | 661 | if (context === 'descriptions' || context == 'init'){ |
665 | | - |
666 | 662 | if (this.$descButton) { |
667 | | - if (this.descOn) { |
668 | | - this.$descButton.removeClass('buttonOff').attr('aria-label',this.tt.turnOffDescriptions); |
669 | | - this.$descButton.find('span.able-clipped').text(this.tt.turnOffDescriptions); |
670 | | - } |
671 | | - else { |
672 | | - this.$descButton.addClass('buttonOff').attr('aria-label',this.tt.turnOnDescriptions); |
673 | | - this.$descButton.find('span.able-clipped').text(this.tt.turnOnDescriptions); |
674 | | - } |
| 663 | + this.toggleButtonState( |
| 664 | + this.$descButton, |
| 665 | + this.descOn, |
| 666 | + this.tt.turnOffDescriptions, |
| 667 | + this.tt.turnOnDescriptions, |
| 668 | + ); |
675 | 669 | } |
676 | 670 | } |
677 | 671 |
|
|
681 | 675 |
|
682 | 676 | captionsCount = this.captions.length; |
683 | 677 |
|
684 | | - // Button has a different title depending on the number of captions. |
685 | | - // If only one caption track, this is "Show captions" and "Hide captions" |
686 | | - // Otherwise, it is just always "Captions" |
687 | | - if (!this.captionsOn) { |
688 | | - this.$ccButton.addClass('buttonOff'); |
689 | | - this.$ccButton.attr('aria-pressed', 'false') |
690 | | - if (captionsCount === 1) { |
691 | | - this.$ccButton.attr('aria-label',this.tt.showCaptions); |
692 | | - this.$ccButton.find('span.able-clipped').text(this.tt.showCaptions); |
693 | | - } |
694 | | - } |
695 | | - else { |
696 | | - this.$ccButton.removeClass('buttonOff'); |
697 | | - this.$ccButton.attr('aria-pressed', 'true') |
698 | | - if (captionsCount === 1) { |
699 | | - this.$ccButton.attr('aria-label',this.tt.hideCaptions); |
700 | | - this.$ccButton.find('span.able-clipped').text(this.tt.hideCaptions); |
701 | | - } |
702 | | - } |
703 | | - |
704 | 678 | if (captionsCount > 1) { |
705 | 679 | this.$ccButton.attr({ |
706 | | - 'aria-label': this.tt.captions, |
707 | 680 | 'aria-haspopup': 'true', |
708 | 681 | 'aria-controls': this.mediaId + '-captions-menu' |
709 | 682 | }); |
710 | | - this.$ccButton.find('span.able-clipped').text(this.tt.captions); |
711 | 683 | } |
| 684 | + var ariaLabelOn = ( captionsCount > 1 ) ? this.tt.captions : this.tt.showCaptions; |
| 685 | + var ariaLabelOff = ( captionsCount > 1 ) ? this.tt.captions : this.tt.hideCaptions; |
| 686 | + var ariaPressed = ( captionsCount > 1 ) ? true : false; |
| 687 | + |
| 688 | + this.toggleButtonState( |
| 689 | + this.$ccButton, |
| 690 | + this.captionsOn, |
| 691 | + ariaLabelOff, |
| 692 | + ariaLabelOn, |
| 693 | + ariaPressed |
| 694 | + ); |
712 | 695 | } |
713 | 696 | } |
714 | 697 |
|
|
799 | 782 | // only scroll once after moving a highlight |
800 | 783 | if (this.movingHighlight) { |
801 | 784 | this.$transcriptDiv.scrollTop(newTop); |
802 | | - this.movingHighlight = false; |
803 | | - } |
| 785 | + this.movingHighlight = false; |
| 786 | + } |
804 | 787 | } |
805 | 788 | } |
806 | 789 | } |
|
1383 | 1366 | AblePlayer.prototype.handleTranscriptToggle = function () { |
1384 | 1367 |
|
1385 | 1368 | var thisObj = this; |
1386 | | - |
1387 | | - if (this.$transcriptDiv.is(':visible')) { |
| 1369 | + var visible = this.$transcriptDiv.is(':visible'); |
| 1370 | + if ( visible ) { |
1388 | 1371 | this.$transcriptArea.hide(); |
1389 | | - this.$transcriptButton.addClass('buttonOff').attr('aria-label',this.tt.showTranscript); |
1390 | | - this.$transcriptButton.find('span.able-clipped').text(this.tt.showTranscript); |
| 1372 | + this.toggleButtonState( this.$transcriptButton, visible, this.tt.hideTranscript, this.tt.showTranscript ); |
1391 | 1373 | this.prefTranscript = 0; |
1392 | 1374 | this.$transcriptButton.trigger('focus').addClass('able-focus'); |
1393 | 1375 | // wait briefly before resetting stopgap var |
|
1404 | 1386 | // showing transcriptArea has a cascading effect of showing all content *within* transcriptArea |
1405 | 1387 | // need to re-hide the popup menu |
1406 | 1388 | this.$transcriptPopup.hide(); |
1407 | | - this.$transcriptButton.removeClass('buttonOff').attr('aria-label',this.tt.hideTranscript); |
1408 | | - this.$transcriptButton.find('span.able-clipped').text(this.tt.hideTranscript); |
| 1389 | + this.toggleButtonState( this.$transcriptButton, visible, this.tt.hideTranscript, this.tt.showTranscript ); |
1409 | 1390 | this.prefTranscript = 1; |
1410 | 1391 | // move focus to first focusable element (window options button) |
1411 | 1392 | this.focusNotClick = true; |
|
1421 | 1402 | AblePlayer.prototype.handleSignToggle = function () { |
1422 | 1403 |
|
1423 | 1404 | var thisObj = this; |
1424 | | - |
1425 | | - if (this.$signWindow.is(':visible')) { |
| 1405 | + var visible = this.$signWindow.is(':visible'); |
| 1406 | + if ( visible ) { |
1426 | 1407 | this.$signWindow.hide(); |
1427 | | - this.$signButton.addClass('buttonOff').attr('aria-label',this.tt.showSign); |
1428 | | - this.$signButton.find('span.able-clipped').text(this.tt.showSign); |
| 1408 | + this.toggleButtonState( this.$signButton, visible, this.tt.hideSign, this.tt.showSign ); |
1429 | 1409 | this.prefSign = 0; |
1430 | 1410 | this.$signButton.trigger('focus').addClass('able-focus'); |
1431 | 1411 | // wait briefly before resetting stopgap var |
|
1440 | 1420 | // showing signWindow has a cascading effect of showing all content *within* signWindow |
1441 | 1421 | // need to re-hide the popup menu |
1442 | 1422 | this.$signPopup.hide(); |
1443 | | - this.$signButton.removeClass('buttonOff').attr('aria-label',this.tt.hideSign); |
1444 | | - this.$signButton.find('span.able-clipped').text(this.tt.hideSign); |
| 1423 | + this.toggleButtonState( this.$signButton, visible, this.tt.hideSign, this.tt.showSign ); |
1445 | 1424 | this.prefSign = 1; |
1446 | 1425 | this.focusNotClick = true; |
1447 | 1426 | this.$signWindow.find('button').first().trigger('focus'); |
|
1657 | 1636 | this.refreshControls('transcript'); |
1658 | 1637 | }; |
1659 | 1638 |
|
| 1639 | + AblePlayer.prototype.toggleButtonState = function($button, isOn, onLabel, offLabel, offClass = 'buttonOff', ariaPressed = false, ariaExpanded = false) { |
| 1640 | + if (isOn) { |
| 1641 | + $button.removeClass(offClass).attr('aria-label', onLabel); |
| 1642 | + $button.find('span.able-clipped').text(onLabel); |
| 1643 | + if ( ariaPressed ) { |
| 1644 | + $button.attr('aria-pressed', 'true'); |
| 1645 | + } |
| 1646 | + if ( ariaExpanded ) { |
| 1647 | + $button.attr( 'aria-expanded', 'true' ); |
| 1648 | + } |
| 1649 | + } else { |
| 1650 | + $button.addClass(offClass).attr('aria-label', offLabel); |
| 1651 | + $button.find('span.able-clipped').text(offLabel); |
| 1652 | + if ( ariaPressed ) { |
| 1653 | + $button.attr('aria-pressed', 'false'); |
| 1654 | + } |
| 1655 | + if ( ariaExpanded ) { |
| 1656 | + $button.attr( 'aria-expanded', 'false' ); |
| 1657 | + } |
| 1658 | + } |
| 1659 | + }; |
1660 | 1660 |
|
1661 | 1661 | AblePlayer.prototype.showTooltip = function($tooltip) { |
1662 | 1662 |
|
|
0 commit comments