When playing many AudioClip, the JVM crashes brutally.
Don't know is it's related to playing always the same or just very frequently.
use the <Note1.wav> from Java FX Ensemble.jar
[Dynamic-linking native method com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer.gstGetPresentationTime ... JNI]
[Dynamic-linking native method com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMedia.gstDispose ... JNI]
import java.net.URL;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.media.AudioClip;
import javafx.stage.Stage;
public class AudioMain extends Application {
public static void main(String[] args) {
launch(AudioMain.class, args);
}
@Override
public void start(final Stage primaryStage) throws Exception {
final Label label = new Label();
final AudioThread at = new AudioThread(100, label);
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(label, 200, 100));
primaryStage.show();
at.start();
}
private final class AudioThread extends Thread {
/** sleep time */
private final int sleep;
private final Label label;
private AudioThread(final int sleep, final Label label) {
super("Audio-Thread");
setPriority(Thread.MIN_PRIORITY);
setDaemon(true);
this.sleep = sleep;
this.label = label;
}
@Override
public void run() {
final int[] run = new int[1];
run[0] = 0;
for (;;) {
try {
final URL url = AudioMain.class.getResource("Note1.wav");
final String string = url.toString();
final AudioClip audioClip = new AudioClip(string);
audioClip.play();
Platform.runLater(new Runnable() {
@Override
public void run() {
label.setText(String.valueOf(run[0]++));
}
});
sleep(this.sleep);
} catch (final Throwable throwable) {
throwable.printStackTrace();
}
}
}
}
}
Don't know is it's related to playing always the same or just very frequently.
use the <Note1.wav> from Java FX Ensemble.jar
[Dynamic-linking native method com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer.gstGetPresentationTime ... JNI]
[Dynamic-linking native method com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMedia.gstDispose ... JNI]
import java.net.URL;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.media.AudioClip;
import javafx.stage.Stage;
public class AudioMain extends Application {
public static void main(String[] args) {
launch(AudioMain.class, args);
}
@Override
public void start(final Stage primaryStage) throws Exception {
final Label label = new Label();
final AudioThread at = new AudioThread(100, label);
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(label, 200, 100));
primaryStage.show();
at.start();
}
private final class AudioThread extends Thread {
/** sleep time */
private final int sleep;
private final Label label;
private AudioThread(final int sleep, final Label label) {
super("Audio-Thread");
setPriority(Thread.MIN_PRIORITY);
setDaemon(true);
this.sleep = sleep;
this.label = label;
}
@Override
public void run() {
final int[] run = new int[1];
run[0] = 0;
for (;;) {
try {
final URL url = AudioMain.class.getResource("Note1.wav");
final String string = url.toString();
final AudioClip audioClip = new AudioClip(string);
audioClip.play();
Platform.runLater(new Runnable() {
@Override
public void run() {
label.setText(String.valueOf(run[0]++));
}
});
sleep(this.sleep);
} catch (final Throwable throwable) {
throwable.printStackTrace();
}
}
}
}
}