
1)当声音没有播放时……
样品未加载.等待30毫秒.
样品X未准备好
2)当声音实际播放时
*未加载样品.等待30毫秒.
因此,即使播放声音,logcat也会告诉“样品没有准备好”.
好的,这是logcat给出的信息.另一件事是,对于较大的声音文件,失败的概率更大.小型声音文件播放两秒钟(约30 KB)
大约4秒(约60 KB).
现在我无法弄清楚如何解决这个问题.我在网上寻找解决方案,尤其是这个网站.我都试过……
1)使用OnLoadCompleteListener()
它不工作
2)制作某种while循环.
也不工作
我有什么不对的.我给出下面的代码.也许有些尴尬?我是否以错误的方式实现了侦听器?
Cincerely
expList.setonGroupExpandListener(new OnGroupExpandListener() { public voID onGroupExpand(int groupposition) { final int group_position = groupposition; loaded = false; int nmbr_childs = adapter.getChildrenCount(groupposition); if (nmbr_childs == 1) { myVoice = soundPool.load(PhraseActivity.this,sound[group_position][0],2); soundPool.setonLoadCompleteListener(new OnLoadCompleteListener() { @OverrIDe public voID onLoadComplete(SoundPool soundPool,int sampleID,int status) { loaded = true; } }); if (loaded) { soundPool.play(myVoice,20,1,1f); } else { System.out.println("something wrong with soundpool!"); } } group = groupposition; int len = adapter.getGroupCount(); for (int i = 0; i < len; i++) { if (i != groupposition) { expList.collapseGroup(i); } } } });解决方法 我认为您应该按如下方式更改代码: myVoice = soundPool.load(PhraseActivity.this,2); soundPool.setonLoadCompleteListener(new OnLoadCompleteListener() { @OverrIDe public voID onLoadComplete(SoundPool soundPool,int status) { soundPool.play(myVoice,1f); } }); 它对我有用.
总结以上是内存溢出为你收集整理的android – 示例未准备好的soundpool全部内容,希望文章能够帮你解决android – 示例未准备好的soundpool所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)