开发者

Audio attachment with image in android

开发者 https://www.devze.com 2023-04-04 00:26 出处:网络
I have image is my Draw able folder.When I call this image I want to play an audio also which is 开发者_高级运维in my raw folder.can I do this how??please help me. You can achieve by creating image bu

I have image is my Draw able folder.When I call this image I want to play an audio also which is 开发者_高级运维in my raw folder.can I do this how??please help me.


You can achieve by creating image button and put image on it. and onClick of that button you can play the music using MediaPlayer api.

Refer this : http://developer.android.com/guide/topics/media/index.html

Example code for Play audio from Raw folder : http://www.barebonescoder.com/2010/06/android-development-audio-playback-safely/


you can write this code at onResume:

MediaPlayer mp = MediaPlayer.create(getApplicationContext(),
                        R.raw.name);
                mp.start();
                while (mp.isPlaying()) { // donothing
                }
                ;
                mp.release();
0

精彩评论

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