From 08587a066a870aecaf50774e955bc94d28b439b7 Mon Sep 17 00:00:00 2001
From: Anonymus Raccoon <32224410+AnonymusRaccoon@users.noreply.github.com>
Date: Wed, 26 Jun 2019 15:18:40 +0200
Subject: [PATCH] Allowing users to switch playback before the end of a parse.
---
Opus/Code/Api/Services/MusicPlayer.cs | 1 +
Opus/Code/Api/SongParser.cs | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/Opus/Code/Api/Services/MusicPlayer.cs b/Opus/Code/Api/Services/MusicPlayer.cs
index e4629cd..89aad95 100644
--- a/Opus/Code/Api/Services/MusicPlayer.cs
+++ b/Opus/Code/Api/Services/MusicPlayer.cs
@@ -464,6 +464,7 @@ namespace Opus.Api.Services
Queue.instance?.Refresh();
Player.instance?.RefreshPlayer();
currentID = 0;
+ SongParser.Cancel(0);
await new SongParser().ParseSong(song, 0, true);
}
else
diff --git a/Opus/Code/Api/SongParser.cs b/Opus/Code/Api/SongParser.cs
index 9010bef..f19ae88 100644
--- a/Opus/Code/Api/SongParser.cs
+++ b/Opus/Code/Api/SongParser.cs
@@ -251,6 +251,15 @@ namespace Opus.Api
return song;
}
+ ///
+ /// Will stop the parsing for a slot of the queue. Use this when the user wants to play something else before the end of a parsing (Want to play something on the same queue slot but not the same song has the one being parsed now).
+ ///
+ ///
+ public static void Cancel(int queuePosition)
+ {
+ instances.Where(x => x.queuePosition == queuePosition).FirstOrDefault()?.Cancel();
+ }
+
///
/// This method will remove playback calls and get requests from the
///