Back to project page GNE_Nepal_App.
The source code is released under:
GNU General Public License
If you think the Android project GNE_Nepal_App listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.yadaming.gne_nepal_app; /*from w w w. ja va 2 s. c om*/ import android.content.Context; import android.media.MediaPlayer; import android.media.MediaPlayer.OnCompletionListener; public class SoundModule { Context c; public static boolean playing; // create a private MediaPlayer instance private static MediaPlayer mMediaPlayer; public SoundModule(Context context) { c = context; } public void play(int soundToPlay) { playing = true; //MediaPlayer mMediaPlayer = MediaPlayer.create(c, soundToPlay); mMediaPlayer = MediaPlayer.create(c, soundToPlay); mMediaPlayer.start(); mMediaPlayer.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { playing = false; } }); } public boolean playsound(int soundToPlay) { playing = true; //MediaPlayer mMediaPlayer = MediaPlayer.create(c, soundToPlay); mMediaPlayer = MediaPlayer.create(c, soundToPlay); mMediaPlayer.start(); mMediaPlayer.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { playing = false; } }); return true; } public void stop(int soundToPlay) { mMediaPlayer.stop(); playing = false; } }