From fabbc52a35e6f01085ebc1b3896a990f7f1a6d62 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:14:42 +0100 Subject: [PATCH] Properly handle unexpected end of stream --- HyperbolicDownloaderApi/Commands/StreamingCommands.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HyperbolicDownloaderApi/Commands/StreamingCommands.cs b/HyperbolicDownloaderApi/Commands/StreamingCommands.cs index ba7847d..0326c02 100644 --- a/HyperbolicDownloaderApi/Commands/StreamingCommands.cs +++ b/HyperbolicDownloaderApi/Commands/StreamingCommands.cs @@ -181,6 +181,12 @@ public class StreamingCommands(HostsManager hostsManager) try { bytesRead = nwStream.Read(reciveBuffer, 0, reciveBuffer.Length); + + if (bytesRead == 0 && bufferedWaveProvider.BufferedBytes == 0) + { + player.Stop(); + ApiManager.SendNotificationMessage($"\r[{player.PlaybackState,-7}]"); + } } catch (IOException ex) {