In your Fxml you need
<FlowPane alignment="CENTER" columnHalignment="CENTER" layoutX="9.0" layoutY="48.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="9.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="48.0">
<children>
<MediaView fx:id="mediaView">
</MediaView>
</children>
</FlowPane>
and in you controller :
@FXML private MediaPlayer mediaPlayer;
@FXML private Duration duration;
@FXML private MediaView mediaView;
....
@Override
public void initialize(URL url, ResourceBundle rb) {
try {
init();
} catch (MalformedURLException ex) {
Logger.getLogger(MainOnlineController.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void init() throws MalformedURLException {
....
mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
mediaView.setMediaPlayer(mediaPlayer);
mediaPlayer.setOnPlaying(new Runnable() {
public void run() {
if (stopRequested) {
mediaPlayer.pause();
stopRequested = false;
} else {
playButton.setText("||");
}
}
});
...other methods for mediaPlayer