为什么我的Soundpool静音?我的、静音、Soundpool

2023-09-05 09:40:23 作者:天涯沦落人

我安装我的的Soundpool ,并加载了完善的资源,因为这在的onCreate()

I setup my SoundPool, and load a sound resource as this in onCreate():

soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
soundId = soundPool.load(this, R.raw.edible_underwear, 1);

然后,我尝试在的onClick(),人们多在左扬声器慢,一快主要是在右扬声器里两次打这样的声音:

And then I try to play this sound twice in a onClick(), one slow mostly in left speaker, and one fast mostly in the right speaker:

soundPool.play(soundId, 0.9f, 0.1f, 0, -1, 0.7f);
soundPool.play(soundId, 0.1f, 0.1f, 0, -1, 1.5f);

没有发出任何声音。我曾经摆弄卷,优先级和价格。至今无果。我失去了一些东西明显?

No sound can be heard. I have fiddled with the volumes, priorities and rates. So far to no avail. Am I missing something obvious?

推荐答案

原来,的Soundpool 有两个错误/限制。

Turns out that SoundPool have two bugs/restrictions.

的音量为0.0,但不包括1.0F。无论1.0F和0.0是静音,所以你必须封顶的音量0.99f。 在上样到的Soundpool 没有在RAM不会导致一个异常适合被抛出,也没有一个 soundId 返回可以检查故障。所以,你一定要看看你的日志,并祈求神明的Andr​​oid,你的样品适合目标设备上。 The sound volume is from 0.0f to but not inclusive 1.0f. Both 1.0f and 0.0f are mute, so you must cap your volume at 0.99f. Loading samples into the SoundPool that do not fit in ram will not result in an exception being thrown, nor is there a soundId returned that can be checked for failure. So you must look at your logs, and pray to the Android gods that your samples fit on the target device.
 
精彩推荐