我有一个无缝代码,其中包括 JavaFX 的 mediaPlayer!我设置了 mediaPlayer.setCycleCounts (MediaPlayer.INDEFINITE)并且歌曲总是重复!但是在重复周期之间我有一些小停顿,在 0.5 秒内!如何不间断地进行这个循环?
private File mp3File;
private Media media;
private MediaPlayer mediaPlayer;
private MediaView mediaView;
public SoundEngine(String mediaFile) {
mp3File = new File(mediaFile);
try {
media = new Media(mp3File.toURI().toURL().toString());
} catch (MalformedURLException e) {
e.printStackTrace();
}
mediaPlayer = new MediaPlayer(media);
mediaView = new MediaView(mediaPlayer);
mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);
}