@Override protected Object call() throws Exception { // Sleep until the start time has elapsed TimeUnit.SECONDS.sleep(startTime); // If we still wish to continue playing at this stage do so by spawning a new thread if (continuePlaying == true) { Platform.runLater( new Runnable() { public void run() { mp.play(); } }); // If the duration to play is not invalid set a stop time if (playDuration != null && playDuration != 0) { mp.setStopTime(Duration.seconds(playDuration)); } } // Return null to keep Java happy. return null; }