title: Refresh Media source in exoplayer
body: <p>I am using <code>Exo Player</code> <code>ExtractorMediaSource</code> for playing video in my android app.  I am downloading media from server and save in local database and on a specific time Alarm i play this media using <code>ConcatenatingMediaSource</code> in exo player. but first i check that all video file downloaded or not and start player with downloaded media source . and if any video is not downloaded then i want to download it in background at when it downloaded then i want to add this video in my already created playlist</p>
  
  <p><strong>This is sample code</strong> </p>
  
  <pre><code>  private void playAndUpdateVideo(ArrayList&lt;String&gt; mediaSourc) {
  
  
  
          simpleExoPlayerView.setVisibility(View.VISIBLE);
          simpleExoPlayerView.setDefaultArtwork(null);
  
          mainHandler = new Handler();
          DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
          TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
          TrackSelector trackSelector = new DefaultTrackSelector( videoTrackSelectionFactory);
          dataSourceFactory = new DefaultDataSourceFactory(context,
                  Util.getUserAgent(context, "com.cloveritservices.hype"), bandwidthMeter);
  // 2. Create a default LoadControl
          extractorsFactory = new DefaultExtractorsFactory();
          LoadControl loadControl = new DefaultLoadControl();
  
  // 3. Create the player
          player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
          player.addListener(this);
  
  //Set media controller
          simpleExoPlayerView.setUseController(false);
          simpleExoPlayerView.requestFocus();
  // Bind the player to the view.
          simpleExoPlayerView.setPlayer(player);
  
  
  
  
          MediaSource[] mediaSources = new MediaSource[mediaSourc.size()];
          for (int i=0;i&lt;mediaSourc.size();i++)
          {
  
              mediaSources[i]= buildMediaSource(Uri.parse(mediaSourc.get(i)));
  
          }
  
          MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0]
                  : new ConcatenatingMediaSource(mediaSources);
          LoopingMediaSource loopingSource = new LoopingMediaSource(mediaSource);
          player.prepare(loopingSource);
          SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
          boolean isChecked = settings.getBoolean("switch", false);
          if (!isChecked)
          player.setVolume(0f);
          else player.setVolume(2f);
          player.setPlayWhenReady(true);
  
      }
  </code></pre>
  
  <p>And here i am checking for video file that it is downloaded or not</p>
  
  <pre><code> if (CommonUtils.isExternalStorageExistAndWritable()) {
                  for (int i = 0; i &lt; videoUrl.size(); i++) {
  
  
                      if (!new File(Environment.getExternalStorageDirectory().toString() + Constants.PROFILE_VIDEO_FOLDER + CommonUtils.fileFromUrl(videoUrl.get(i))).exists() &amp;&amp; !CommonUtils.currentlyDownloading(context,CommonUtils.fileFromUrl(videoUrl.get(i)))) {
                          downloadByDownloadManager(videoUrl.get(i), CommonUtils.fileFromUrl(videoUrl.get(i)));
                          if (flag==Constants.FLAG_PLAY){downloadFlag=true;}
                      }
                  }
  
              } else {
                  Toast.makeText(getApplicationContext(), "SD Card not mounted.Please Mount SD Card", Toast.LENGTH_SHORT).show();
              }
              if (flag==Constants.FLAG_PLAY &amp;&amp; !downloadFlag)
              {
                  playAndUpdateVideo(videoUrl);
              }
  
    public void downloadByDownloadManager(String url, String fileName1) {
          downloadUrl=url;
          fileName=fileName1;
          request = new DownloadManager.Request(Uri.parse(url));
          request.setDescription("video file");
          request.setTitle(fileName);
  
          request.setNotificationVisibility(2);
          request.allowScanningByMediaScanner();
  
                      request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
                      request.setDestinationInExternalPublicDir(Constants.PROFILE_VIDEO_FOLDER, fileName);
                      DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
  
                      manager.enqueue(request);
  
  
  
  
  
  
  
          // get download service and enqueue file
  
  
  
      }
  </code></pre>
  
  <p>Please help that how to add missing video file later to playlist if it is not downloaded. </p>