@@ -1117,9 +1117,7 @@ var AblePlayerInstances = [];
11171117
11181118 this . initSignLanguage ( ) ;
11191119
1120- // thisObj.initializing = true;
1121- this . initPlayer ( ) . then ( function ( ) { // initPlayer success
1122- // thisObj.initializing = false;
1120+ this . initPlayer ( ) . then ( function ( ) {
11231121
11241122 thisObj . setupTracks ( ) . then ( function ( ) {
11251123
@@ -1192,7 +1190,6 @@ var AblePlayerInstances = [];
11921190
11931191 var thisObj = this ;
11941192 var playerPromise ;
1195-
11961193 // First run player specific initialization.
11971194 if ( this . player === 'html5' ) {
11981195 playerPromise = this . initHtml5Player ( ) ;
@@ -1203,7 +1200,6 @@ var AblePlayerInstances = [];
12031200 else if ( this . player === 'vimeo' ) {
12041201 playerPromise = this . initVimeoPlayer ( ) ;
12051202 }
1206-
12071203 // After player specific initialization is done, run remaining general initialization.
12081204 var deferred = new $ . Deferred ( ) ;
12091205 var promise = deferred . promise ( ) ;
@@ -1268,7 +1264,6 @@ var AblePlayerInstances = [];
12681264 var captions , i ;
12691265
12701266 captions = this . captions ;
1271-
12721267 if ( captions . length > 0 ) {
12731268 for ( i = 0 ; i < captions . length ; i ++ ) {
12741269 if ( captions [ i ] . def === true ) {
@@ -1300,6 +1295,38 @@ var AblePlayerInstances = [];
13001295 // sync all other tracks to this same languge
13011296 this . syncTrackLanguages ( 'init' , this . captionLang ) ;
13021297 }
1298+ if ( this . usingVimeoCaptions && this . prefCaptions == 1 ) {
1299+ // initialize Vimeo captions to the default language
1300+ this . vimeoPlayer . enableTextTrack ( this . captionLang ) . then ( function ( track ) {
1301+ // track.language = the iso code for the language
1302+ // track.kind = 'captions' or 'subtitles'
1303+ // track.label = the human-readable label
1304+ } ) . catch ( function ( error ) {
1305+ switch ( error . name ) {
1306+ case 'InvalidTrackLanguageError' :
1307+ // no track was available with the specified language
1308+ console . log ( 'No ' + track . kind + ' track is available in the specified language (' + track . label + ')' ) ;
1309+ break ;
1310+ case 'InvalidTrackError' :
1311+ // no track was available with the specified language and kind
1312+ console . log ( 'No ' + track . kind + ' track is available in the specified language (' + track . label + ')' ) ;
1313+ break ;
1314+ default :
1315+ // some other error occurred
1316+ console . log ( 'Error loading ' + track . label + ' ' + track . kind + ' track' ) ;
1317+ break ;
1318+ }
1319+ } ) ;
1320+ }
1321+ else {
1322+ // disable Vimeo captions.
1323+ // captions are either provided locally, or user has them turned off.
1324+ this . vimeoPlayer . disableTextTrack ( ) . then ( function ( ) {
1325+ // Vimeo captions disabled
1326+ } ) . catch ( function ( error ) {
1327+ console . log ( 'Error disabling Vimeo text track: ' , error ) ;
1328+ } ) ;
1329+ }
13031330 }
13041331 } ;
13051332
@@ -3457,7 +3484,7 @@ var AblePlayerInstances = [];
34573484 'tabindex' : '-1' ,
34583485 'lang' : track . language
34593486 } ) ;
3460- if ( track . def ) {
3487+ if ( track . def && this . prefCaptions == 1 ) {
34613488 $menuItem . attr ( 'aria-checked' , 'true' ) ;
34623489 hasDefault = true ;
34633490 }
@@ -8016,7 +8043,7 @@ if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml
80168043 }
80178044 }
80188045 else if ( this . player === 'vimeo' ) {
8019- // since this takes longer to determine, it was set previous in initVimeoPlayer()
8046+ // since this takes longer to determine, it was set previously in initVimeoPlayer()
80208047 return this . vimeoSupportsPlaybackRateChange ;
80218048 }
80228049 } ;
@@ -9732,12 +9759,14 @@ if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml
97329759
97339760 // Returns the function used when the "Captions Off" button is clicked in the captions tooltip.
97349761 AblePlayer . prototype . getCaptionOffFunction = function ( ) {
9735-
97369762 var thisObj = this ;
97379763 return function ( ) {
97389764 if ( thisObj . player == 'youtube' ) {
97399765 thisObj . youTubePlayer . unloadModule ( thisObj . ytCaptionModule ) ;
97409766 }
9767+ else if ( thisObj . usingVimeoCaptions ) {
9768+ thisObj . vimeoPlayer . disableTextTrack ( ) ;
9769+ }
97419770 thisObj . captionsOn = false ;
97429771 thisObj . currentCaption = - 1 ;
97439772 // stopgap to prevent spacebar in Firefox from reopening popup
@@ -15459,8 +15488,6 @@ if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml
1545915488 deferred = new $ . Deferred ( ) ;
1546015489 promise = deferred . promise ( ) ;
1546115490
15462- deferred . resolve ( ) ;
15463-
1546415491 containerId = this . mediaId + '_vimeo' ;
1546515492
1546615493 // add container to which Vimeo player iframe will be appended
@@ -15478,14 +15505,13 @@ if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml
1547815505
1547915506 // Notes re. Vimeo Embed Options:
1548015507 // If a video is owned by a user with a paid Plus, PRO, or Business account,
15481- // setting the "background" option to "true" will hide the default controls.
15482- // It has no effect on videos owned by a free basic account owner (their controls cannot be hidden).
15483- // Also, setting "background" to "true" has a couple of side effects:
15484- // In addition to hiding the controls, it also autoplays and loops the video.
15485- // If the player is initialized with options to set both "autoplay" and "loop" to "false",
15486- // this does not override the "background" setting.
15487- // Passing this.autoplay and this.loop anyway, just in case it works someday
15488- // Meanwhile, workaround is to setup an event listener to immediately pause after video autoplays
15508+ // setting the "controls" option to "false" will hide the default controls, without hiding captions.
15509+ // This is a new option from Vimeo; previously used "background:true" to hide the controller,
15510+ // but that had unwanted side effects:
15511+ // - In addition to hiding the controls, it also hides captions
15512+ // - It automatically autoplays (initializing the player with autoplay:false does not override this)
15513+ // - It automatically loops (but this can be overridden by initializing the player with loop:false)
15514+ // - It automatically sets volume to 0 (not sure if this can be overridden, since no longer using the background option)
1548915515
1549015516 if ( this . autoplay && this . okToPlay ) {
1549115517 autoplay = 'true' ;
@@ -15507,12 +15533,11 @@ if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml
1550715533 this . vimeoWidth = null ;
1550815534 this . vimeoHeight = null ;
1550915535 }
15536+
1551015537 options = {
15511- id : vimeoId ,
15512- width : this . vimeoWidth ,
15513- background : true ,
15514- autoplay : this . autoplay ,
15515- loop : this . loop
15538+ id : vimeoId ,
15539+ width : this . vimeoWidth ,
15540+ controls : false
1551615541 } ;
1551715542
1551815543 this . vimeoPlayer = new Vimeo . Player ( containerId , options ) ;
@@ -15787,7 +15812,7 @@ if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml
1578715812 isDefaultTrack = false ;
1578815813 }
1578915814 thisObj . tracks . push ( {
15790- 'kind' : tracks [ i ] [ 'kind' ] ,
15815+ 'kind' : tracks [ i ] [ 'kind' ] ,
1579115816 'language' : tracks [ i ] [ 'language' ] ,
1579215817 'label' : tracks [ i ] [ 'label' ] ,
1579315818 'def' : isDefaultTrack
@@ -15799,7 +15824,7 @@ if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml
1579915824 deferred . resolve ( ) ;
1580015825 }
1580115826 else {
15802- thisObj . hasCaptions = false ;
15827+ thisObj . hasCaptions = false ;
1580315828 thisObj . usingVimeoCaptions = false ;
1580415829 deferred . resolve ( ) ;
1580515830 }
@@ -15813,7 +15838,6 @@ if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml
1581315838 // NOTE: This function is modeled after same function in youtube.js
1581415839 // in case useful for Vimeo, but is not currently used
1581515840
15816-
1581715841 // This function is called when YouTube onApiChange event fires
1581815842 // to indicate that the player has loaded (or unloaded) a module with exposed API methods
1581915843 // it isn't fired until the video starts playing
0 commit comments