title: Prevent Exoplayer re-buffering for .mp4 videos
body: <p>Within this project there is a 'SimpleExoPlayer' and the version of the player is 'exoplayer:r2.5.3'. After running the app 'SimpleExoPlayer' buffering the content of the video and playing smoothly. But the user set the 'SeekBar' to previous position, the 'SimpleExoPlayer' re-buffering to displaying the video. It is time consuming process for large file size of '.mp4' videos. Helping for solve this issue is kindly appreciated. </p>
  
  <p>below is my code.</p>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="match_parent"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:orientation="vertical"
      android:padding="10dp"&gt;
  
      &lt;ScrollView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fillViewport="true"&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"&gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="300dp"
                  android:orientation="vertical"&gt;
  
                  &lt;com.google.android.exoplayer2.ui.SimpleExoPlayerView
                      android:id="@+id/simple_expo_player"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"&gt;
  
  
                  &lt;/com.google.android.exoplayer2.ui.SimpleExoPlayerView&gt;
  
  
              &lt;/LinearLayout&gt;
  
  
          &lt;/LinearLayout&gt;
  
      &lt;/ScrollView&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private SimpleExoPlayerView simpleExoPlayerView;
  
      SimpleExoPlayer player;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          initUi();
      }
  
      public void initUi(){
  
  // 1. Create a default TrackSelector
          BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
          TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
          TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
  
  // 2. Create the player
  
          player = ExoPlayerFactory.newSimpleInstance(getApplicationContext(), trackSelector);
  
  
  // 3. Produces DataSource instances through which media data is loaded.
          DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(), Util.getUserAgent(getApplicationContext(), "com.a3iteam.exoplayertest"));
  
  // 4. Produces Extractor instances for parsing the media data.
          ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
  
  // 5. This is the MediaSource representing the media to be played.
  
          MediaSource videoSource = new ExtractorMediaSource(Uri.parse("https://www.w3schools.com/html/mov_bbb.mp4"),dataSourceFactory, extractorsFactory, null, null);
  
  
  // 6. Prepare the player with the source.
  
          simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.simple_expo_player);
  
          simpleExoPlayerView.setPlayer(player);
  
  
      }
  
  
  }
  </code></pre>