Added notification sound

This commit is contained in:
Snowyfox 2022-04-29 14:22:55 -04:00
parent 9c75464b18
commit 648d36ad4c
2 changed files with 42 additions and 1 deletions

BIN
KDE_Dialog_Appear.wav Normal file

Binary file not shown.

View File

@ -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<TimelineWindow>
@ -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;
}
}
}