Question

I want to add custom audible feedback to a button press (various click sounds encoded as *.ogg) I've done this by using the RingtoneManager to create Ringtones for each of the clicks and then .play() them in the onClick() method. This works but seems a little sluggish. This leaves me wondering if there is a better way to attach a custom sound effect to a button press. I've scanned the Button reference page and all I found was playSoundEffect() which seems to handle only system defined sounds.

thanks, hank

Was it helpful?

Solution

Use a SoundPool- they work it preloads the data into memory (so no file reads which cause sluggishness). Ringtones are definitely not what you want to be using here- those are typically much longer and not time critical (delaying a ringtone by a second or so isn't a problem, whereas delaying a button sound effect by that long is).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top