开发者

How to play ringtone once through MediaPlayer?

I can't play a ringtone once even if mediaplayer looping property is set to false. It looks like this property was overriden by the ringt开发者_JS百科one URIused. So onCompletion is never fired.

Curiously, if the URI corresponds to a notification tone, looping behaves according to setLooping. It works well here.

So is there a way to play a ringtone once?


I faced this problem before and solved it by using OnSeekCompleteListener:

mMediaPlayer.setOnSeekCompleteListener(new OnSeekCompleteListener() { public void onSeekComplete(MediaPlayer mp) { //Your stuff }});

I don't know if it's the best way to solve this, but it worked for me.

Edit: BTW, I use both listeners, oncompletionlistener AND onseekcompletelistener. Hope this helps!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜