声音池载入监听器? [英] Sound Pool Load Listener?

查看:221
本文介绍了声音池载入监听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加载声音到的Soundpool然后:

  mySoundPool.setOnLoadCompleteListener(新OnLoadCompleteListener(){
        公共无效的onLoadComplete(的Soundpool的Soundpool,INT sampleId,
                INT状态){
            加载=真实的;
        }
    });

我的问题是,我怎么能得到的声音直打它无需用户做任何事像触摸按钮加载之后?

感谢


解决方案

  SoundPool.setOnLoadCompleteListner(新OnLoadCompleteListner(){@override
的onLoadComplete(的Soundpool的Soundpool,诠释sampleId,诠释状态)
{
    如果(状态== 0)
    soundPool.play(soundId,1.0F,1.0F,0,0,0.0);
}});

I load a sound into soundpool and then:

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

My question is, how can I get the sound to play straight after it is loaded without the user having to do anything like touch a button?

Thanks

解决方案

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);
}});

这篇关于声音池载入监听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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