为什么我的Soundpool静音? [英] Why is my SoundPool mute?

查看:252
本文介绍了为什么我的Soundpool静音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装我的的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.

  1. 的音量为0.0,但不包括1.0F。无论1.0F和0.0是静音,所以你必须封顶的音量0.99f。
  2. 在上样到的Soundpool 没有在RAM不会导致一个异常适合被抛出,也没有一个 soundId 返回可以检查故障。所以,你一定要看看你的日志,并祈求神明的Andr​​oid,你的样品适合目标设备上。
  1. 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.
  2. 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.

这篇关于为什么我的Soundpool静音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆