开发者

play a simple .wav on a view page?

开发者 https://www.devze.com 2023-01-26 04:13 出处:网络
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:

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

精彩评论

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

关注公众号