import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.layout.StackPane; import javafx.scene.media.AudioClip; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.stage.Stage; /** * * @author lans */ public class SampleMediaCrash extends Application { private static final String MEDIA_URL = "http://reavers.us.oracle.com/MediaJUnitTestFiles/sounds/doorbell.mp3"; public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) throws Exception { AudioClip audioClip = new AudioClip(MEDIA_URL); StackPane stack = new StackPane(); Text text = new Text("Audio Clip"); text.setFont(new Font(80)); stack.getChildren().add(text); Scene scene = new Scene(new Group()); scene.setRoot(stack); stage.setTitle("AudioClipStopTest"); stage.setWidth(640); stage.setHeight(480); stage.setScene(scene); stage.show(); audioClip.play(); try { Thread.sleep(2000); } catch (InterruptedException ex) { ex.printStackTrace(); } audioClip.stop(); } }