大佬教程收集整理的这篇文章主要介绍了JavaFX:尝试通过MediaPlayer类播放mp3文件时未初始化“工具包”,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
JavaFX
在启动时执行“隐藏”初始化。运行@H_64_3@mediaPlayer不会触发初始化。
触发它的最简单方法是:
Application.launch()
执行Application
从fx ant任务打包的jar运行的基础程序(例如,从Netbeans JavaFX项目构建)Platform.startup(RunnablE)
(Java 9+)我正在尝试使用以下命令在程序的后台播放一个简单的mp3:
@H_64_3@media med = new Media(getClass().getresource("intro.mp3").toExternalForm()); MediaPlayer mPlayer = new MediaPlayer(med); mPlayer.play();
intro.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)
根据问题的原因有人有想法吗?
以上是大佬教程为你收集整理的JavaFX:尝试通过MediaPlayer类播放mp3文件时未初始化“工具包”全部内容,希望文章能够帮你解决JavaFX:尝试通过MediaPlayer类播放mp3文件时未初始化“工具包”所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。