JavaFX:尝试通过MediaPlayer类播放mp3文件时未初始化“工具包”
2022-09-01 11:45:11
我正在尝试使用以下方法在我的程序后台播放一个简单的mp3:
Media med = new Media(getClass().getResource("intro.mp3").toExternalForm());
MediaPlayer mPlayer = new MediaPlayer(med);
mPlayer.play();
介绍.mp3文件与其他.class文件一起放置在我的包的 bin 文件夹中。
问题是我的程序以以下方式终止:
Exception in thread "main" java.lang.IllegalStateException: Toolkit not initialized
完整的终止日志为:
Device "Intel(R) HD Graphics Family" (\\.\DISPLAY1) initialization failed :
WARNING: bad driver version detected, device disabled. Please update your driver to at least version 8.15.10.2302
Exception in thread "main" java.lang.IllegalStateException: Toolkit not initialized
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:153)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:148)
at javafx.application.Platform.runLater(Platform.java:52)
at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:450)
at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:365)
at PokerApp.<init>(PokerApp.java:33)
at PokerApp.main(PokerApp.java:105)
有人根据问题的原因有任何想法吗?