[英]Javafx won't play mp3
I want to run mp3 without any videos with java.我想用 java 运行没有任何视频的 mp3。
import javafx.embed.swing.JFXPanel;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
public class Guess {
public static void main(String[] args) throws Exception {
new JFXPanel();
Media m = new Media("file:///D://Guess_the_Song//resources//new.m4a");
MediaPlayer p = new MediaPlayer(m);
p.play();
}
}
This code doesn't lead me to any errors, but I can't hear any sound...此代码不会导致我出现任何错误,但我听不到任何声音......
Try this:尝试这个:
path = "D:/Guess_the_Song/resources/new.m4a";
Media m = new Media(new File(path).toURI().toString());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.