Christian Orth
Christian Orth

Reputation: 4653

VideoView/MediaPlayer stop on last frame

is it possible to stop a video on its last frame? I am using the code below:

VideoView video = (VideoView) findViewById(R.id.menu_video);

final String uriPath = "android.resource://com.my.project/raw/myvideo"

Uri uri = Uri.parse(uriPath);
video.setVideoURI(uri);

I've tried to load the video from the sd card, to pause it in a completion listener and to find out something in the web... Now I am thinking about hiding it and using an ImageView as "fake" last Frame. Does anyone know a better solution?

Upvotes: 5

Views: 3889

Answers (2)

Christian Orth
Christian Orth

Reputation: 4653

To get the last frame of a video you can skip to its end by using:

video.seekTo(video.getDuration());

Upvotes: 2

Dawid Sajdak
Dawid Sajdak

Reputation: 3084

firstly you must register listner like this:

mMediaPlayer.setOnCompletionListener(this);

second:

public void onCompletion(MediaPlayer arg0) {
    Log.d(TAG, "onCompletion called");
    this.finish();
}

and you should implement OnCompletionListener in your class

Upvotes: 0

Related Questions