Back to project page K6nele.
The source code is released under:
Apache License
If you think the Android project K6nele 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 ee.ioc.phon.android.speak; //from ww w . j a va 2 s . c om import android.content.Context; import android.media.AudioManager; import android.media.MediaPlayer; import android.os.SystemClock; public class AudioCue { private static final int DELAY_AFTER_START_BEEP = 200; private final Context mContext; public AudioCue(Context context) { mContext = context; } public void playStartSoundAndSleep() { playSound(R.raw.explore_begin); SystemClock.sleep(DELAY_AFTER_START_BEEP); } public void playStopSound() { playSound(R.raw.explore_end); } public void playErrorSound() { playSound(R.raw.error); } private void playSound(int sound) { MediaPlayer mp = MediaPlayer.create(mContext, sound); mp.setAudioStreamType(AudioManager.STREAM_MUSIC); mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mp.release(); } }); mp.start(); } }