声音池负载监听器?

时间:2011-10-27 23:01:04

标签: android

我将声音加载到soundpool然后:

mySoundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
        public void onLoadComplete(SoundPool soundPool, int sampleId,
                int status) {
            loaded = true;
        }
    });

我的问题是,如何在没有用户做任何事情(如触摸按钮)的情况下让声音直接播放?

由于

1 个答案:

答案 0 :(得分:1)

SoundPool.setOnLoadCompleteListner(new OnLoadCompleteListner(){

@override
onLoadComplete(SoundPool soundPool, int sampleId, int status)
{
    if(status == 0)
    soundPool.play(soundId, 1.0f, 1.0f, 0, 0, 0.0f);
}});