Android 2.2的 - 的Soundpool样本0未准备好 [英] Android 2.2 - SoundPool sample 0 is not READY

查看:164
本文介绍了Android 2.2的 - 的Soundpool样本0未准备好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我寻觅计算器,找不到像我这样situtation。我使用的四个按钮,每个按钮播放声音文件。
我使用的Soundpool:
      的Soundpool声音=新的Soundpool(4 AudioManager.STREAM_MUSIC,0)

我还使用了 OnLoadCompleteListener(),它使用日志中创建LogCat中的我通知。
当我启动该程序在模拟器中我看到所有四个样品完成装载。在方案三的声音但是会玩,一会总是说:
WARN /的Soundpool(4842):试样0没有准备好

任何想法..因为我很大吃一惊。声音文件是16位PCM波形文件播放方波的音调。
加载code:
        sound.setOnLoadCompleteListener(新OnLoadCompleteListener(){

I have searched StackOverflow and cannot find a situtation like mine. I am using four buttons with each button playing a sound file.
I am using SoundPool:
SoundPool sound = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);

I am also using the OnLoadCompleteListener() which uses Log to create an I notification in LogCat.
When I launch the program in the emulator I see all four samples complete loading. During the program three of the sounds will play, however, one will always say:
WARN/SoundPool(4842): sample 0 not READY

Any Ideas.. cause i'm quite flabbergasted. The sound files are 16-bit pcm wave file playing squarewave tones.
Load Code:
sound.setOnLoadCompleteListener(new OnLoadCompleteListener(){

        @Override
        public void onLoadComplete(SoundPool sound, int sampleId, int status) {
            if(status != 0)
                Log.e("SOUND LOAD"," Sound ID: " + sampleId + " Failed to load.");
            else
                Log.i("SOUND LOAD"," Sound ID: " + sampleId + " loaded.");
        }
    });

    soundID[0] = sound.load(this, R.raw.greennote, 1);
    soundID[1] = sound.load(this, R.raw.rednote, 1);
    soundID[2] = sound.load(this, R.raw.yellownote, 1);
    soundID[3] = sound.load(this, R.raw.bluenote, 1);


播放声音:


Play Sound:

streamid.setStreamId(myActivity.sound.play(id, 0.5f, 0.5f, 0, 0, 1));

推荐答案

我有同样的问题。从我的实验,它看起来像有一些错误的ID的处理方式。的Soundpool只是不喜欢的声音的ID编号为0。

I'm having the same issues. From my experiments, it looks like there's something wrong with the ID handling. SoundPool just doesn't like sound IDs with the number 0.

所以,我已经找到了解决方法。开始我的样品标识1,不为0。希望这个作品。

So I have found a work-around. Start my sample IDs with 1, not 0. Hope this works.

这篇关于Android 2.2的 - 的Soundpool样本0未准备好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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