Example usage for javafx.scene.media MediaPlayer getError

List of usage examples for javafx.scene.media MediaPlayer getError

Introduction

In this page you can find the example usage for javafx.scene.media MediaPlayer getError.

Prototype

public final MediaException getError() 

Source Link

Document

Retrieve the value of the #errorProperty error property or null if there is no error.

Usage

From source file:filesmodel.SoundModel.java

/** @return a MediaPlayer for the given source which will report any errors it encounters */
public MediaPlayer createPlayer(String mediaSource) {
    final Media media = new Media(mediaSource);
    final MediaPlayer player = new MediaPlayer(media);
    player.setOnError(new Runnable() {
        @Override//from  ww  w  .  j a v a2 s .c om
        public void run() {
            System.out.println("Media error occurred: " + player.getError());
        }
    });

    return player;

}