Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any built-in/default sounds that can be utilized in an App?

Tags:

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.

like image 354
Matt Avatar asked Jan 31 '11 20:01

Matt


People also ask

What is sounds in the app?

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.


2 Answers

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.

like image 176
Will Tate Avatar answered Sep 22 '22 11:09

Will Tate


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.

like image 32
Regis St-Gelais Avatar answered Sep 21 '22 11:09

Regis St-Gelais