开发者

Android Media Player - Getting the number of times a video played in SetLooping

I am Playing the video in loop using set Looping(true)开发者_如何学运维 option and i will stop the media player after a particular event happened. It is working fine. But i want to know the number of times that my video got played in the loop.


MediaPlayer doesn't provide that information, you need to make it loop yourself and count how many times it has restarted. To do this, something in your app will need to extend OnCompletionListener and do something like

int count = 0;
public void onCompletion(MediaPlayer mediaPlayer) {
    count++;
    mediaplayer.seekTo(0);
    mediaplayer.start();
}

And you need to set mediaPlayer.setLooping(false)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜