Android Media Player Play The Song X Times
I would like to play the song x times like 1,2,3 ..etc using android media player.Please let me know is there any way to do this using android api. Thanks
Solution 1:
As Wamasa said, you could use setLooping for infinite playing. For playing only a specific count time, you can add an onCompletionListener to your MediaPlayer:
intcount=0; // initialise outside listener to prevent looping
mediaPlayer.setOnCompletionListener(newOnCompletionListener(){
intmaxCount=3;
@OverridepublicvoidonCompletion(MediaPlayer mediaPlayer) {
if(count < maxCount) {
count++;
mediaPlayer.seekTo(0);
mediaPlayer.start();
}
}});
Solution 2:
If you are using a MediaPlayer class try using MediaPlayer.setLooping(true)
Post a Comment for "Android Media Player Play The Song X Times"