mirror of
https://gitlab.com/biskuteri-cafe/JKomasto2.git
synced 2024-11-20 06:24:50 +01:00
Added notification sound
This commit is contained in:
parent
9c75464b18
commit
648d36ad4c
BIN
KDE_Dialog_Appear.wav
Normal file
BIN
KDE_Dialog_Appear.wav
Normal file
Binary file not shown.
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user