Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void playMusic(){
- media = new Media("file:///" + System.getProperty("user.dir").replace('\', '/') + "/" + "ressource/audio/tetris_1.mp3");
- MediaPlayer player = new MediaPlayer(media);// I will declare media and player it as a static variable later
- player.setAutoPlay(true);
- player.play();
- player.setOnEndOfMedia(new Runnable() {
- public void run() {
- player.seek(Duration.ZERO);
- }
- });
- // Create Handlers for handling Errors (copy-pasted code)
- player.setOnError(new Runnable()
- {
- public void run()
- {
- System.out.println(player.getError());
- }
- });
- media.setOnError(new Runnable()
- {
- public void run()
- {
- System.out.println(media.getError());
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement