我有一个显示流媒体rtsp的应用程序。我该如何检查它是否结束? 缓冲空了?还有什么吗?
答案 0 :(得分:0)
答案 1 :(得分:0)
private VideoView vidView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vidView = (VideoView) findViewById(R.id.myVideo);
uri = Uri.parse(RTSP_URL);
vidView.setMediaController(new MediaController(this));
vidView.setVideoURI(uri);
vidView.requestFocus();
vidView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Runnable runnable = new Runnable() {
@Override
public void run() {
vidView.start();
}
};
runOnUiThread(runnable);
}
});
vidView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
Log.d("Error ", what + " " + extra);
return false;
}
});
vidView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
Log.d(getClass().getName(), " callback COMPLETE HERE ");
}
});
}