|
134 | 134 | } |
135 | 135 |
|
136 | 136 | if ($(media).data('youtube-id') !== undefined && $(media).data('youtube-id') !== "") { |
137 | | - this.youtubeId = $(media).data('youtube-id'); |
| 137 | + this.youTubeId = $(media).data('youtube-id'); |
138 | 138 | } |
139 | 139 |
|
140 | 140 | if ($(media).data('youtube-desc-id') !== undefined && $(media).data('youtube-desc-id') !== "") { |
|
844 | 844 | // Determine which player to use, if any |
845 | 845 | // return 'html5', 'jw' or null |
846 | 846 | var i, sourceType, $newItem; |
847 | | - if (this.youtubeId) { |
| 847 | + if (this.youTubeId) { |
848 | 848 | if (this.mediaType !== 'video') { |
849 | 849 | return null; |
850 | 850 | } |
|
4171 | 4171 | youTubeId = this.youTubeDescId; |
4172 | 4172 | } |
4173 | 4173 | else { |
4174 | | - youTubeId = this.youtubeId; |
| 4174 | + youTubeId = this.youTubeId; |
4175 | 4175 | } |
4176 | 4176 | this.activeYouTubeId = youTubeId; |
4177 | 4177 |
|
|
4341 | 4341 | youTubeId = this.youTubeDescId; |
4342 | 4342 | } |
4343 | 4343 | else { |
4344 | | - youTubeId = this.youtubeId; |
| 4344 | + youTubeId = this.youTubeId; |
4345 | 4345 | } |
4346 | 4346 |
|
4347 | 4347 | // Wait until Google Client API is loaded |
|
4369 | 4369 | }; |
4370 | 4370 |
|
4371 | 4371 | AblePlayer.prototype.getYouTubeCaptionData = function (youTubeId) { |
4372 | | - |
4373 | 4372 | // get data via YouTube Data API, and push data to this.ytCaptions |
4374 | 4373 |
|
4375 | 4374 | var deferred = new $.Deferred(); |
|
4450 | 4449 | }; |
4451 | 4450 |
|
4452 | 4451 | AblePlayer.prototype.initYouTubeCaptionModule = function () { |
4453 | | - |
4454 | 4452 | // This function is called when YouTube onApiChange event fires |
4455 | 4453 | // to indicate that the player has loaded (or unloaded) a module with exposed API methods |
4456 | 4454 | // it isn't fired until the video starts playing |
|
5587 | 5585 | }; |
5588 | 5586 |
|
5589 | 5587 | AblePlayer.prototype.swapDescription = function() { |
5590 | | - |
5591 | 5588 | // swap described and non-described source media, depending on which is playing |
5592 | 5589 | // this function is only called in two circumstances: |
5593 | 5590 | // 1. Swapping to described version when initializing player (based on user prefs & availability) |
|
5613 | 5610 | if (this.player === 'html5') { |
5614 | 5611 |
|
5615 | 5612 | if (this.usingAudioDescription()) { |
5616 | | - |
5617 | 5613 | // the described version is currently playing. Swap to non-described |
5618 | 5614 | for (i=0; i < this.$sources.length; i++) { |
5619 | 5615 | // for all <source> elements, replace src with data-orig-src |
|
5632 | 5628 | this.swappingSrc = true; |
5633 | 5629 | } |
5634 | 5630 | else { |
5635 | | - |
5636 | 5631 | // the non-described version is currently playing. Swap to described. |
5637 | 5632 | for (i=0; i < this.$sources.length; i++) { |
5638 | 5633 | // for all <source> elements, replace src with data-desc-src (if one exists) |
|
5663 | 5658 | this.jwPlayer.load({file: newSource}); |
5664 | 5659 | } |
5665 | 5660 | } |
| 5661 | + else if (this.player === 'youtube') { |
| 5662 | + |
| 5663 | + if (this.usingAudioDescription()) { |
| 5664 | + // the described version is currently playing. Swap to non-described |
| 5665 | + this.activeYouTubeId = this.youTubeId; |
| 5666 | + this.showAlert(this.tt.alertNonDescribedVersion); |
| 5667 | + } |
| 5668 | + else { |
| 5669 | + // the non-described version is currently playing. Swap to described. |
| 5670 | + this.activeYouTubeId = this.youTubeDescId; |
| 5671 | + this.showAlert(this.tt.alertDescribedVersion); |
| 5672 | + } |
| 5673 | + if (typeof this.youTubePlayer !== 'undefined') { |
| 5674 | + if (this.playing) { |
| 5675 | + // loadVideoById() loads and immediately plays the new video at swapTime |
| 5676 | + this.youTubePlayer.loadVideoById(this.activeYouTubeId,this.swapTime); |
| 5677 | + } |
| 5678 | + else { |
| 5679 | + // cueVideoById() loads the new video and seeks to swapTime, but does not play |
| 5680 | + this.youTubePlayer.cueVideoById(this.activeYouTubeId,this.swapTime); |
| 5681 | + } |
| 5682 | + } |
| 5683 | + } |
5666 | 5684 | }; |
5667 | 5685 |
|
5668 | 5686 | AblePlayer.prototype.showDescription = function(now) { |
|
6939 | 6957 |
|
6940 | 6958 | (function ($) { |
6941 | 6959 | AblePlayer.prototype.updateCaption = function (time) { |
6942 | | - if (!this.usingYouTubeCaptions) { |
| 6960 | + if (!this.usingYouTubeCaptions && (typeof this.$captionDiv !== 'undefined')) { |
6943 | 6961 | if (this.captionsOn) { |
6944 | 6962 | this.$captionDiv.show(); |
6945 | 6963 | this.showCaptions(time || this.getElapsed()); |
|
0 commit comments