java.applet.AudioClip Java Examples
The following examples show how to use
java.applet.AudioClip.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutoCloseTimeCheck.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Checks that after small period of non-activity the clip will not be * closed and the "Direct Clip" thread will alive. */ private static void testSmallDelay(final File file) throws IOException { AudioClip clip = (AudioClip) file.toURL().getContent(); long threadID = 0; // Will run the test no more than 15 seconds long endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(15); while (endtime - System.nanoTime() > 0) { clip.loop(); sleep(500); long data = count(); if (data != threadID) { System.out.println("Playing on new thread: " + data + " at " + new java.util.Date()); if (threadID == 0) { threadID = data; } else { throw new RuntimeException("Thread was changed"); } } clip.stop(); sleep(500); } }
Example #2
Source File: AutoCloseTimeCheck.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Checks that after small period of non-activity the clip will not be * closed and the "Direct Clip" thread will alive. */ private static void testSmallDelay(final File file) throws IOException { AudioClip clip = (AudioClip) file.toURL().getContent(); long threadID = 0; // Will run the test no more than 15 seconds long endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(15); while (endtime - System.nanoTime() > 0) { clip.loop(); sleep(500); long data = count(); if (data != threadID) { System.out.println("Playing on new thread: " + data + " at " + new java.util.Date()); if (threadID == 0) { threadID = data; } else { throw new RuntimeException("Thread was changed"); } } clip.stop(); sleep(500); } }
Example #3
Source File: SoundManager.java From Spark with Apache License 2.0 | 6 votes |
/** * Plays a sound file. * * @param soundFile the File object representing the wav file. */ public void playClip(final File soundFile) { final Runnable playThread = () -> { try { final URL url = soundFile.toURI().toURL(); AudioClip ac = fileMap.get(url); if (ac == null) { ac = Applet.newAudioClip(url); fileMap.put(url, ac); } ac.play(); } catch (MalformedURLException e) { Log.error(e); } }; TaskEngine.getInstance().submit(playThread); }
Example #4
Source File: AutoCloseTimeCheck.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Checks that after small period of non-activity the clip will not be * closed and the "Direct Clip" thread will alive. */ private static void testSmallDelay(final File file) throws IOException { AudioClip clip = (AudioClip) file.toURL().getContent(); long threadID = 0; // Will run the test no more than 15 seconds long endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(15); while (endtime - System.nanoTime() > 0) { clip.loop(); sleep(500); long data = count(); if (data != threadID) { System.out.println("Playing on new thread: " + data + " at " + new java.util.Date()); if (threadID == 0) { threadID = data; } else { throw new RuntimeException("Thread was changed"); } } clip.stop(); sleep(500); } }
Example #5
Source File: BartThemeDialog.java From BART with MIT License | 6 votes |
public static Dialog getFunDialog() { FileObject img = FileUtil.getConfigFile("BartGIfImage/BartSaturdayNightFever.gif"); FileObject audio = FileUtil.getConfigFile("BartAudio/STheme.wav"); final AudioClip clip = Applet.newAudioClip(audio.toURL()); Icon icon = new ImageIcon(img.toURL()); JLabel label = new JLabel(icon); final Dialog dialog = new BartThemeDialog(WindowManager.getDefault().getMainWindow(), label); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if(e.getClickCount() == 1) { clip.stop(); dialog.dispose(); } } }); clip.loop(); return dialog; }
Example #6
Source File: AutoCloseTimeCheck.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Checks that after small period of non-activity the clip will not be * closed and the "Direct Clip" thread will alive. */ private static void testSmallDelay(final File file) throws IOException { AudioClip clip = (AudioClip) file.toURL().getContent(); long threadID = 0; // Will run the test no more than 15 seconds long endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(15); while (endtime - System.nanoTime() > 0) { clip.loop(); sleep(500); long data = count(); if (data != threadID) { System.out.println("Playing on new thread: " + data + " at " + new java.util.Date()); if (threadID == 0) { threadID = data; } else { throw new RuntimeException("Thread was changed"); } } clip.stop(); sleep(500); } }
Example #7
Source File: Beans.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #8
Source File: Beans.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #9
Source File: Beans.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #10
Source File: Beans.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #11
Source File: AutoCloseTimeCheck.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Checks that after a big period of non-activity the clip will be closed * and the "Direct Clip" thread will stop. */ private static void testBigDelay(final File file) throws Exception { AudioClip clip = (AudioClip) file.toURL().getContent(); clip.loop(); clip.stop(); sleep(20000); // 20 sec for slow systems if (count() != 0) { throw new RuntimeException("Thread was found"); } }
Example #12
Source File: FileUtil.java From JAVA-MVC-Swing-Monopoly with Apache License 2.0 | 5 votes |
public static AudioClip getAudio(String path) { URL url = getURL("audio", path); if(url == null) { return null; } return Applet.newAudioClip(url); }
Example #13
Source File: Beans.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #14
Source File: Beans.java From jdk-1.7-annotated with Apache License 2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #15
Source File: Beans.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #16
Source File: SoundManager.java From Spark with Apache License 2.0 | 5 votes |
/** * Plays an audio clip of local clips deployed with Spark. * * @param clip the properties value found in la.properties. * @return the AudioClip found. If no audio clip was found, returns null. */ public AudioClip getClip(String clip) { if (!clipMap.containsKey(clip)) { // Add new clip final AudioClip newClip = loadClipForURL(clip); if (newClip != null) { clipMap.put(clip, newClip); } } return clipMap.get(clip); }
Example #17
Source File: SoundManager.java From Spark with Apache License 2.0 | 5 votes |
/** * 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); }
Example #18
Source File: SoundManager.java From Spark with Apache License 2.0 | 5 votes |
/** * 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"); } }
Example #19
Source File: SoundManager.java From Spark with Apache License 2.0 | 5 votes |
/** * Creates an AudioClip from a URL. * * @param clipOfURL the url of the AudioClip to play. We only support .wav files at the moment. * @return the AudioFile found. If no audio file was found,returns null. */ private AudioClip loadClipForURL(String clipOfURL) { final URL url = SoundsRes.getURL(clipOfURL); AudioClip clip = null; try { clip = Applet.newAudioClip(url); } catch (Exception e) { Log.error("Unable to load sound url: " + url + "\n\t: " + e); } return clip; }
Example #20
Source File: AlertManager.java From Spark with Apache License 2.0 | 5 votes |
public void startAlert(String alertResourceName) { AudioClip alertClip = getAlertClip(alertResourceName, true); if (alertClip == null) { return; } boolean loop = true; if (!loop) { alertClip.play(); } else { alertClip.loop(); } }
Example #21
Source File: AlertManager.java From Spark with Apache License 2.0 | 5 votes |
private AudioClip getAlertClip(String alertResourceName, boolean create) { AudioClip clip = (AudioClip) alertClips.get(alertResourceName); if (clip == null && create) { clip = Applet.newAudioClip(PhoneRes.getURL(alertResourceName)); if (clip != null) { alertClips.put(alertResourceName, clip); } } return clip; }
Example #22
Source File: Resource.java From osp with GNU General Public License v3.0 | 5 votes |
/** * Gets an AudioClip. * * @return the audio clip */ public AudioClip getAudioClip() { if((clip==null)&&(getURL()!=null)) { clip = Applet.newAudioClip(getURL()); } return clip; }
Example #23
Source File: Beans.java From Java8CN with Apache License 2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #24
Source File: Beans.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #25
Source File: AutoCloseTimeCheck.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Checks that after a big period of non-activity the clip will be closed * and the "Direct Clip" thread will stop. */ private static void testBigDelay(final File file) throws Exception { AudioClip clip = (AudioClip) file.toURL().getContent(); clip.loop(); clip.stop(); sleep(20000); // 20 sec for slow systems if (count() != 0) { throw new RuntimeException("Thread was found"); } }
Example #26
Source File: Beans.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #27
Source File: AutoCloseTimeCheck.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Checks that after a big period of non-activity the clip will be closed * and the "Direct Clip" thread will stop. */ private static void testBigDelay(final File file) throws Exception { AudioClip clip = (AudioClip) file.toURL().getContent(); clip.loop(); clip.stop(); sleep(20000); // 20 sec for slow systems if (count() != 0) { throw new RuntimeException("Thread was found"); } }
Example #28
Source File: Beans.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #29
Source File: Beans.java From JDKSourceCode1.8 with MIT License | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }
Example #30
Source File: Beans.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public AudioClip getAudioClip(URL url) { // We don't currently support audio clips in the Beans.instantiate // applet context, unless by some luck there exists a URL content // class that can generate an AudioClip from the audio URL. try { return (AudioClip) url.getContent(); } catch (Exception ex) { return null; } }