【发布时间】:2012-10-24 14:53:56
【问题描述】:
自从我使用简单的 medaiplayer (Sound sometimes remains silent when playing more sounds in a row, why?) 并尝试使用 SoundPool 来创建整个事情以来,我的上一个问题没有得到回答。但是你猜怎么着,几乎同样的事情发生了,但有一个错误
AudioFlinger could not create track, status: -12
Error creating AudioTrack
我了解到最多可以将 32 个声音存储在 soundpool 的内存中,然后我会收到错误消息。没错,在第 32 个声音之后,我无法播放任何声音,因为我总是收到错误消息。那么我如何在 SoundPool 中使用超过 32 种声音呢?我尝试使用 3 个 Soundpool,每个 Soundpool 有 20 个声音,我总是用这个从其他池中卸载所有声音:
mSoundPoolMapV1.clear(); //clearing HashMap
for(int i=1;i<15;i++){
mSoundPoolV1.unload(i);
}
但是同样的错误又来了。 (我使用 22k 声音而不是 44.1k,我读到这可以解决它,但什么也没发生) 任何建议表示赞赏。到底是什么,我既不能用 mediaplayer 也不能用 soundpool 播放大约 50 种声音?这怎么可能??
release():
mSoundPoolMap.clear();
for(int i=1;i<50;i++){
mSoundPool.unload(i);
}
mSoundPool.release();
mSoundPoolMap.put(1, mSoundPool.load(Main.this, R.raw.sound1, 1));
...
mSoundPoolMap.put(50, mSoundPool.load(Main.this, R.raw.sound50, 1));
所以我清除了 hashmp,然后卸载了所有的声音,然后我释放了 soundpool。然后我再次填充哈希图,但现在它根本没有给我任何声音。我一定错过了什么,你能告诉我什么吗?
【问题讨论】:
标签: android hashmap media-player soundpool