Improve ticker handling to stop recording
This commit is contained in:
parent
426268b512
commit
1e8fe94e3e
|
@ -42,6 +42,9 @@ class Program
|
||||||
var isRecording = false;
|
var isRecording = false;
|
||||||
var currentSongName = string.Empty;
|
var currentSongName = string.Empty;
|
||||||
|
|
||||||
|
// Flag to track if we need to check for "MUSIC SELECT!!"
|
||||||
|
var shouldCheckForMusicSelect = false;
|
||||||
|
|
||||||
using var clientWebSocket = new ClientWebSocket();
|
using var clientWebSocket = new ClientWebSocket();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -91,10 +94,21 @@ class Program
|
||||||
isRecording = true;
|
isRecording = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isRecording || (!message.EndsWith("CLEAR!") && !message.EndsWith("FAILED.."))) continue;
|
if (isRecording)
|
||||||
|
{
|
||||||
|
if (shouldCheckForMusicSelect && message.Contains("MUSIC SELECT!!"))
|
||||||
|
{
|
||||||
Console.WriteLine("Stopping recording...");
|
Console.WriteLine("Stopping recording...");
|
||||||
StopRecording(currentSongName);
|
StopRecording(currentSongName);
|
||||||
isRecording = false;
|
isRecording = false;
|
||||||
|
shouldCheckForMusicSelect = false;
|
||||||
|
}
|
||||||
|
else if (message.EndsWith("CLEAR!") || message.EndsWith("FAILED.."))
|
||||||
|
{
|
||||||
|
// Set the flag to check the next message for "MUSIC SELECT!!"
|
||||||
|
shouldCheckForMusicSelect = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reconnecting)
|
if (reconnecting)
|
||||||
|
@ -104,6 +118,7 @@ class Program
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void StartRecording(string songName)
|
private static void StartRecording(string songName)
|
||||||
{
|
{
|
||||||
Task.Run(() => StartAudioRecording(songName));
|
Task.Run(() => StartAudioRecording(songName));
|
||||||
|
|
Loading…
Reference in a new issue