In android, is there a way I can conditionally play a small .wav file when a layout is displayed to the user (on load), like so:
if (randonGen 开发者_Go百科== 3) {
//play small wav sound here
mTheMessage = (TextView) findViewById(R.id.resultText);
mTheImageButton = (ImageButton) findViewById(R.id.face_image);
mTheImageButton.setBackgroundDrawable(bitDraw);
mThePicture.setImageBitmap(cameraBitmap);
}
Where the code to call my sound.wav
from my assets folder is called and played?
Actually - I figured out that a simple Media Play will do the trick with small wavs:
MediaPlayer mp = MediaPlayer.create(this, R.raw.your_wav);
mp.start();
android.media.SoundPool looks like it will do what you want.
精彩评论