I'm trying to add just a few simple sounds (beep, boop, click, etc) to an Android app, so I was just wondering if there are any built-in sounds in the Android OS or SDK that could be utilized. If so, how might they be accessed? My only guesses have been somewhere in the mediastore or soundpool classes... I'm pretty new, so any help/tips you could offer would be greatly appreciated. Thank you.
Sounds is an iPhone and Android app that lets you discover music and also seamlessly share your favorite songs to multiple social networks, including Instagram, Snapchat, Facebook Messenger and Tinder. “Unlike other apps, we only use the cover art when you share a song,” co-founder and CEO Rhai Goburdhun told me.
You can play the default ringtone with:
MediaPlayer player = MediaPlayer.create(this, Settings.System.DEFAULT_RINGTONE_URI); player.start();
You can replace DEFAULT_RINGTONE_URI
with DEFAULT_NOTIFICATION_URI
or DEFAULT_ALARM_ALERT_URI
for the various other default sounds.
Here is one way to generate a beep.
Create a raw resouce file with extention .rtttl and put "c5:d=4,o=5,b=250:c5" in it (no quotes)
Then add this code:
protected MediaPlayer _mediaPlayer; public void playFromResource(int resId) { if (_mediaPlayer != null) { // _mediaPlayer.stop(); freeze on some emulator snapshot // _mediaPlayer.release(); _mediaPlayer.reset(); // reset stops and release on any state of the player } _mediaPlayer = MediaPlayer.create(this, resId); _mediaPlayer.start(); }
Then call playFromResource and pass it the resource id if your raw rtttl resource.
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