Audio attachment with image in android
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();
精彩评论