Java examples for javax.sound.sampled:Audio
Audio clip to cheer when the selection is correct
//package com.java2s; import java.applet.AudioClip; public class Main { static AudioClip gameClip, rightClip, wrongClip; /**//from w ww .j av a2 s . c om * Audio clip to cheer the kindergartner when the selection is correct */ static void playRight() { try { stopGameMusic(); Thread.sleep(200); rightClip.play(); Thread.sleep(2449); loopGameMusic(); } catch (Exception e) { System.out.println("playRight caught exception" + e.getMessage()); } } /** * The music needs to be stopped to play other sounds like right or wrong */ static void stopGameMusic() { try { gameClip.stop(); } catch (Exception e) { System.out.println("stopGameMusic caught exception" + e.getMessage()); } } /** * Game music that plays in the background */ static void loopGameMusic() { try { gameClip.loop(); } catch (Exception e) { System.out.println("loopgamemusic caught exception" + e.getMessage()); } } }