开发者

play a simple .wav on a view page?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜