private MediaPlayer mp;
mp = MediaPlayer.create(MainActivity.this, R.raw.bubble_blust_bg_music);
mp.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// Release after played the file
mp.release();
}
});
mp.start();
Play audio file in Android
Sometimes , You wanna play audio files in your android application.
it's very easy. Create a MediaPlayer class object & call it's
method. Make sure, You create a folder, specific for your sound. Here, I
create a folder named raw in res directory & put an audio file lets say bubble_blust_bg_music.mp3 there. Follow below code to achieve this.