I am writing an application on android 4.0 which will play the current ringtone when I press a button.
But in the ringtone is played only one time. I need it to repeat for a few times.
My current code:
Uri notifi = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
final Ringtone r = RingtoneManager.getRingtone(c, notifi);
r.play();
Member. Upload your MP3, it converts it to OGG format and then drop this into your ringtones folder and it will now loop! Besides converting the mp3 to ogg I had to add a tag/field called “ANDROID_LOOP”, and set it to “true”. I used foobar2000 on Windows to do this.
You can have a timer regularly check if the ringtone is still playing. For example, every second:
mRingtone.play();
mTimer = new Timer();
mTimer.scheduleAtFixedRate(new TimerTask() {
public void run() {
if (!mRingtone.isPlaying()) {
mRingtone.play();
}
}
}, 1000*1, 1000*1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With