added audio support

This commit is contained in:
Marc Froehlich
2024-01-16 22:49:28 +01:00
parent d57880d945
commit c2086a73b0
99 changed files with 928 additions and 19 deletions

BIN
LTTR0.mp3 Normal file

Binary file not shown.

BIN
LTTR1.mp3 Normal file

Binary file not shown.

BIN
LTTR2.mp3 Normal file

Binary file not shown.

BIN
LTTR3.mp3 Normal file

Binary file not shown.

BIN
LTTR4.mp3 Normal file

Binary file not shown.

BIN
LTTR5.mp3 Normal file

Binary file not shown.

BIN
LTTR6.mp3 Normal file

Binary file not shown.

BIN
LTTR7.mp3 Normal file

Binary file not shown.

BIN
LTTR8.mp3 Normal file

Binary file not shown.

BIN
LTTR9.mp3 Normal file

Binary file not shown.

BIN
LTTRA.mp3 Normal file

Binary file not shown.

BIN
LTTRB.mp3 Normal file

Binary file not shown.

BIN
LTTRC.mp3 Normal file

Binary file not shown.

BIN
LTTRD.mp3 Normal file

Binary file not shown.

BIN
LTTRE.mp3 Normal file

Binary file not shown.

BIN
LTTRF.mp3 Normal file

Binary file not shown.

BIN
LTTRG.mp3 Normal file

Binary file not shown.

BIN
LTTRH.mp3 Normal file

Binary file not shown.

BIN
LTTRI.mp3 Normal file

Binary file not shown.

BIN
LTTRJ.mp3 Normal file

Binary file not shown.

BIN
LTTRK.mp3 Normal file

Binary file not shown.

BIN
LTTRL.mp3 Normal file

Binary file not shown.

BIN
LTTRM.mp3 Normal file

Binary file not shown.

BIN
LTTRMINUS.mp3 Normal file

Binary file not shown.

BIN
LTTRN.mp3 Normal file

Binary file not shown.

BIN
LTTRO.mp3 Normal file

Binary file not shown.

BIN
LTTRP.mp3 Normal file

Binary file not shown.

BIN
LTTRPOINT.mp3 Normal file

Binary file not shown.

BIN
LTTRQ.mp3 Normal file

Binary file not shown.

BIN
LTTRQUESTMARK.mp3 Normal file

Binary file not shown.

BIN
LTTRR.mp3 Normal file

Binary file not shown.

BIN
LTTRS.mp3 Normal file

Binary file not shown.

BIN
LTTRSPACE.mp3 Normal file

Binary file not shown.

BIN
LTTRSTROKE.mp3 Normal file

Binary file not shown.

BIN
LTTRT.mp3 Normal file

Binary file not shown.

BIN
LTTRU.mp3 Normal file

Binary file not shown.

BIN
LTTRV.mp3 Normal file

Binary file not shown.

BIN
LTTRW.mp3 Normal file

Binary file not shown.

BIN
LTTRX.mp3 Normal file

Binary file not shown.

BIN
LTTRY.mp3 Normal file

Binary file not shown.

BIN
LTTRZ.mp3 Normal file

Binary file not shown.

BIN
NOISECQWINDOW.mp3 Normal file

Binary file not shown.

BIN
NOISEERROR.mp3 Normal file

Binary file not shown.

BIN
NOISENOTIFY.mp3 Normal file

Binary file not shown.

BIN
NOISEPMWINDOW.mp3 Normal file

Binary file not shown.

BIN
NOISESTARTUP.mp3 Normal file

Binary file not shown.

Binary file not shown.

BIN
VOICE0.mp3 Normal file

Binary file not shown.

BIN
VOICE1.mp3 Normal file

Binary file not shown.

BIN
VOICE2.mp3 Normal file

Binary file not shown.

BIN
VOICE3.mp3 Normal file

Binary file not shown.

BIN
VOICE4.mp3 Normal file

Binary file not shown.

BIN
VOICE5.mp3 Normal file

Binary file not shown.

BIN
VOICE6.mp3 Normal file

Binary file not shown.

BIN
VOICE7.mp3 Normal file

Binary file not shown.

BIN
VOICE73.mp3 Normal file

Binary file not shown.

BIN
VOICE8.mp3 Normal file

Binary file not shown.

BIN
VOICE9.mp3 Normal file

Binary file not shown.

BIN
VOICEA.mp3 Normal file

Binary file not shown.

BIN
VOICEB.mp3 Normal file

Binary file not shown.

BIN
VOICEBELL.mp3 Normal file

Binary file not shown.

BIN
VOICEC.mp3 Normal file

Binary file not shown.

BIN
VOICED.mp3 Normal file

Binary file not shown.

BIN
VOICEE.mp3 Normal file

Binary file not shown.

BIN
VOICEF.mp3 Normal file

Binary file not shown.

BIN
VOICEG.mp3 Normal file

Binary file not shown.

BIN
VOICEH.mp3 Normal file

Binary file not shown.

BIN
VOICEHELLO.mp3 Normal file

Binary file not shown.

BIN
VOICEI.mp3 Normal file

Binary file not shown.

BIN
VOICEJ.mp3 Normal file

Binary file not shown.

BIN
VOICEK.mp3 Normal file

Binary file not shown.

BIN
VOICEL.mp3 Normal file

Binary file not shown.

BIN
VOICEM.mp3 Normal file

Binary file not shown.

BIN
VOICEMEEPMEEP.mp3 Normal file

Binary file not shown.

BIN
VOICEN.mp3 Normal file

Binary file not shown.

BIN
VOICEO.mp3 Normal file

Binary file not shown.

BIN
VOICEP.mp3 Normal file

Binary file not shown.

BIN
VOICEQ.mp3 Normal file

Binary file not shown.

BIN
VOICER.mp3 Normal file

Binary file not shown.

BIN
VOICES.mp3 Normal file

Binary file not shown.

BIN
VOICESTROKE.mp3 Normal file

Binary file not shown.

BIN
VOICESTROKEPORTABLE.mp3 Normal file

Binary file not shown.

BIN
VOICET.mp3 Normal file

Binary file not shown.

BIN
VOICEU.mp3 Normal file

Binary file not shown.

BIN
VOICEV.mp3 Normal file

Binary file not shown.

BIN
VOICEW.mp3 Normal file

Binary file not shown.

BIN
VOICEX.mp3 Normal file

Binary file not shown.

BIN
VOICEY.mp3 Normal file

Binary file not shown.

BIN
VOICEYOUGOTMAIL.mp3 Normal file

Binary file not shown.

BIN
VOICEZ.mp3 Normal file

Binary file not shown.

3
jdk.cmd Normal file
View File

@@ -0,0 +1,3 @@
@echo off
SET JAVA_HOME=C:\Program Files\Java\jdk-17
SET PATH=%JAVA_HOME%\bin,%PATH%

BIN
sk.mp3 Normal file

Binary file not shown.

View File

@@ -18,6 +18,7 @@ import kst4contest.model.ChatMember;
import kst4contest.model.ChatMessage; import kst4contest.model.ChatMessage;
import kst4contest.model.ChatPreferences; import kst4contest.model.ChatPreferences;
import kst4contest.model.ClusterMessage; import kst4contest.model.ClusterMessage;
import kst4contest.utils.PlayAudioUtils;
import java.io.*; import java.io.*;
@@ -232,6 +233,12 @@ public class ChatController {
private MessageBusManagementThread messageProcessor; private MessageBusManagementThread messageProcessor;
private ReadUDPbyAirScoutMessageThread airScoutUDPReaderThread; private ReadUDPbyAirScoutMessageThread airScoutUDPReaderThread;
private PlayAudioUtils playAudioUtils = new PlayAudioUtils();
public PlayAudioUtils getPlayAudioUtils() {
return playAudioUtils;
}
private TimerTask userActualizationTask; private TimerTask userActualizationTask;
private TimerTask keepAliveMessageSenderTask; private TimerTask keepAliveMessageSenderTask;

View File

@@ -15,6 +15,7 @@ import kst4contest.model.AirPlaneReflectionInfo;
import kst4contest.model.ChatMember; import kst4contest.model.ChatMember;
import kst4contest.model.ChatMessage; import kst4contest.model.ChatMessage;
import kst4contest.model.ClusterMessage; import kst4contest.model.ClusterMessage;
import kst4contest.utils.PlayAudioUtils;
/** /**
* *
@@ -544,14 +545,30 @@ public class MessageBusManagementThread extends Thread {
// System.out.println("message directed to: " + newMessage.getReceiver().getCallSign() + ". EQ?: " + this.client.getownChatMemberObject().getCallSign() + " sent by: " + newMessage.getSender().getCallSign().toUpperCase() + " -> EQ?: "+ this.client.getChatPreferences().getLoginCallSign().toUpperCase()); // System.out.println("message directed to: " + newMessage.getReceiver().getCallSign() + ". EQ?: " + this.client.getownChatMemberObject().getCallSign() + " sent by: " + newMessage.getSender().getCallSign().toUpperCase() + " -> EQ?: "+ this.client.getChatPreferences().getLoginCallSign().toUpperCase());
try { try {
/**
* message is directed to me, will be put in the "to me" messagelist
*/
if (newMessage.getReceiver().getCallSign() if (newMessage.getReceiver().getCallSign()
.equals(this.client.getChatPreferences().getLoginCallSign())) { .equals(this.client.getChatPreferences().getLoginCallSign())) {
this.client.getLst_toMeMessageList().add(0, newMessage); this.client.getLst_toMeMessageList().add(0, newMessage);
if (this.client.getChatPreferences().isNotify_playSimpleSounds()) {
this.client.getPlayAudioUtils().playNoiseLauncher('P');
}
if (this.client.getChatPreferences().isNotify_playCWCallsignsOnRxedPMs()) {
this.client.getPlayAudioUtils().playCWLauncher(" " + " " + newMessage.getSender().getCallSign().toUpperCase());
}
if (this.client.getChatPreferences().isNotify_playVoiceCallsignsOnRxedPMs()) {
this.client.getPlayAudioUtils().playVoiceLauncher( "?" + newMessage.getSender().getCallSign().toUpperCase());
}
System.out.println("message directed to me: " + newMessage.getReceiver().getCallSign() + "."); System.out.println("message directed to me: " + newMessage.getReceiver().getCallSign() + ".");
} else if (newMessage.getSender().getCallSign().toUpperCase() } else if (newMessage.getSender().getCallSign().toUpperCase()
/**
* message from me will appear in the PM window, too, with (>CALLSIGN) before
*/
.equals(this.client.getChatPreferences().getLoginCallSign().toUpperCase())) { .equals(this.client.getChatPreferences().getLoginCallSign().toUpperCase())) {
String originalMessage = newMessage.getMessageText(); String originalMessage = newMessage.getMessageText();
newMessage newMessage
@@ -566,7 +583,7 @@ public class MessageBusManagementThread extends Thread {
// System.out.println("MSGBS bgfx: tx call = " + newMessage.getSender().getCallSign() + " / rx call = " + newMessage.getReceiver().getCallSign()); // System.out.println("MSGBS bgfx: tx call = " + newMessage.getSender().getCallSign() + " / rx call = " + newMessage.getReceiver().getCallSign());
} }
} catch (NullPointerException referenceDeletedByUserLeftChatDuringMessageprocessing) { } catch (NullPointerException referenceDeletedByUserLeftChatDuringMessageprocessing) {
System.out.println("MSGBS bgfx, catched error: referenced user left the chat during messageprocessing: "); System.out.println("MSGBS bgfx, <<<catched error>>>: referenced user left the chat during messageprocessing: ");
referenceDeletedByUserLeftChatDuringMessageprocessing.printStackTrace(); referenceDeletedByUserLeftChatDuringMessageprocessing.printStackTrace();
} }

View File

@@ -164,6 +164,13 @@ public class ChatPreferences {
* Notification prefs * Notification prefs
*/ */
//Audio section
boolean notify_playSimpleSounds = true;
boolean notify_playCWCallsignsOnRxedPMs = true;
boolean notify_playVoiceCallsignsOnRxedPMs = true;
/** /**
* Shortcuts and Textsnippets prefs * Shortcuts and Textsnippets prefs
*/ */
@@ -198,6 +205,8 @@ public class ChatPreferences {
// MYQRG = mYQRG; // MYQRG = mYQRG;
// } // }
public String getLoginCallSign() { public String getLoginCallSign() {
return loginCallSign; return loginCallSign;
} }
@@ -267,6 +276,30 @@ public class ChatPreferences {
this.logsynch_storeWorkedCallSignsFileNameUDPMessageBackup = logsynch_storeWorkedCallSignsFileNameUDPMessageBackup; this.logsynch_storeWorkedCallSignsFileNameUDPMessageBackup = logsynch_storeWorkedCallSignsFileNameUDPMessageBackup;
} }
public boolean isNotify_playSimpleSounds() {
return notify_playSimpleSounds;
}
public boolean isNotify_playCWCallsignsOnRxedPMs() {
return notify_playCWCallsignsOnRxedPMs;
}
public boolean isNotify_playVoiceCallsignsOnRxedPMs() {
return notify_playVoiceCallsignsOnRxedPMs;
}
public void setNotify_playSimpleSounds(boolean notify_playSimpleSounds) {
this.notify_playSimpleSounds = notify_playSimpleSounds;
}
public void setNotify_playCWCallsignsOnRxedPMs(boolean notify_playCWCallsignsOnRxedPMs) {
this.notify_playCWCallsignsOnRxedPMs = notify_playCWCallsignsOnRxedPMs;
}
public void setNotify_playVoiceCallsignsOnRxedPMs(boolean notify_playVoiceCallsignsOnRxedPMs) {
this.notify_playVoiceCallsignsOnRxedPMs = notify_playVoiceCallsignsOnRxedPMs;
}
/** /**
* actualQTF, int, QTF in degrees * actualQTF, int, QTF in degrees
* *
@@ -603,6 +636,27 @@ public class ChatPreferences {
asQry_airScoutBandValue.setTextContent(this.getAirScout_asBandString()); asQry_airScoutBandValue.setTextContent(this.getAirScout_asBandString());
AirScoutQuerier.appendChild(asQry_airScoutBandValue); AirScoutQuerier.appendChild(asQry_airScoutBandValue);
/**
* Notifications
*/
Element notifications = doc.createElement("notifications");
rootElement.appendChild(notifications);
Element notify_SimpleAudioNotificationsEnabled = doc.createElement("notify_SimpleAudioNotificationsEnabled");
notify_SimpleAudioNotificationsEnabled.setTextContent(this.isNotify_playSimpleSounds()+"");
notifications.appendChild(notify_SimpleAudioNotificationsEnabled);
Element notify_CWCallSignAudioNotificationsEnabled = doc.createElement("notify_CWCallsignAudioNotificationsEnabled");
notify_CWCallSignAudioNotificationsEnabled.setTextContent(this.isNotify_playCWCallsignsOnRxedPMs()+"");
notifications.appendChild(notify_CWCallSignAudioNotificationsEnabled);
Element notify_VoiceCallSignAudioNotificationsEnabled = doc.createElement("notify_VoiceCallsignAudioNotificationsEnabled");
notify_VoiceCallSignAudioNotificationsEnabled.setTextContent(this.isNotify_playVoiceCallsignsOnRxedPMs()+"");
notifications.appendChild(notify_VoiceCallSignAudioNotificationsEnabled);
/** /**
* Shortcuts * Shortcuts
*/ */
@@ -905,6 +959,56 @@ public class ChatPreferences {
} }
} }
/**
* Case notifications
*/
list = doc.getElementsByTagName("notifications");
if (list.getLength() != 0) {
for (int temp = 0; temp < list.getLength(); temp++) {
Node node = list.item(temp);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
String notify_simpleAudioNotificationsEnabled = element.getElementsByTagName("notify_SimpleAudioNotificationsEnabled").item(0)
.getTextContent();
if (notify_simpleAudioNotificationsEnabled.equals("true")) {
notify_playSimpleSounds = true;
} else {
notify_playSimpleSounds = false;
}
String notify_cwAudioNotificationsEnabled = element.getElementsByTagName("notify_CWCallsignAudioNotificationsEnabled").item(0)
.getTextContent();
if (notify_cwAudioNotificationsEnabled.equals("true")) {
notify_playCWCallsignsOnRxedPMs = true;
} else {
notify_playCWCallsignsOnRxedPMs = false;
}
String notify_voiceAudioNotificationsEnabled = element.getElementsByTagName("notify_VoiceCallsignAudioNotificationsEnabled").item(0)
.getTextContent();
if (notify_voiceAudioNotificationsEnabled.equals("true")) {
notify_playVoiceCallsignsOnRxedPMs = true;
} else {
notify_playVoiceCallsignsOnRxedPMs = false;
}
System.out.println(
"[ChatPreferences, info]: Set the audionotifications simple: " + notify_playSimpleSounds + ", CW: " + notify_playCWCallsignsOnRxedPMs + ", Voice: " + notify_playVoiceCallsignsOnRxedPMs);
}
}
}
/** /**
* Case AirScout querier * Case AirScout querier
*/ */

View File

@@ -0,0 +1,395 @@
package kst4contest.utils;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import java.io.File;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
/**
* This part of the client drives the sounds. Its a singleton instance. All audio outs are directed to this instance.<br>
* <br>
* Instance of this classes will use the audio-notification-settings of the ChatPreferences instance and then wheter
* play a sound or not. Each method of this class will only cause an audio output if the settings for audio-out are
* made. This is good for less typing work. If audio is switched off by the user, all audio out callings will do: <br/>
* <b>nothing</b>.
*
*/
public class PlayAudioUtils {
// public boolean useNormalProgramSounds, useCWCallSignSounds, useVoiceCallSignSounds;
// public void setUseNormalProgramSounds(boolean useNormalProgramSounds) {
// this.useNormalProgramSounds = useNormalProgramSounds;
// }
//
// public void setUseCWCallSignSounds(boolean useCWCallSignSounds) {
// this.useCWCallSignSounds = useCWCallSignSounds;
// }
//
// public void setUseVoiceCallSignSounds(boolean useVoiceCallSignSounds) {
// this.useVoiceCallSignSounds = useVoiceCallSignSounds;
// }
private Queue<Media> musicList = new LinkedList<Media>();
private MediaPlayer mediaPlayer ;
/**
* Plays notification sounds out of the windws 95 box by given action character<br/>
*<br/>
* <b>Note that the audio settings (ChatPreferences) must be switched on in order to make the sounds playing.</b><br/>
* case '!': Startup<br/>
* case 'C': CQ Window new entry<br/>
* case 'P': PM Window new entry<br/>
* case 'E': Error occured<br/>
* case 'N': other notification sounds<br/>
*
* @param actionChar
*/
public void playNoiseLauncher(char actionChar) {
switch (actionChar){
case '!':
musicList.add(new Media(new File ("NOISESTARTUP.mp3").toURI().toString()));
break;
case 'C':
musicList.add(new Media(new File ("NOISECQWINDOW.mp3").toURI().toString()));
break;
case 'P':
musicList.add(new Media(new File ("NOISEPMWINDOW.mp3").toURI().toString()));
break;
case 'E':
musicList.add(new Media(new File ("NOISEERROR.mp3").toURI().toString()));
break;
case 'N':
musicList.add(new Media(new File ("NOISENOTIFY.mp3").toURI().toString()));
break;
// case 'M':
// musicList.add(new Media(new File ("VOICE.mp3").toURI().toString()));
// break;
default:
System.out.println("[KST4ContestApp, warning, letter not defined!]");
}
playMusic();
// mediaPlayer.dispose();
}
/**
* Plays all chars of a given String-parameter as CW Sound out of the speaker.
* As a workaround for delay problems at the beginning of playing, there are added 2x pause chars to the string.
* <b>Note that the audio settings (ChatPreferences) must be switched on in order to make the sounds playing.</b><br/>
* @param playThisChars
*/
public void playCWLauncher(String playThisChars) {
char[] playThisInCW = playThisChars.toUpperCase().toCharArray();
for (char letterToPlay: playThisInCW){
switch (letterToPlay){
case 'A':
musicList.add(new Media(new File("LTTRA.mp3").toURI().toString()));
break;
case 'B':
musicList.add(new Media(new File ("LTTRB.mp3").toURI().toString()));
break;
case 'C':
musicList.add(new Media(new File ("LTTRC.mp3").toURI().toString()));
break;
case 'D':
musicList.add(new Media(new File ("LTTRD.mp3").toURI().toString()));
break;
case 'E':
musicList.add(new Media(new File ("LTTRE.mp3").toURI().toString()));
break;
case 'F':
musicList.add(new Media(new File ("LTTRF.mp3").toURI().toString()));
break;
case 'G':
musicList.add(new Media(new File ("LTTRG.mp3").toURI().toString()));
break;
case 'H':
musicList.add(new Media(new File ("LTTRH.mp3").toURI().toString()));
break;
case 'I':
musicList.add(new Media(new File ("LTTRI.mp3").toURI().toString()));
break;
case 'J':
musicList.add(new Media(new File ("LTTRJ.mp3").toURI().toString()));
break;
case 'K':
musicList.add(new Media(new File ("LTTRK.mp3").toURI().toString()));
break;
case 'L':
musicList.add(new Media(new File ("LTTRL.mp3").toURI().toString()));
break;
case 'M':
musicList.add(new Media(new File ("LTTRM.mp3").toURI().toString()));
break;
case 'N':
musicList.add(new Media(new File ("LTTRN.mp3").toURI().toString()));
break;
case 'O':
musicList.add(new Media(new File ("LTTRO.mp3").toURI().toString()));
break;
case 'P':
musicList.add(new Media(new File ("LTTRP.mp3").toURI().toString()));
break;
case 'Q':
musicList.add(new Media(new File ("LTTRQ.mp3").toURI().toString()));
break;
case 'R':
musicList.add(new Media(new File ("LTTRR.mp3").toURI().toString()));
break;
case 'S':
musicList.add(new Media(new File ("LTTRS.mp3").toURI().toString()));
break;
case 'T':
musicList.add(new Media(new File ("LTTRT.mp3").toURI().toString()));
break;
case 'U':
musicList.add(new Media(new File ("LTTRU.mp3").toURI().toString()));
break;
case 'V':
musicList.add(new Media(new File ("LTTRV.mp3").toURI().toString()));
break;
case 'W':
musicList.add(new Media(new File ("LTTRW.mp3").toURI().toString()));
break;
case 'X':
musicList.add(new Media(new File ("LTTRX.mp3").toURI().toString()));
break;
case 'Y':
musicList.add(new Media(new File ("LTTRY.mp3").toURI().toString()));
break;
case 'Z':
musicList.add(new Media(new File ("LTTRZ.mp3").toURI().toString()));
break;
case '1':
musicList.add(new Media(new File ("LTTR1.mp3").toURI().toString()));
break;
case '2':
musicList.add(new Media(new File ("LTTR2.mp3").toURI().toString()));
break;
case '3':
musicList.add(new Media(new File ("LTTR3.mp3").toURI().toString()));
break;
case '4':
musicList.add(new Media(new File ("LTTR4.mp3").toURI().toString()));
break;
case '5':
musicList.add(new Media(new File ("LTTR5.mp3").toURI().toString()));
break;
case '6':
musicList.add(new Media(new File ("LTTR6.mp3").toURI().toString()));
break;
case '7':
musicList.add(new Media(new File ("LTTR7.mp3").toURI().toString()));
break;
case '8':
musicList.add(new Media(new File ("LTTR8.mp3").toURI().toString()));
break;
case '9':
musicList.add(new Media(new File ("LTTR9.mp3").toURI().toString()));
break;
case '0':
musicList.add(new Media(new File ("LTTR0.mp3").toURI().toString()));
break;
case '/':
musicList.add(new Media(new File ("LTTRSTROKE.mp3").toURI().toString()));
break;
case ' ':
musicList.add(new Media(new File ("LTTRSPACE.mp3").toURI().toString()));
break;
default:
System.out.println("[KST4ContestApp, warning, letter not defined:] cwLetters = " + Arrays.toString(playThisInCW));
}
}
playMusic();
// mediaPlayer.dispose();
}
/**
*
* Plays a voice file for each char in the string (only EN alphabetic and numbers) except some specials: <br/><br/>
* <b>Note that the audio settings (ChatPreferences) must be switched on in order to make the sounds playing.</b><br/><br/>
* case '!': BELL<br/>
* case '?': YOUGOTMAIL<br/>
* case '#': HELLO<br/>
* case '*': 73 bye<br/>
* case '$': STROKEPORTABLE<br/>
* @param playThisChars
*/
public void playVoiceLauncher(String playThisChars) {
char[] playThisInCW = playThisChars.toUpperCase().toCharArray();
for (char letterToPlay: playThisInCW){
switch (letterToPlay){
case '!':
musicList.add(new Media(new File ("VOICEBELL.mp3").toURI().toString()));
break;
case '?':
musicList.add(new Media(new File ("VOICEYOUGOTMAIL.mp3").toURI().toString()));
break;
case '#':
musicList.add(new Media(new File ("VOICEHELLO.mp3").toURI().toString()));
break;
case '*':
musicList.add(new Media(new File ("VOICE73.mp3").toURI().toString()));
break;
case '$':
musicList.add(new Media(new File ("VOICESTROKEPORTABLE.mp3").toURI().toString()));
break;
case 'A':
musicList.add(new Media(new File ("VOICEA.mp3").toURI().toString()));
break;
case 'B':
musicList.add(new Media(new File ("VOICEB.mp3").toURI().toString()));
break;
case 'C':
musicList.add(new Media(new File ("VOICEC.mp3").toURI().toString()));
break;
case 'D':
musicList.add(new Media(new File ("VOICED.mp3").toURI().toString()));
break;
case 'E':
musicList.add(new Media(new File ("VOICEE.mp3").toURI().toString()));
break;
case 'F':
musicList.add(new Media(new File ("VOICEF.mp3").toURI().toString()));
break;
case 'G':
musicList.add(new Media(new File ("VOICEG.mp3").toURI().toString()));
break;
case 'H':
musicList.add(new Media(new File ("VOICEH.mp3").toURI().toString()));
break;
case 'I':
musicList.add(new Media(new File ("VOICEI.mp3").toURI().toString()));
break;
case 'J':
musicList.add(new Media(new File ("VOICEJ.mp3").toURI().toString()));
break;
case 'K':
musicList.add(new Media(new File ("VOICEK.mp3").toURI().toString()));
break;
case 'L':
musicList.add(new Media(new File ("VOICEL.mp3").toURI().toString()));
break;
case 'M':
musicList.add(new Media(new File ("VOICEM.mp3").toURI().toString()));
break;
case 'N':
musicList.add(new Media(new File ("VOICEN.mp3").toURI().toString()));
break;
case 'O':
musicList.add(new Media(new File ("VOICEO.mp3").toURI().toString()));
break;
case 'P':
musicList.add(new Media(new File ("VOICEP.mp3").toURI().toString()));
break;
case 'Q':
musicList.add(new Media(new File ("VOICEQ.mp3").toURI().toString()));
break;
case 'R':
musicList.add(new Media(new File ("VOICER.mp3").toURI().toString()));
break;
case 'S':
musicList.add(new Media(new File ("VOICES.mp3").toURI().toString()));
break;
case 'T':
musicList.add(new Media(new File ("VOICET.mp3").toURI().toString()));
break;
case 'U':
musicList.add(new Media(new File ("VOICEU.mp3").toURI().toString()));
break;
case 'V':
musicList.add(new Media(new File ("VOICEV.mp3").toURI().toString()));
break;
case 'W':
musicList.add(new Media(new File ("VOICEW.mp3").toURI().toString()));
break;
case 'X':
musicList.add(new Media(new File ("VOICEX.mp3").toURI().toString()));
break;
case 'Y':
musicList.add(new Media(new File ("VOICEY.mp3").toURI().toString()));
break;
case 'Z':
musicList.add(new Media(new File ("VOICEZ.mp3").toURI().toString()));
break;
case '1':
musicList.add(new Media(new File ("VOICE1.mp3").toURI().toString()));
break;
case '2':
musicList.add(new Media(new File ("VOICE2.mp3").toURI().toString()));
break;
case '3':
musicList.add(new Media(new File ("VOICE3.mp3").toURI().toString()));
break;
case '4':
musicList.add(new Media(new File ("VOICE4.mp3").toURI().toString()));
break;
case '5':
musicList.add(new Media(new File ("VOICE5.mp3").toURI().toString()));
break;
case '6':
musicList.add(new Media(new File ("VOICE6.mp3").toURI().toString()));
break;
case '7':
musicList.add(new Media(new File ("VOICE7.mp3").toURI().toString()));
break;
case '8':
musicList.add(new Media(new File ("VOICE8.mp3").toURI().toString()));
break;
case '9':
musicList.add(new Media(new File ("VOICE9.mp3").toURI().toString()));
break;
case '0':
musicList.add(new Media(new File ("VOICE0.mp3").toURI().toString()));
break;
case '/':
musicList.add(new Media(new File ("VOICESTROKE.mp3").toURI().toString()));
break;
// case ' ':
// musicList.add(new Media(new File ("VOICESPACE.mp3").toURI().toString()));
// break;
default:
System.out.println("[KST4ContestApp, warning, letter not defined:] cwLetters = " + Arrays.toString(playThisInCW));
}
}
playMusic();
// mediaPlayer.dispose();
}
private void playMusic() {
// System.out.println("Kst4ContestApplication.playMusic");
if(musicList.peek() == null)
{
return;
}
mediaPlayer = new MediaPlayer(musicList.poll());
mediaPlayer.setRate(1.0);
mediaPlayer.setOnReady(() -> {
mediaPlayer.play();
mediaPlayer.setOnEndOfMedia(() -> {
// mediaPlayer.dispose();
playMusic();
if (musicList.isEmpty()) {
// mediaPlayer.dispose();
}
});
});
}
}

View File

@@ -2,12 +2,13 @@ package kst4contest.view;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Date; import java.net.URI;
import java.util.Iterator; import java.net.URISyntaxException;
import java.util.Optional; import java.nio.file.Path;
import java.util.Timer; import java.util.*;
import java.util.TimerTask;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import kst4contest.controller.ChatController; import kst4contest.controller.ChatController;
import kst4contest.controller.Utils4KST; import kst4contest.controller.Utils4KST;
import javafx.application.Application; import javafx.application.Application;
@@ -71,6 +72,8 @@ import kst4contest.model.ChatCategory;
import kst4contest.model.ChatMember; import kst4contest.model.ChatMember;
import kst4contest.model.ChatMessage; import kst4contest.model.ChatMessage;
import kst4contest.model.ClusterMessage; import kst4contest.model.ClusterMessage;
import kst4contest.utils.PlayAudioUtils;
public class Kst4ContestApplication extends Application { public class Kst4ContestApplication extends Application {
@@ -740,8 +743,6 @@ public class Kst4ContestApplication extends Application {
if (item.contains(chatcontroller.getChatPreferences().getLoginCallSign())) { if (item.contains(chatcontroller.getChatPreferences().getLoginCallSign())) {
this.setTextFill(Color.GREEN); this.setTextFill(Color.GREEN);
// AudioClip sound = new AudioClip(getClass().getResource("/K.mp3").toExternalForm());
// sound.play();
} }
setText(item); setText(item);
@@ -882,12 +883,18 @@ public class Kst4ContestApplication extends Application {
if (!isEmpty()) { if (!isEmpty()) {
this.setTextFill(Color.BLACK); this.setTextFill(Color.BLACK);
// Get fancy and change color based on data // Get fancy and change color based on data
if (item.contains("100%")) {
this.setTextFill(Color.BLUEVIOLET); try {
} else if (item.contains("75%") && !item.contains("100%")) { if (item.contains("100%")) {
this.setTextFill(Color.RED); this.setTextFill(Color.BLUEVIOLET);
} else if (item.contains("50%") && ((!item.contains("100%")) || (!item.contains("75%")))) { } else if (item.contains("75%") && !item.contains("100%")) {
this.setTextFill(Color.ORANGE); this.setTextFill(Color.RED);
} else if (item.contains("50%") && ((!item.contains("100%")) || (!item.contains("75%")))) {
this.setTextFill(Color.ORANGE);
}
} catch (Exception exc) {
//TODO: on nullpointerexcteption dont to that
} }
setText(item); setText(item);
@@ -1876,8 +1883,324 @@ public class Kst4ContestApplication extends Application {
} }
private Queue<Media> musicList = new LinkedList<Media>();
private MediaPlayer mediaPlayer ;
private void playCWLauncher(String playThisChars) {
char[] playThisInCW = playThisChars.toUpperCase().toCharArray();
for (char letterToPlay: playThisInCW){
switch (letterToPlay){
case 'A':
musicList.add(new Media(new File ("LTTRA.mp3").toURI().toString()));
break;
case 'B':
musicList.add(new Media(new File ("LTTRB.mp3").toURI().toString()));
break;
case 'C':
musicList.add(new Media(new File ("LTTRC.mp3").toURI().toString()));
break;
case 'D':
musicList.add(new Media(new File ("LTTRD.mp3").toURI().toString()));
break;
case 'E':
musicList.add(new Media(new File ("LTTRE.mp3").toURI().toString()));
break;
case 'F':
musicList.add(new Media(new File ("LTTRF.mp3").toURI().toString()));
break;
case 'G':
musicList.add(new Media(new File ("LTTRG.mp3").toURI().toString()));
break;
case 'H':
musicList.add(new Media(new File ("LTTRH.mp3").toURI().toString()));
break;
case 'I':
musicList.add(new Media(new File ("LTTRI.mp3").toURI().toString()));
break;
case 'J':
musicList.add(new Media(new File ("LTTRJ.mp3").toURI().toString()));
break;
case 'K':
musicList.add(new Media(new File ("LTTRK.mp3").toURI().toString()));
break;
case 'L':
musicList.add(new Media(new File ("LTTRL.mp3").toURI().toString()));
break;
case 'M':
musicList.add(new Media(new File ("LTTRM.mp3").toURI().toString()));
break;
case 'N':
musicList.add(new Media(new File ("LTTRN.mp3").toURI().toString()));
break;
case 'O':
musicList.add(new Media(new File ("LTTRO.mp3").toURI().toString()));
break;
case 'P':
musicList.add(new Media(new File ("LTTRP.mp3").toURI().toString()));
break;
case 'Q':
musicList.add(new Media(new File ("LTTRQ.mp3").toURI().toString()));
break;
case 'R':
musicList.add(new Media(new File ("LTTRR.mp3").toURI().toString()));
break;
case 'S':
musicList.add(new Media(new File ("LTTRS.mp3").toURI().toString()));
break;
case 'T':
musicList.add(new Media(new File ("LTTRT.mp3").toURI().toString()));
break;
case 'U':
musicList.add(new Media(new File ("LTTRU.mp3").toURI().toString()));
break;
case 'V':
musicList.add(new Media(new File ("LTTRV.mp3").toURI().toString()));
break;
case 'W':
musicList.add(new Media(new File ("LTTRW.mp3").toURI().toString()));
break;
case 'X':
musicList.add(new Media(new File ("LTTRX.mp3").toURI().toString()));
break;
case 'Y':
musicList.add(new Media(new File ("LTTRY.mp3").toURI().toString()));
break;
case 'Z':
musicList.add(new Media(new File ("LTTRZ.mp3").toURI().toString()));
break;
case '1':
musicList.add(new Media(new File ("LTTR1.mp3").toURI().toString()));
break;
case '2':
musicList.add(new Media(new File ("LTTR2.mp3").toURI().toString()));
break;
case '3':
musicList.add(new Media(new File ("LTTR3.mp3").toURI().toString()));
break;
case '4':
musicList.add(new Media(new File ("LTTR4.mp3").toURI().toString()));
break;
case '5':
musicList.add(new Media(new File ("LTTR5.mp3").toURI().toString()));
break;
case '6':
musicList.add(new Media(new File ("LTTR6.mp3").toURI().toString()));
break;
case '7':
musicList.add(new Media(new File ("LTTR7.mp3").toURI().toString()));
break;
case '8':
musicList.add(new Media(new File ("LTTR8.mp3").toURI().toString()));
break;
case '9':
musicList.add(new Media(new File ("LTTR9.mp3").toURI().toString()));
break;
case '0':
musicList.add(new Media(new File ("LTTR0.mp3").toURI().toString()));
break;
case '/':
musicList.add(new Media(new File ("LTTRSTROKE.mp3").toURI().toString()));
break;
case ' ':
musicList.add(new Media(new File ("LTTRSPACE.mp3").toURI().toString()));
break;
default:
System.out.println("[KST4ContestApp, warning, letter not defined:] cwLetters = " + Arrays.toString(playThisInCW));
}
}
playMusic();
// mediaPlayer.dispose();
}
/**
* Plays a voice file for each char in the string (only EN alphabetic and numbers) except some specials: <br/><br/>
*
* case '!': BELL<br/>
* case '?': YOUGOTMAIL<br/>
* case '#': HELLO<br/>
* case '*': 73 bye<br/>
* case '$': STROKEPORTABLE<br/>
* @param playThisChars
*/
private void playVoiceLauncher(String playThisChars) {
char[] playThisInCW = playThisChars.toUpperCase().toCharArray();
for (char letterToPlay: playThisInCW){
switch (letterToPlay){
case '!':
musicList.add(new Media(new File ("VOICEBELL.mp3").toURI().toString()));
break;
case '?':
musicList.add(new Media(new File ("VOICEYOUGOTMAIL.mp3").toURI().toString()));
break;
case '#':
musicList.add(new Media(new File ("VOICEHELLO.mp3").toURI().toString()));
break;
case '*':
musicList.add(new Media(new File ("VOICE73.mp3").toURI().toString()));
break;
case '$':
musicList.add(new Media(new File ("VOICESTROKEPORTABLE.mp3").toURI().toString()));
break;
case 'A':
musicList.add(new Media(new File ("VOICEA.mp3").toURI().toString()));
break;
case 'B':
musicList.add(new Media(new File ("VOICEB.mp3").toURI().toString()));
break;
case 'C':
musicList.add(new Media(new File ("VOICEC.mp3").toURI().toString()));
break;
case 'D':
musicList.add(new Media(new File ("VOICED.mp3").toURI().toString()));
break;
case 'E':
musicList.add(new Media(new File ("VOICEE.mp3").toURI().toString()));
break;
case 'F':
musicList.add(new Media(new File ("VOICEF.mp3").toURI().toString()));
break;
case 'G':
musicList.add(new Media(new File ("VOICEG.mp3").toURI().toString()));
break;
case 'H':
musicList.add(new Media(new File ("VOICEH.mp3").toURI().toString()));
break;
case 'I':
musicList.add(new Media(new File ("VOICEI.mp3").toURI().toString()));
break;
case 'J':
musicList.add(new Media(new File ("VOICEJ.mp3").toURI().toString()));
break;
case 'K':
musicList.add(new Media(new File ("VOICEK.mp3").toURI().toString()));
break;
case 'L':
musicList.add(new Media(new File ("VOICEL.mp3").toURI().toString()));
break;
case 'M':
musicList.add(new Media(new File ("VOICEM.mp3").toURI().toString()));
break;
case 'N':
musicList.add(new Media(new File ("VOICEN.mp3").toURI().toString()));
break;
case 'O':
musicList.add(new Media(new File ("VOICEO.mp3").toURI().toString()));
break;
case 'P':
musicList.add(new Media(new File ("VOICEP.mp3").toURI().toString()));
break;
case 'Q':
musicList.add(new Media(new File ("VOICEQ.mp3").toURI().toString()));
break;
case 'R':
musicList.add(new Media(new File ("VOICER.mp3").toURI().toString()));
break;
case 'S':
musicList.add(new Media(new File ("VOICES.mp3").toURI().toString()));
break;
case 'T':
musicList.add(new Media(new File ("VOICET.mp3").toURI().toString()));
break;
case 'U':
musicList.add(new Media(new File ("VOICEU.mp3").toURI().toString()));
break;
case 'V':
musicList.add(new Media(new File ("VOICEV.mp3").toURI().toString()));
break;
case 'W':
musicList.add(new Media(new File ("VOICEW.mp3").toURI().toString()));
break;
case 'X':
musicList.add(new Media(new File ("VOICEX.mp3").toURI().toString()));
break;
case 'Y':
musicList.add(new Media(new File ("VOICEY.mp3").toURI().toString()));
break;
case 'Z':
musicList.add(new Media(new File ("VOICEZ.mp3").toURI().toString()));
break;
case '1':
musicList.add(new Media(new File ("VOICE1.mp3").toURI().toString()));
break;
case '2':
musicList.add(new Media(new File ("VOICE2.mp3").toURI().toString()));
break;
case '3':
musicList.add(new Media(new File ("VOICE3.mp3").toURI().toString()));
break;
case '4':
musicList.add(new Media(new File ("VOICE4.mp3").toURI().toString()));
break;
case '5':
musicList.add(new Media(new File ("VOICE5.mp3").toURI().toString()));
break;
case '6':
musicList.add(new Media(new File ("VOICE6.mp3").toURI().toString()));
break;
case '7':
musicList.add(new Media(new File ("VOICE7.mp3").toURI().toString()));
break;
case '8':
musicList.add(new Media(new File ("VOICE8.mp3").toURI().toString()));
break;
case '9':
musicList.add(new Media(new File ("VOICE9.mp3").toURI().toString()));
break;
case '0':
musicList.add(new Media(new File ("VOICE0.mp3").toURI().toString()));
break;
case '/':
musicList.add(new Media(new File ("VOICESTROKE.mp3").toURI().toString()));
break;
// case ' ':
// musicList.add(new Media(new File ("VOICESPACE.mp3").toURI().toString()));
// break;
default:
System.out.println("[KST4ContestApp, warning, letter not defined:] cwLetters = " + Arrays.toString(playThisInCW));
}
}
playMusic();
// mediaPlayer.dispose();
}
// protected static final int SAMPLE_RATE = 16 * 1024;
private void playMusic() {
// System.out.println("Kst4ContestApplication.playMusic");
if(musicList.peek() == null)
{
return;
}
mediaPlayer = new MediaPlayer(musicList.poll());
mediaPlayer.setRate(1.0);
mediaPlayer.setOnReady(() -> {
mediaPlayer.play();
mediaPlayer.setOnEndOfMedia(() -> {
// mediaPlayer.dispose();
playMusic();
if (musicList.isEmpty()) {
// mediaPlayer.dispose();
}
});
});
}
@Override @Override
public void start(Stage primaryStage) throws InterruptedException, IOException { public void start(Stage primaryStage) throws InterruptedException, IOException, URISyntaxException {
// this.primaryStage = primaryStage; // this.primaryStage = primaryStage;
// ChatCategory category = new ChatCategory(0); //TODO: get the Category out of the preferences-object // ChatCategory category = new ChatCategory(0); //TODO: get the Category out of the preferences-object
@@ -1888,6 +2211,9 @@ public class Kst4ContestApplication extends Application {
// ownChatMemberObject.setQra("JO51IJ"); // ownChatMemberObject.setQra("JO51IJ");
chatcontroller = new ChatController(ownChatMemberObject); // instantiate the Chatcontroller with the user object chatcontroller = new ChatController(ownChatMemberObject); // instantiate the Chatcontroller with the user object
this.chatcontroller.getPlayAudioUtils().playNoiseLauncher('!');
// chatcontroller.execute(); //TODO:THAT IS THE MAIN POINT WHERE THE CHAT WILL BE STARTED --- MOVED TO CONNECT BUTTON EVENTHANDLER // chatcontroller.execute(); //TODO:THAT IS THE MAIN POINT WHERE THE CHAT WILL BE STARTED --- MOVED TO CONNECT BUTTON EVENTHANDLER
// System.out.println(chatcontroller.getChatMemberTable().size()); // System.out.println(chatcontroller.getChatMemberTable().size());
@@ -2717,15 +3043,41 @@ public class Kst4ContestApplication extends Application {
grdPnlNotify.setPadding(new Insets(10, 10, 10, 10)); grdPnlNotify.setPadding(new Insets(10, 10, 10, 10));
grdPnlNotify.setVgap(5); grdPnlNotify.setVgap(5);
grdPnlNotify.setHgap(5); grdPnlNotify.setHgap(5);
grdPnlNotify.add(generateLabeledSeparator(100, "Notification settings"), 0, 0, 2, 1);
Label lblNitificationInfo = new Label( // Label lblNitificationInfo = new Label(
"Switch bands, prefix worked by others alert, direction notifications, notification pattern matchers"); // "Switch bands, prefix worked by others alert, direction notifications, notification pattern matchers");
// CheckBox chkBxEnableTRXMsgbyUCX = new CheckBox(); // CheckBox chkBxEnableTRXMsgbyUCX = new CheckBox();
grdPnlNotify.add(generateLabeledSeparator(100, "Notification settings"), 0, 0, 2, 1); Label lblNotifyEnableSimpleSounds = new Label("Enable audio notifications at: startup, new personal messages, other");
grdPnlNotify.add(lblNitificationInfo, 0, 1); Label lblNotifyCWSounds = new Label("Enable CW callsign spelling for new personal messages");
Label lblNotifyVoiceSounds = new Label("Enable phonetic callsign spelling for new personal messages");
CheckBox chkBxEnableNotifySimpleSounds = new CheckBox();
chkBxEnableNotifySimpleSounds.setSelected(this.chatcontroller.getChatPreferences().isNotify_playSimpleSounds());
chkBxEnableNotifySimpleSounds.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
chatcontroller.getChatPreferences()
.setNotify_playSimpleSounds(chkBxEnableNotifySimpleSounds.isSelected());
System.out.println("[Main.java, Info]: Notification simplesounds enabled: " + newValue);
}
});
grdPnlNotify.add(lblNotifyEnableSimpleSounds, 0, 1);
grdPnlNotify.add(chkBxEnableNotifySimpleSounds, 1, 1);
// grdPnlNotify.add(lblNitificationInfo, 0, 1);
// grdPnltrx.add(chkBxEnableTRXMsgbyUCX, 1, 1); // grdPnltrx.add(chkBxEnableTRXMsgbyUCX, 1, 1);
VBox vbxNotify = new VBox(); VBox vbxNotify = new VBox();
vbxNotify.setPadding(new Insets(10, 10, 10, 10)); vbxNotify.setPadding(new Insets(10, 10, 10, 10));
vbxNotify.getChildren().addAll(grdPnlNotify); vbxNotify.getChildren().addAll(grdPnlNotify);
@@ -3188,6 +3540,8 @@ public class Kst4ContestApplication extends Application {
// event.consume(); // event.consume();
} else { } else {
System.out.println("closewindowevent: Platform.exit"); System.out.println("closewindowevent: Platform.exit");
Platform.exit(); Platform.exit();
} }
} }

View File

@@ -0,0 +1,10 @@
module praktiKST {
requires javafx.controls;
requires jdk.xml.dom;
requires java.sql;
requires javafx.media;
exports kst4contest.controller;
exports kst4contest.locatorUtils;
exports kst4contest.model;
exports kst4contest.view;
}

View File

@@ -0,0 +1,19 @@
package kst4contest.test;
import javafx.application.Application;
import javafx.stage.Stage;
import kst4contest.utils.PlayAudioUtils;
public class TestAudioPlayerUtils extends Application {
public static void main(String[] args) {
}
@Override
public void start(Stage stage) throws Exception {
PlayAudioUtils testAudio = new PlayAudioUtils();
testAudio.playCWLauncher("DO5AMF");
}
}