From: Debayan Sutradhar Date: Fri, 02 Apr 2021 01:57:56 +0530 Subject: refactored --- refactored --- --- 'a/playaudioclipaction/src/main/java/com/stream_pi/playaudioclipaction/PlayAudioClipAction.java' +++ b/playaudioclipaction/src/main/java/com/stream_pi/playaudioclipaction/PlayAudioClipAction.java @@ -60,21 +60,22 @@ public class PlayAudioClipAction extends } - if(!path.equals(audioFileLocationProperty.getStringValue())) + if(mediaPlayer != null) { - if(mediaPlayer!=null) + if(mediaPlayer.isPlaying()) { - if(mediaPlayer.isPlaying()) - Platform.runLater(mediaPlayer::stop); + Platform.runLater(mediaPlayer::stop); + return; } + } + + if(!audioFileLocationProperty.getStringValue().equals(path)) + { path = audioFileLocationProperty.getStringValue(); mediaPlayer = new AudioClip(new File(path).toURI().toString()); } - if(mediaPlayer.isPlaying()) - Platform.runLater(mediaPlayer::stop); - else - Platform.runLater(mediaPlayer::play); + Platform.runLater(mediaPlayer::play); } @Override