I got a simple dialog box with a VideoView
in it and I want to play the video in a loop.
I'm currently using a quick fix
//Video Loop
vv.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
vv.start();
}
});
but I would like to know if there is a better way?
Edit
I'm adding more code because I don't know how I can get access to the MediaPlayer object form the VideoView
:
String path = defaultPath+currentVideoRessource;
if (path == null || path.length() == 0) {
Log.e("extra","File URL/path is empty");
} else {
// If the path has not changed, just start the media player
if (!path.equals(current) && mVideoView != null) {
Uri pathURI = Uri.parse(defaultPath+currentVideoRessource);
mVideoView.setVideoURI(pathURI);
}
current = path;
mVideoView.setOnCompletionListener(new MyOnCompletionListener(this));
//Video Loop
// mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
// public void onCompletion(MediaPlayer mp) {
// mVideoView.start(); //need to make transition seamless.
// }
// });
mVideoView.start();
mVideoView.requestFocus();
I'm currently looking into using directly MediaPlayer
and a SurfaceView
bu I would like to know if there is a way with VideoView
directly
question from:
https://stackoverflow.com/questions/5569631/android-video-view-how-to-play-a-video-on-a-loop 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…