title: How can I change audio track in Exo player in android
body: <p><strong>I have some video with two audio tracks and I want to change the audio tracks to another language during the video play.</strong></p>
  
  <p>I have tried everything but still got no success</p>
  
  <p>This is my code and I am using firebase storage to store the video.</p>
  
  <p>I have searched everywhere but couldn't get the sollution.</p>
  
  <p>My code is running and still didn't get any error but it's like impossible for me to change the audio tracks.</p>
  
  <pre><code>public class NewVideoActivity extends AppCompatActivity {
  
      SimpleExoPlayerView exoPlayerView;
      SimpleExoPlayer exoPlayer;
      String videoURL;
      private ImageView selectTracksButton;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_new_video);
  
          getSupportActionBar().hide();
  
          selectTracksButton = findViewById(R.id.audioTrack);
  
  
  
          videoURL = getIntent().getStringExtra("Link");
  
          exoPlayerView = (SimpleExoPlayerView) findViewById(R.id.exo_player_view);
          try {
  
  
              BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
              TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));
              exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
  
  
  
  
              Uri videoURI = Uri.parse(videoURL);
  
              DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory("exoplayer_video");
              ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
              MediaSource mediaSource = new ExtractorMediaSource(videoURI, dataSourceFactory, extractorsFactory, null, null);
  
  
  
  
              exoPlayerView.setPlayer(exoPlayer);
  
              exoPlayer.prepare(mediaSource);
              exoPlayer.setPlayWhenReady(true);
  
  
          }catch (Exception e){
              Log.e("MainAcvtivity"," exoplayer error "+ e.toString());
          }
  }
  </code></pre>