使用SoundPool播放两种声音

时间:2016-04-10 05:29:01

标签: java android soundpool android-imagebutton

我是编程的新手,我很确定我在这里犯了一个愚蠢的错误,但我已经陷入困境,无法解决问题。< / p>

出现的错误如下:

错误的第一个参数类型。找到:&#39; int []&#39;,必需:&#39; int&#39;

当尝试播放声音时,此错误几乎出现在代码的末尾。更具体地说:

spool.play(soundId, 1, 1, 0, 0, 1f);

我很确定这可能很容易修复,但我无法做到。有人可以帮我解决吗?

我决定在这里发布我遇到问题的部分;如果有人想检查整件事,那么在修改中是对的。

if (rndm == 0) { //I'm just testing it with the horse sound
                             //right now, so if the random sound that is               
                             //played equals to zero, that's the horse sound
                final int[] soundId = new int[2];
                soundId[0] = spool.load(actibida.this, R.raw.el, 1); //"el" is the horse sound ID
                soundId[1] = spool.load(actibida.this, R.raw.applause, 1); //this is an applause clip I want to be played simultaneously with the horse sound
                ImageButton caballo = (ImageButton) findViewById(R.id.caballo); //this is the horse ImageButton ID
                caballo.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        spool.play(soundId, 1, 1, 0, 0, 1f); //this is
                                                             //where I'm
                                                             //having the
                                                             //issue.
                    }
                });
            }

0 个答案:

没有答案