diff --git a/src/main/java/net/Broken/RestApi/MusicWebController.java b/src/main/java/net/Broken/RestApi/MusicWebController.java index 65a97cb..91ce83e 100644 --- a/src/main/java/net/Broken/RestApi/MusicWebController.java +++ b/src/main/java/net/Broken/RestApi/MusicWebController.java @@ -106,6 +106,15 @@ public class MusicWebController { case "ADD": return new WebLoadUtils(musicCommande ,data).getResponse(); + case "FLUSH": + try { + musicCommande.getAudioManager().getMusicManager().scheduler.flush(); + return new ResponseEntity<>(new CommandResponseData(data.command, "Accepted"), HttpStatus.OK); + } catch (NullMusicManager | NotConectedException nullMusicManager) { + return new ResponseEntity<>(new CommandResponseData(data.command, "Not connected to vocal!"), HttpStatus.NOT_ACCEPTABLE); + } + + } } else diff --git a/src/main/resources/static/js/init.js b/src/main/resources/static/js/init.js index 9e39df9..9ccaa96 100644 --- a/src/main/resources/static/js/init.js +++ b/src/main/resources/static/js/init.js @@ -65,6 +65,13 @@ $(document).ready(function() { } }); + $('#flush_btn').click(function () { + var command = { + command: "FLUSH" + }; + sendCommand(JSON.stringify(command)); + }); + $('#btn_add_top').click(function () { var command = { command: "ADD", @@ -74,7 +81,7 @@ $(document).ready(function() { }; $('#input_link').val(''); sendCommand(JSON.stringify(command)); - }) + }); $('#btn_add_bottom').click(function () { var command = { @@ -85,7 +92,7 @@ $(document).ready(function() { }; $('#input_link').val(''); sendCommand(JSON.stringify(command)); - }) + }); }) @@ -120,6 +127,9 @@ function getCurentMusic() { if ($('#add_btn').hasClass("disabled")) { $('#add_btn').removeClass("disabled"); } + if ($('#flush_btn').hasClass("disabled")) { + $('#flush_btn').removeClass("disabled"); + } $('#music_img').attr("src","/img/no_music.jpg"); $('#total_time').text("00:00"); @@ -170,6 +180,9 @@ function getCurentMusic() { if (!$('#add_btn').hasClass("disabled")) { $('#add_btn').addClass("disabled"); } + if (!$('#flush_btn').hasClass("disabled")) { + $('#flush_btn').addClass("disabled"); + } $('#music_img').attr("src","/img/disconnected.png"); @@ -254,6 +267,9 @@ function updateControl(data){ if ($('#add_btn').hasClass("disabled")) { $('#add_btn').removeClass("disabled"); } + if ($('#flush_btn').hasClass("disabled")) { + $('#flush_btn').removeClass("disabled"); + } if ($('#btn_next').hasClass("disabled")) { $('#btn_next').removeClass("disabled"); diff --git a/src/main/resources/templates/music.html b/src/main/resources/templates/music.html index 08e8e68..37d9021 100644 --- a/src/main/resources/templates/music.html +++ b/src/main/resources/templates/music.html @@ -86,8 +86,11 @@