Versão atual:

Mp3 JavaFX, o que á de errado?

package application;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.media.AudioClip;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Main extends Application {

    private String AUDIO_URL = getClass().getResource(
            "/audio/C:/The unforgiven.mp3").toString();

    public static void main(String[] args) {
        launch();
    }

    @Override
    public void start(Stage palco) throws Exception {
        AudioClip clip = new AudioClip(AUDIO_URL);// 1
        clip.play(); // 2
        StackPane raiz = new StackPane();
        raiz.getChildren().add(new Text("Tocando Música ")); 
        Scene cena = new Scene(raiz, 600, 100);
        palco.setTitle("Tocando Audio em JavaFX");
        palco.setScene(cena);
        palco.show();

    }
}

Informa esse erro: Exception in Application constructor Exception in thread "main" java.lang.RuntimeException: Unable to construct Application instance: class application.Main at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source) at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source) at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) ... 4 more Caused by: java.lang.NullPointerException at application.Main.<init>(Main.java:13) ... 8 more `

Versões(2):

Ver a versão formatada

Mp3 JavaFX, o que á de errado?

Comentário

new question