Java Code Examples for java.applet.AudioClip#loop()

The following examples show how to use java.applet.AudioClip#loop() . 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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: AutoCloseTimeCheck.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 4
Source File: AutoCloseTimeCheck.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 vote down vote up
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 dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 7
Source File: AutoCloseTimeCheck.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 8
Source File: AutoCloseTimeCheck.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 9
Source File: AutoCloseTimeCheck.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 10
Source File: AlertManager.java    From Spark with Apache License 2.0 5 votes vote down vote up
public void startAlert(String alertResourceName) {

        AudioClip alertClip = getAlertClip(alertResourceName, true);
        if (alertClip == null) {
            return;
        }
        boolean loop = true;
        if (!loop) {
            alertClip.play();
        } else {
            alertClip.loop();
        }
    }