private static void playApplet(String filename) { URL url = null; try { File file = new File(filename); if (file.canRead()) url = file.toURI().toURL(); } catch (MalformedURLException e) { throw new IllegalArgumentException("could not play '" + filename + "'", e); } // URL url = StdAudio.class.getResource(filename); if (url == null) { throw new IllegalArgumentException("could not play '" + filename + "'"); } AudioClip clip = Applet.newAudioClip(url); clip.play(); }
/** * Play the sound if an event is being processed */ protected void append(LoggingEvent event) { if (clip != null) { clip.play(); } }
/** * Play the sound if an event is being processed */ protected void append(LoggingEvent event) { if (clip != null) { clip.play(); } }
/** * Play the sound if an event is being processed */ protected void append(LoggingEvent event) { if (clip != null) { clip.play(); } }
/** * Play the sound if an event is being processed */ protected void append(LoggingEvent event) { if (clip != null) { clip.play(); } }
AudioClip clip = Applet.newAudioClip(resource); clip.play();
@Override public void run() { try{ audio_clip.play(); Thread.sleep(2500); }catch( Throwable e ){ } } }.start();
public void music(){ String bip = "src/data/fjordmusic.mp3"; Media hit = new Media(Paths.get(bip).toUri().toString()); AudioClip mediaPlayer = new AudioClip(hit.getSource()); mediaPlayer.play(); }
URL url = getClass().getResource("/sound/Your_sound_name.wav"); AudioClip clip = Applet.newAudioClip(url); clip.play();
AudioClip clip; File fileClip = new File("/usr/share/sounds/generic.wav"); URL url = null; try { URI uri = fileClip.toURI(); url = uri.toURL(); clip = Applet.newAudioClip(url); } catch (MalformedURLException e){} clip.play();
URL url = this.getClass().getResource("sounds/beep.au"); String urls=url.toString(); urls=urls.replaceFirst("file:/", "file:///"); AudioClip ac=Applet.newAudioClip(new URL(urls)); ac.play();
import java.applet.*; import java.net.*; public class MainClass { public static void main(String[] args) { try { AudioClip clip = Applet.newAudioClip( new URL("file:C:/sound.wav")); clip.play(); } catch (MalformedURLException murle) { murle.printStackTrace(); }}}
final AudioClip ping = new AudioClip( "http://soundbible.com/grab.php?id=1815&type=wav" ); webView.getEngine().locationProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldLocation, String newLocation) { if (newLocation != null && newLocation.startsWith("http://www.google.com") { ping.play(); } } });
/** * Plays an AudioClip. * * @param clipToPlay the properties value found in la.properties. */ public void playClip(String clipToPlay) { AudioClip clip = getClip(clipToPlay); try { clip.play(); } catch (Exception ex) { System.err.println("Unable to load sound file"); } }
/** * Play a sound file (in .wav, .mid, or .au format) in a background thread. */ public static void play(String filename) { URL url = null; try { File file = new File(filename); if (file.canRead()) url = file.toURI().toURL(); } catch (MalformedURLException e) { e.printStackTrace(); } // URL url = StdAudio.class.getResource(filename); if (url == null) throw new RuntimeException("audio " + filename + " not found"); AudioClip clip = Applet.newAudioClip(url); clip.play(); }
AudioClip plonkSound = new AudioClip("http://somehost/path/plonk.aiff"); plonkSound.play();
AudioClip plonkSound = new AudioClip("http://somehost/path/plonk.aiff"); plonkSound.play();
AudioClip soundMyNoise = new AudioClip(new File("noises/roll.wav").toURI().toString()); soundMyNoise.play();
/** * Plays an AudioClip. * * @param clip the audioclip to play. */ public void playClip(final AudioClip clip) { final Runnable playThread = () -> { try { clip.play(); } catch (Exception ex) { System.err.println("Unable to load sound file"); } }; TaskEngine.getInstance().submit(playThread); }
/** * Make a "bing" sound. */ void bing() { if (!GUIPreferences.getInstance().getSoundMute() && (bingClip != null)) { bingClip.play(); } }