|
3396 | 3396 | tracks = this.captions; |
3397 | 3397 | } |
3398 | 3398 | else if (popup == 'chapters') { |
3399 | | - if (typeof this.chaptersPopup === 'undefined') { |
3400 | | - this.chaptersPopup = this.createPopup('chapters'); |
3401 | | - } |
3402 | | - tracks = this.chapters; |
| 3399 | + // sets the appropriate language for chapters if there are multiple chapter tracks available. |
| 3400 | + thisObj.updateChaptersLanguage(); |
| 3401 | + if (typeof this.chaptersPopup === 'undefined') { |
| 3402 | + this.chaptersPopup = this.createPopup('chapters'); |
| 3403 | + } |
| 3404 | + if (this.selectedChapters) { |
| 3405 | + tracks = this.selectedChapters.cues; |
| 3406 | + } |
| 3407 | + else if (this.chapters.length >= 1) { |
| 3408 | + tracks = this.chapters[0].cues; |
| 3409 | + } |
| 3410 | + else { |
| 3411 | + tracks = []; |
| 3412 | + } |
3403 | 3413 | } |
3404 | 3414 | else if (popup == 'ytCaptions') { |
3405 | 3415 | if (typeof this.captionsPopup === 'undefined') { |
|
4693 | 4703 | // Replace the following line with the commented block that follows |
4694 | 4704 | // Haven't done this because it will have a big effect downstream |
4695 | 4705 | // on all chapter processing |
4696 | | - this.chapters = cues; |
| 4706 | + //this.chapters = cues; |
4697 | 4707 |
|
4698 | | - /* // new |
| 4708 | + // new |
4699 | 4709 | this.chapters.push({ |
4700 | 4710 | cues: cues, |
4701 | 4711 | language: trackLang |
4702 | 4712 | }); |
4703 | | - */ |
4704 | 4713 |
|
4705 | 4714 | if (this.chaptersDivLocation) { |
4706 | 4715 | this.populateChaptersDiv(); |
|
7308 | 7317 | else if (this.player === 'youtube') { |
7309 | 7318 | this.seekBar.setBuffered(this.youTubePlayer.getVideoLoadedFraction()); |
7310 | 7319 | } |
| 7320 | + // This will adjust the text in the chapter pop-ups. |
| 7321 | + // This is to respond to changes in the caption language and transcript language when appropriate. |
| 7322 | + // See "updateChaptersLanguage" in chapters.js to see how this is handled. |
| 7323 | + this.setupPopups('chapters'); |
7311 | 7324 | }; |
7312 | 7325 |
|
7313 | 7326 | AblePlayer.prototype.getHiddenWidth = function($el) { |
|
7632 | 7645 | this.prefTranscript = 1; |
7633 | 7646 | } |
7634 | 7647 | this.updateCookie('prefTranscript'); |
| 7648 | + this.setupPopups('chapters'); |
7635 | 7649 | }; |
7636 | 7650 |
|
7637 | 7651 | AblePlayer.prototype.handleSignToggle = function () { |
|
8617 | 8631 | } |
8618 | 8632 | }; |
8619 | 8633 |
|
| 8634 | + AblePlayer.prototype.updateChaptersLanguage = function () { |
| 8635 | + var thisObj = this; |
| 8636 | + var matchChapLang = function (languageToMatch){ |
| 8637 | + for (var i = 0; i < thisObj.chapters.length; i++) { |
| 8638 | + if(languageToMatch == thisObj.chapters[i].language){ |
| 8639 | + thisObj.selectedChapters = thisObj.chapters[i]; |
| 8640 | + return true; |
| 8641 | + } |
| 8642 | + } |
| 8643 | + return false; |
| 8644 | + }; |
| 8645 | + |
| 8646 | + var isSelectedChaptersUpdated = false; |
| 8647 | + // if captions are on, use the language of the captions |
| 8648 | + if(this.captionsOn || this.prefCaptions){ |
| 8649 | + isSelectedChaptersUpdated = matchChapLang(this.captionLang); |
| 8650 | + } |
| 8651 | + // if captions are off, and the transcript is on, use the transcript language |
| 8652 | + if(this.prefTranscript && !(isSelectedChaptersUpdated)){ |
| 8653 | + isSelectedChaptersUpdated = matchChapLang(this.$transcriptLanguageSelect.val()); |
| 8654 | + } |
| 8655 | + // if none of the above, use the language of the player |
| 8656 | + if(!(isSelectedChaptersUpdated)){ |
| 8657 | + isSelectedChaptersUpdated = matchChapLang(this.lang); |
| 8658 | + } |
| 8659 | + // if can't match any of that, use the first track in the Chapters array |
| 8660 | + if(!(isSelectedChaptersUpdated) && (this.chapters.length >= 1)) { |
| 8661 | + this.selectedChapters = (this.chapters[0]); |
| 8662 | + } |
| 8663 | + }; |
| 8664 | + |
8620 | 8665 | })(jQuery); |
8621 | 8666 |
|
8622 | 8667 | (function ($) { |
|
8841 | 8886 | } |
8842 | 8887 | } |
8843 | 8888 | thisObj.updateTranscript(); |
| 8889 | + thisObj.setupPopups('chapters'); |
8844 | 8890 | }); |
8845 | 8891 | } |
8846 | 8892 | }; |
|
8916 | 8962 | } |
8917 | 8963 | } |
8918 | 8964 | if (typeof chapters === 'undefined') { |
8919 | | - chapters = this.chapters; |
| 8965 | + chapters = this.chapters[0] || []; |
8920 | 8966 | } |
8921 | 8967 | } |
8922 | 8968 |
|
|
0 commit comments