From 7360a197c9c09ffa239b0c56712202e8320b9e22 Mon Sep 17 00:00:00 2001 From: Matt Kohls Date: Tue, 30 Oct 2018 15:27:36 -0400 Subject: Adding progressbar --- .../java/soundchan/BotListener/BotListener.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/soundchan/BotListener/BotListener.java b/src/main/java/soundchan/BotListener/BotListener.java index 6e928e6..05ebec1 100644 --- a/src/main/java/soundchan/BotListener/BotListener.java +++ b/src/main/java/soundchan/BotListener/BotListener.java @@ -268,7 +268,7 @@ public class BotListener extends ListenerAdapter{ if(currentlyPlaying != null) { message = "Currently Playing: " + currentlyPlaying.getInfo().title + " by " + currentlyPlaying.getInfo().author; if(printStatus) { - message += ( "\nTime : " + genTimeStamp(currentlyPlaying.getPosition()) + " | " + genTimeStamp(currentlyPlaying.getDuration()) ); + message += genTimeInformation(currentlyPlaying.getPosition(), currentlyPlaying.getDuration()); if(musicManager.player.isPaused()) { message += "\n**Paused**"; } else { @@ -385,6 +385,26 @@ public class BotListener extends ListenerAdapter{ } } + /** + * Creates a block of time information with a progressbar + * @param currentMillis Current position in the audio in milliseconds + * @param durationMillis Length of audio in milliseconds + * @return Time information block + */ + private static String genTimeInformation(long currentMillis, long durationMillis) { + String message = "|"; + int fill = (int) ((double)(currentMillis / durationMillis)) * 10; + for(int i = 0; i < fill; i++) { + message += "--"; + } + message += "<>"; + for(int i = fill; i < 10; i++) { + message += "--"; + } + message += "|\nTime : " + genTimeStamp(currentMillis) + " | " + genTimeStamp(durationMillis); + return message; + } + /** * Creates a timestamp string from a number of milliseconds * @param durationInMillis Number of milliseconds to turn into timestamp -- cgit v1.2.3