Reputation: 109
i want to check weather the app streaming (live streaming) is buffering or stopped. Is their any way to listen the error while playing the video. i had tried onErrorListner but is detects on if any error occurs during the first time
Upvotes: 1
Views: 1532
Reputation: 1635
I would answer your Question in two parts
- I want to check weather the app streaming (live streaming) is buffering or stopped.
You can use VideoView.setOnInfoListener (MediaPlayer.OnInfoListener l) for receiving following Events in your overrided onInfo(MediaPlayer mp, int what, int extra) method .
MEDIA_INFO_BUFFERING_START and MEDIA_INFO_BUFFERING_END for "int what" parameter of onInfo()
For more events , you can take a look here , http://developer.android.com/reference/android/media/MediaPlayer.OnInfoListener.html#onInfo%28android.media.MediaPlayer,%20int,%20int%29
Now 2nd part,
Is their any way to listen the error while playing the video. i had tried onErrorListner but is detects on if any error occurs during the first time
If you take a look at the State Diagram for Media Player here
You would find that After Media Player Goes to "Error State" it won't move to any other state , This state can occur for any of the following reasons:
Under all these error conditions, the internal player engine invokes a user supplied OnErrorListener.onError() method
Important points to notice from this situation and recovery process can be enumerated as below :
You can get more information about all state and Proper handling of media player from this link http://developer.android.com/reference/android/media/MediaPlayer.html
Enjoy !
Upvotes: 3