I am trying to support from API level 14 in my app, but the MediaActionSound
class is only supported from API level 16. I found out that I can use this code snippet to play the required sound:
int currentApiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
maSound = new MediaActionSound();
maSound.load(MediaActionSound.FOCUS_COMPLETE);
} else {
SoundPool soundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
int shutterSound = soundPool.load(this, R.raw.focus_complete, 0);
}
where R.raw.focus_complete
is the reference to the audio .ogg
file for that sound.
However I do not know where to download the standard .ogg
files for the sounds FOCUS_COMPLETE
and START_VIDEO_RECORDING
.
Can anyone refer me to the URL or is there an alternative way to do this?
Thanks!
Take a quick look into MediaActionSound.java. You have this :
private static final String[] SOUND_FILES = {
"/system/media/audio/ui/camera_click.ogg",
"/system/media/audio/ui/camera_focus.ogg",
"/system/media/audio/ui/VideoRecord.ogg",
"/system/media/audio/ui/VideoRecord.ogg"
};
So it seems you can use this load method :
soundPool.load("/system/media/audio/ui/VideoRecord.ogg",1);