为什么我的 SoundPool 静音?
我设置了 SoundPool
,并在 onCreate()
中加载声音资源:
soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
soundId = soundPool.load(this, R.raw.edible_underwear, 1);
然后我尝试在 onClick()
中播放此声音两次code>,一慢主要在左扬声器,一快主要在右扬声器:
soundPool.play(soundId, 0.9f, 0.1f, 0, -1, 0.7f);
soundPool.play(soundId, 0.1f, 0.1f, 0, -1, 1.5f);
听不到声音。我摆弄了数量、优先级和费率。至今无济于事。我错过了一些明显的东西吗?
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);
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,
SoundPool
有两个错误/限制。soundId
。因此,您必须查看日志,并向 Android 之神祈祷您的示例适合目标设备。Turns out that
SoundPool
have two bugs/restrictions.SoundPool
that do not fit in ram will not result in an exception being thrown, nor is there asoundId
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.