【发布时间】:2014-12-22 00:23:01
【问题描述】:
在 Android L - 最新的开发者预览版 (Nexus 5) 上,SoundPool.load() 方法似乎有一个回归,加载样本 (5 秒,其中样本是在预加载的-L 系统立即使用完全相同的代码。
我尝试了 OGG 或 MP3,结果都一样。尝试了不同的大小,但都低于 100kb。似乎 40kb 或 80kb 没有任何区别,OGG 或 MP3 也是如此。加载总是延迟 5 秒左右。
在 4.3 中循环被破坏后,这似乎是 SoundPool 中的又一次回归。
这个问题很容易重现:
pool = new SoundPool(6, AudioManager.STREAM_MUSIC, 0);
// use a listener to start playback after load
pool.setOnLoadCompleteListener(listener);
// R.raw.sound1 is either an OGG or MP3 sample under 100kb od size
int id = pool.load(context, R.raw.sound1, 1);
// onLoadComplete() method of the listener is called several seconds after the call to laod()
使用 Builders 引入的 API 21 构建 SoundPool 时也是如此:
AudioAttributes attr = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_MEDIA)
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build();
pool = new SoundPool.Builder().setAudioAttributes(attr).setMaxStreams(6).build();
还有其他人遇到过这种情况吗?有人找到解决方法吗?
非常感谢!
【问题讨论】:
-
在 Nexus 7 2012 上存在相同问题,最终棒棒糖版本 (LRX21P)
-
Nexus 4 存在同样的问题,设备通过无线方式更新到 Android L。虽然带有 Android L 的 Nexus10 没有这样的问题。
-
同样的问题 nexus 5..... wtf...¿??¿?¿?¿ with android 5.0.1 official
-
相同 - Nexus 10,有什么解决方法吗?应用程序过去需要大约 2.5 秒才能加载,现在只需不到 8 秒 :-(
标签: android android-5.0-lollipop soundpool