Android: Playing an audio clip onClick

Posted by fordays on Stack Overflow See other posts from Stack Overflow or by fordays
Published on 2010-06-15T00:04:49Z Indexed on 2010/06/15 0:12 UTC
Read the original article Hit count: 245

Filed under:
|

How do I set up an audiofile to play when a user touches an image.

Where should I store the audio file and what code should I use to actually play the file? I don't want to bring up the MediaPlayer interface or anything like that.

I was thinking of doing it like this:

foo = (ImageView)this.findViewById(R.id.foo);
    foo.setOnClickListener(this);

public void onClick(View v) {
if (foo.isTouched()) {

 playAudioFile();
  }
}

Thanks

© Stack Overflow or respective owner

Related posts about android

Related posts about audio