mirror of
https://gitlab.com/biskuteri-cafe/JKomasto2.git
synced 2024-11-20 08:34:49 +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.util.ArrayList;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import cafe.biskuteri.hinoki.Tree;
|
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
|
class
|
||||||
TimelineWindowUpdater {
|
TimelineWindowUpdater {
|
||||||
@ -21,6 +27,9 @@ TimelineWindowUpdater {
|
|||||||
private StringBuilder
|
private StringBuilder
|
||||||
event, data;
|
event, data;
|
||||||
|
|
||||||
|
private Clip
|
||||||
|
notificationSound;
|
||||||
|
|
||||||
// - -%- -
|
// - -%- -
|
||||||
|
|
||||||
private Thread
|
private Thread
|
||||||
@ -74,6 +83,12 @@ TimelineWindowUpdater {
|
|||||||
for (TimelineWindow updatee: filter(type)) {
|
for (TimelineWindow updatee: filter(type)) {
|
||||||
updatee.showLatestPage();
|
updatee.showLatestPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newNotif)
|
||||||
|
{
|
||||||
|
notificationSound.setFramePosition(0);
|
||||||
|
notificationSound.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TimelineWindow>
|
private List<TimelineWindow>
|
||||||
@ -117,7 +132,8 @@ TimelineWindowUpdater {
|
|||||||
{
|
{
|
||||||
if (line.startsWith(":")) return;
|
if (line.startsWith(":")) return;
|
||||||
|
|
||||||
if (line.isEmpty()) {
|
if (line.isEmpty())
|
||||||
|
{
|
||||||
handle(type, event.toString(), data.toString());
|
handle(type, event.toString(), data.toString());
|
||||||
event.delete(0, event.length());
|
event.delete(0, event.length());
|
||||||
data.delete(0, event.length());
|
data.delete(0, event.length());
|
||||||
@ -160,6 +176,31 @@ TimelineWindowUpdater {
|
|||||||
this.api = primaire.getMastodonApi();
|
this.api = primaire.getMastodonApi();
|
||||||
|
|
||||||
this.updatees = new ArrayList<>();
|
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