how to show video loop in videoview in android studio

Asked

Viewed 320 times

2

I have a video view on my android app and the background video is set that way

String uri = "android.resource://" + getPackageName() + "/" + R.raw.oceans;
 VideoView mVideoView  = (VideoView)findViewById(R.id.video_login);
 if (mVideoView != null)
 {  mVideoView.setVideoURI(Uri.parse(uri));
     mVideoView.requestFocus();
     mVideoView.start();
 }

how can I make this video be shown in loop?

1 answer

2


If the video is set inside Activity, the following code snippet works:

mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                mp.setLooping(true);
            }
        });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.