diff --git a/KDE_Dialog_Appear.wav b/KDE_Dialog_Appear.wav new file mode 100644 index 0000000..1f7e377 Binary files /dev/null and b/KDE_Dialog_Appear.wav differ diff --git a/TimelineWindowUpdater.java b/TimelineWindowUpdater.java index 84fec0d..24ea560 100755 --- a/TimelineWindowUpdater.java +++ b/TimelineWindowUpdater.java @@ -3,6 +3,12 @@ import java.util.List; import java.util.ArrayList; import java.io.IOException; import cafe.biskuteri.hinoki.Tree; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.UnsupportedAudioFileException; +import javax.sound.sampled.LineUnavailableException; +import java.net.URL; class TimelineWindowUpdater { @@ -21,6 +27,9 @@ TimelineWindowUpdater { private StringBuilder event, data; + private Clip + notificationSound; + // - -%- - private Thread @@ -74,6 +83,12 @@ TimelineWindowUpdater { for (TimelineWindow updatee: filter(type)) { updatee.showLatestPage(); } + + if (newNotif) + { + notificationSound.setFramePosition(0); + notificationSound.start(); + } } private List @@ -117,7 +132,8 @@ TimelineWindowUpdater { { if (line.startsWith(":")) return; - if (line.isEmpty()) { + if (line.isEmpty()) + { handle(type, event.toString(), data.toString()); event.delete(0, event.length()); data.delete(0, event.length()); @@ -160,6 +176,31 @@ TimelineWindowUpdater { this.api = primaire.getMastodonApi(); this.updatees = new ArrayList<>(); + + loadNotificationSound(); } + void + loadNotificationSound() + { + URL url = getClass().getResource("KDE_Dialog_Appear.wav"); + try { + Clip clip = AudioSystem.getClip(); + clip.open(AudioSystem.getAudioInputStream(url)); + notificationSound = clip; + } + catch (LineUnavailableException eLu) { + assert false; + } + catch (UnsupportedAudioFileException eUa) { + assert false; + } + catch (IOException eIo) { + assert false; + } + catch (IllegalArgumentException eIa) { + assert false; + } + } + }