function set(index) {
	    var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
	    var tracks = captions.getTracks.call(this); // Disable captions if setting to -1

	    if (index === -1) {
	      captions.toggle.call(this, false, passive);
	      return;
	    }

	    if (!is$1.number(index)) {
	      this.debug.warn('Invalid caption argument', index);
	      return;
	    }

	    if (!(index in tracks)) {
	      this.debug.warn('Track not found', index);
	      return;
	    }

	    if (this.captions.currentTrack !== index) {
	      this.captions.currentTrack = index;
	      var track = tracks[index];

	      var _ref = track || {},
	          language = _ref.language; // Store reference to node for invalidation on remove


	      this.captions.currentTrackNode = track; // Update settings menu

	      controls.updateSetting.call(this, 'captions'); // When passive, don't override user preferences

	      if (!passive) {
	        this.captions.language = language;
	        this.storage.set({
	          language: language
	        });
	      } // Handle Vimeo captions


	      if (this.isVimeo) {
	        this.embed.enableTextTrack(language);
	      } // Trigger event


	      triggerEvent.call(this, this.media, 'languagechange');
	    } // Show captions


	    captions.toggle.call(this, true, passive);

	    if (this.isHTML5 && this.isVideo) {
	      // If we change the active track while a cue is already displayed we need to update it
	      captions.updateCues.call(this);
	    }
	  }
function set(index) {
	    var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
	    var tracks = captions.getTracks.call(this); 

	    if (index === -1) {
	      captions.toggle.call(this, false, passive);
	      return;
	    }

	    if (!is$1.number(index)) {
	      this.debug.warn('Invalid caption argument', index);
	      return;
	    }

	    if (!(index in tracks)) {
	      this.debug.warn('Track not found', index);
	      return;
	    }

	    if (this.captions.currentTrack !== index) {
	      this.captions.currentTrack = index;
	      var track = tracks[index];

	      var _ref = track || {},
	          language = _ref.language; 


	      this.captions.currentTrackNode = track; 

	      controls.updateSetting.call(this, 'captions'); 

	      if (!passive) {
	        this.captions.language = language;
	        this.storage.set({
	          language: language
	        });
	      } 


	      if (this.isVimeo) {
	        this.embed.enableTextTrack(language);
	      } 


	      triggerEvent.call(this, this.media, 'languagechange');
	    } 


	    captions.toggle.call(this, true, passive);

	    if (this.isHTML5 && this.isVideo) {
	      
	      captions.updateCues.call(this);
	    }
	  }
function set ( index ) { var passive = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : true ; var tracks = captions . getTracks . call ( this ) ; // Disable captions if setting to -1 if ( index === - 1 ) { captions . toggle . call ( this , false , passive ) ; return ; } if ( ! is$1 . number ( index ) ) { this . debug . warn ( 'Invalid caption argument' , index ) ; return ; } if ( ! ( index in tracks ) ) { this . debug . warn ( 'Track not found' , index ) ; return ; } if ( this . captions . currentTrack !== index ) { this . captions . currentTrack = index ; var track = tracks [ index ] ; var _ref = track || { } , language = _ref . language ; // Store reference to node for invalidation on remove this . captions . currentTrackNode = track ; // Update settings menu controls . updateSetting . call ( this , 'captions' ) ; // When passive, don't override user preferences if ( ! passive ) { this . captions . language = language ; this . storage . set ( { language : language } ) ; } // Handle Vimeo captions if ( this . isVimeo ) { this . embed . enableTextTrack ( language ) ; } // Trigger event triggerEvent . call ( this , this . media , 'languagechange' ) ; } // Show captions captions . toggle . call ( this , true , passive ) ; if ( this . isHTML5 && this . isVideo ) { // If we change the active track while a cue is already displayed we need to update it captions . updateCues . call ( this ) ; } }
Set captions by track index Used internally for the currentTrack setter with the passive option forced to false
Set captions by track index Used internally for the currentTrack setter with the passive option forced to false