How to detect if VideoView is playing video or Buffering?

User7723337 picture User7723337 · Apr 11, 2013 · Viewed 16.9k times · Source

How to detect if VideoView is playing video or Buffering?
I want to display a pop-up saying video is buffering.

In android API level 17 there is a call back setOnInfoListener that can provide me this information but i am using API level 15 (android ICS).

I have also seen this question "Detect if a VideoVIew is buffering" but the suggested solution is for MediaPlayer and not for VideoView.

SO how can I detect if VideoView is buffering? is it a good solution to run a thread to check the current seek/progress level and depending on that decide if video is playing or buffering.

UPDATE

It is not like i just need to check if video is playing or buffering at the start of the video only, i want to check it through out video paying.

Answer

Lucifer picture Lucifer · Apr 11, 2013

To check if VideoView is playing is not you can use its isPlaying() method,

if ( videoView.isPlaying() )
{
     // Video is playing
}
else
{
     // Video is either stopped or buffering
}

To check if VideoView is completed use following,

videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() 
{
    @Override
    public void onCompletion(MediaPlayer mp) 
    {
             // Video Playing is completed
    }
});