11( function ( $ ) {
2+
23 AblePlayer . prototype . injectPlayerCode = function ( ) {
34 // create and inject surrounding HTML structure
45 // If IOS:
2728 this . injectOffscreenHeading ( ) ;
2829
2930 // youtube adds its own big play button
30- if ( this . mediaType === 'video' && this . player !== 'youtube' ) {
31- this . injectBigPlayButton ( ) ;
31+ // if (this.mediaType === 'video' && this.player !== 'youtube') {
32+ if ( this . mediaType === 'video' ) {
33+ if ( this . player !== 'youtube' ) {
34+ this . injectBigPlayButton ( ) ;
35+ }
3236
3337 // add container that captions or description will be appended to
3438 // Note: new Jquery object must be assigned _after_ wrap, hence the temp vidcapContainer variable
3741 } ) ;
3842 this . $vidcapContainer = this . $mediaContainer . wrap ( vidcapContainer ) . parent ( ) ;
3943 }
40-
44+
4145 this . injectPlayerControlArea ( ) ;
4246 this . injectTextDescriptionArea ( ) ;
4347
390394 radioName , radioId , trackButton , trackLabel ;
391395
392396 popups = [ ] ;
393- if ( this . captions . length > 0 ) {
394- popups . push ( 'captions' ) ;
397+
398+ if ( typeof this . ytCaptions !== 'undefined' ) {
399+ // special call to this function for setting up a YouTube caption popup
400+ if ( this . ytCaptions . length ) {
401+ popups . push ( 'ytCaptions' ) ;
402+ }
403+ else {
404+ return false ;
405+ }
395406 }
396- if ( this . chapters . length > 0 ) {
397- popups . push ( 'chapters' ) ;
407+ else {
408+ if ( this . captions . length > 0 ) {
409+ popups . push ( 'captions' ) ;
410+ }
411+ if ( this . chapters . length > 0 ) {
412+ popups . push ( 'chapters' ) ;
413+ }
398414 }
399415 if ( popups . length > 0 ) {
400416 thisObj = this ;
409425 this . chaptersPopup = this . createPopup ( 'chapters' ) ;
410426 tracks = this . chapters ;
411427 }
428+ else if ( popup == 'ytCaptions' ) {
429+ this . captionsPopup = this . createPopup ( 'captions' ) ;
430+ tracks = this . ytCaptions ;
431+ }
412432 var trackList = $ ( '<ul></ul>' ) ;
413433 radioName = this . mediaId + '-' + popup + '-choice' ;
414434 for ( j in tracks ) {
431451 if ( track . language !== 'undefined' ) {
432452 trackButton . attr ( 'lang' , track . language ) ;
433453 }
434- if ( popup == 'captions' ) {
454+ if ( popup == 'captions' || popup == 'ytCaptions' ) {
435455 trackLabel . text ( track . label || track . language ) ;
436456 trackButton . click ( this . getCaptionClickFunction ( track ) ) ;
437- //trackButton.click(this.handleCaptionRadioSelect(track));
438- // trackButton.keypress(function() { alert('hey!');});
439457 }
440458 else if ( popup == 'chapters' ) {
441459 trackLabel . text ( this . flattenCueForCaption ( track ) + ' - ' + this . formatSecondsAsColonTime ( track . start ) ) ;
452470 trackItem . append ( trackButton , trackLabel ) ;
453471 trackList . append ( trackItem ) ;
454472 }
455- if ( popup == 'captions' ) {
473+ if ( popup == 'captions' || popup == 'ytCaptions' ) {
456474 // add a captions off button
457475 radioId = this . mediaId + '-captions-off' ;
458476 trackItem = $ ( '<li></li>' ) ;
473491 // check the first button
474492 trackList . find ( 'input' ) . first ( ) . attr ( 'checked' , 'checked' ) ;
475493 }
476- if ( popup == 'captions' ) {
494+ if ( popup == 'captions' || popup == 'ytCaptions' ) {
477495 this . captionsPopup . append ( trackList ) ;
478496 }
479497 else if ( popup == 'chapters' ) {
626644 }
627645 else if ( this . controls [ i ] === 'captions' ) {
628646 if ( this . captions . length > 1 ) {
647+ console . log ( 'There is more than one caption' ) ;
629648 // caption button launches a Captions popup menu
630649 label = this . tt . captions ;
631650 }
632651 else {
652+ console . log ( 'There is only one caption' ) ;
633653 // there is only one caption track
634654 // therefore caption button is a toggle
635655 if ( this . captionsOn ) {
777797 } ;
778798
779799 AblePlayer . prototype . addControls = function ( ) {
800+
780801 // determine which controls to show based on several factors:
781802 // mediaType (audio vs video)
782803 // availability of tracks (e.g., for closed captions & audio description)
798819 var controlLayout = this . calculateControlLayout ( ) ;
799820
800821 var sectionByOrder = { 0 : 'ul' , 1 :'ur' , 2 :'bl' , 3 :'br' } ;
801-
822+
802823 // add an empty div to serve as a tooltip
803824 tooltipId = this . mediaId + '-tooltip' ;
804825 tooltipDiv = $ ( '<div>' , {
11421163 this . media . load ( ) ;
11431164 }
11441165 else if ( this . player === 'jw' ) {
1145- console . log ( 'this.jwPlayer.load' ) ;
11461166 this . jwPlayer . load ( { file : jwSource } ) ;
11471167 }
11481168 else if ( this . player === 'youtube' ) {
@@ -1153,6 +1173,9 @@ console.log('this.jwPlayer.load');
11531173 } ;
11541174
11551175 AblePlayer . prototype . getButtonTitle = function ( control ) {
1176+
1177+ var captionsCount ;
1178+
11561179 if ( control === 'playpause' ) {
11571180 return this . tt . play ;
11581181 }
@@ -1172,11 +1195,22 @@ console.log('this.jwPlayer.load');
11721195 return this . tt . forward ;
11731196 }
11741197 else if ( control === 'captions' ) {
1175- if ( this . captionsOn ) {
1176- return this . tt . hideCaptions ;
1198+ if ( this . usingYouTubeCaptions ) {
1199+ captionsCount = this . ytCaptions . length ;
1200+ }
1201+ else {
1202+ captionsCount = this . captions . length ;
1203+ }
1204+ if ( captionsCount > 1 ) {
1205+ return this . tt . captions ;
11771206 }
11781207 else {
1179- return this . tt . showCaptions ;
1208+ if ( this . captionsOn ) {
1209+ return this . tt . hideCaptions ;
1210+ }
1211+ else {
1212+ return this . tt . showCaptions ;
1213+ }
11801214 }
11811215 }
11821216 else if ( control === 'descriptions' ) {
0 commit comments