开发者

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();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜