I am developing a Live video streaming application for android. For video playing I am just passing the URL for VideoView. Most of the times video is playing well. But sometimes when server is down,I found VideoView is not prepared for playing the video and its continuously showing black screen.
I want to implement a tracker for VideoView. Suppose if VideoView doesn’t show video for 10 seconds,a Dialog box will appear with message, and when I click on the OK button, Activity will finish.
Anybody suggest some ideas or code to implement my idea?
You should be using the
setOnPreparedListener()to check on the preparedness of yourVideoView.You can look out for errors using :
setOnErrorListener().And you can keep an eye on the buffering percentage using :
getBufferPercentage(). If the media source has not ended playback, it could mean you have a buffering problem, if your buffering percentage has stagnated at a certain level.