It seems that a combination of SoundPool and music playing has an
unexpected and unwanted behavior:
When music is playing (on STREAM_MUSIC), even if its volume is down,
the sounds played by SoundPool (on STREAM_NOTIFICATION) are at 50% of
the volume than when no music is playing. This is the code I'm using:
<code>
SoundPool soundPool = new SoundPool(1,
AudioManager.STREAM_NOTIFICATION, 0);
// a few of those:
sound_id = soundPool.load(context,
context.getResources().getIdentifier(
"sound1", "raw",
"com.package.name")
,1),
// later this:
final AudioManager manager = (AudioManager)
context.getSystemService(Context.AUDIO_SERVICE);
final int volume =
manager.getStreamVolume(AudioManager.STREAM_MUSIC);
manager.setStreamVolume(AudioManager.STREAM_MUSIC, volume/2,
0);
soundPool.play(sound_id, 1f, 1f, 1, 0, 1);
new Handler().postDelayed(new Runnable() {
public void run() {
manager.setStreamVolume(AudioManager.STREAM_MUSIC,
volume, 0);
}
}, 1000);
</code>
If no music is currently playing, the sounds are at full volume, nice
and clear. If music is playing, the music gets attenuated correctly,
but the sound still only plays at 50% volume.
If anyone knows anything about this, or a workaround, I would really
love to know.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en