title: android - videoView does AsyncTask only once / onPostExecute never gets called
body: <p>I have 3 videos. depending on the <code>videoLong</code> I play the selected video with <code>videoView</code>.</p>
  
  <p><strong>I have 2 questions:</strong> </p>
  
  <ol>
  <li><p>The first time a video is played it works. The video stops at the correct time and <code>finish()</code> is used. BUT any time after that <code>doInBackground</code> doesnt check the other if statements. </p></li>
  <li><p>My onPostExecute never gets called.</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  if (videoLong == 0) {
      videoView
              .setVideoURI(Uri
                      .parse("http://pv...70ab1aae7633.mp4"));
      videoView.seekTo(60000 * 10);// 10 mins
      videoView.start();
      new myAsync().execute();
  } else if (videoLong == 1) {
  
      videoView
              .setVideoURI(Uri
                      .parse("http://pv....mp4"));
      videoView.seekTo(60000 * 10);// 10 mins
      videoView.start();
      new myAsync().execute();
  } else if (videoLong == 2) {
      videoView
              .setVideoURI(Uri
                      .parse("http://pv....mp4"));
      videoView.seekTo(60000 * 10);// 10 mins
  
      new myAsync().execute();
      videoView.start();
  }
  }
  
  private class myAsync extends AsyncTask&lt;Void, Integer, Void&gt; {
  
  int duration = 0;
  int current = 0;
  
  protected void onPreExecute() {
      super.onPreExecute();
      System.out.println("on pre execute");
      // alertDialog = new AlertDialog.Builder(PlayVideoActivity.this);
  }
  
  @Override
  protected Void doInBackground(Void... params) {
  
      videoView
              .setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
  
                  public void onPrepared(MediaPlayer mp) {
                      duration = videoView.getDuration();
  
                  }
              });
  
      videoView
              .setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                  public void onCompletion(MediaPlayer mp) {
                      // Do whatever u need to do here
                      System.out.println("video complete");
                      finish();
                  }
              });
  
      do {
          current = videoView.getCurrentPosition();
          // System.out.println("duration - " + duration + " current- " +
          // current);
  
          try {
  
              publishProgress((int) (current * 100 / duration));
  
              // System.out.println("time: " + current);
              if (current &gt;= 610100 &amp;&amp; videoLong == 0) {
                  System.out.println("video 1 done");
                  videoView.stopPlayback();
  
                  videoView = null;
              }
              if (current &gt;= 610200 &amp;&amp; videoLong == 1) {
                  System.out.println("video 2 done");
                  videoView.stopPlayback();
                  finish();
              }
              if (current &gt;= 610200 &amp;&amp; videoLong == 2) {
                  System.out.println("video 3 done");
                  videoView.stopPlayback();
                  finish();
              }
              if (mProgressBar.getProgress() &gt;= 100) {
                  // System.out.println("error100");
              }
  
          } catch (Exception e) {
              // e.printStackTrace();
          }
      } while (mProgressBar.getProgress() &lt;= 100);
  
      return null;
  }
  
  @Override
  protected void onProgressUpdate(Integer... values) {
      super.onProgressUpdate(values);
      // System.out.println("values: " + values[0]);
      mProgressBar.setProgress(values[0]);
  }
  
  @Override
  protected void onPostExecute(Void result) {
      System.out.println("on POST execute");
  
  
  }
  
  }
  
  @Override
   public void onBackPressed() {
  if (videoView != null)
      videoView.stopPlayback();
  videoView = null;
  System.out.println("back button pressed. stop playback");
  super.onBackPressed();
  }
  </code></pre></li>
  </ol>
  
  <p>Thanks for looking!</p>