diff --git a/src/beatboxer/BeatBoxer.java b/src/beatboxer/BeatBoxer.java index e0cb317..52cc43e 100644 --- a/src/beatboxer/BeatBoxer.java +++ b/src/beatboxer/BeatBoxer.java @@ -52,7 +52,6 @@ public void start(Stage stage) throws Exception { state.addListener(new ChangeListener(){ @Override public void changed(ObservableValue observable, String oldValue, String newValue) { - System.out.println(newValue); if(newValue.equals("autoPlayNext")){ // playNext(); if(currentIndex==nowPlaying.size()-1){ @@ -98,16 +97,32 @@ public static void playNext(){ else{ currentIndex++; BBSong song = nowPlaying.get(currentIndex); - System.out.println(song); play(song); } } + + private static double getvolumevalue(String genre) { + double volume; + if (genre.contains("Dance") || genre.contains("Party") || genre.contains("Rock") || genre.contains("Metal") || genre.contains("Progressive House")) { + volume = 1.0; + } else if (genre.contains("Pop") || genre.contains("Electro") || genre.contains("Techno") || genre.contains("Edm") || genre.contains("Hip hop") || genre.contains("Hip-hop") || genre.contains("Trap")) { + volume = 0.05; + } else if (genre.contains("Romantic") || genre.contains("Soothing") || genre.contains("Soul") || genre.contains("Piano") || genre.contains("Tropical House") || genre.contains("Ambient")) { + volume = 0.02; + } else if (genre.contains("Bollywood")) { + volume = 0.1; + } else { + volume = 0.3; + } + return volume; + } + public static void play(BBSong track){ mediaPlayer.dispose(); mediaPlayer = toMediaPlayer(track.getLocation()); initMediaPlayer(); currentIndex = BBGenerator.find(nowPlaying, track); - System.out.println("cI=" + currentIndex + track + " " + track.isFavourite()); + mediaPlayer.setVolume(getvolumevalue(track.getGenre())); mediaPlayer.play(); } public static void initMediaPlayer(){ @@ -161,4 +176,4 @@ public static void main(String[] args) { System.exit(0); } -} \ No newline at end of file +}