Allowing users to switch playback before the end of a parse.

This commit is contained in:
Anonymus Raccoon
2019-06-26 15:18:40 +02:00
parent 90fcdb8d1c
commit 08587a066a
2 changed files with 10 additions and 0 deletions

View File

@@ -464,6 +464,7 @@ namespace Opus.Api.Services
Queue.instance?.Refresh(); Queue.instance?.Refresh();
Player.instance?.RefreshPlayer(); Player.instance?.RefreshPlayer();
currentID = 0; currentID = 0;
SongParser.Cancel(0);
await new SongParser().ParseSong(song, 0, true); await new SongParser().ParseSong(song, 0, true);
} }
else else

View File

@@ -251,6 +251,15 @@ namespace Opus.Api
return song; return song;
} }
/// <summary>
/// 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).
/// </summary>
/// <param name="queuePosition"></param>
public static void Cancel(int queuePosition)
{
instances.Where(x => x.queuePosition == queuePosition).FirstOrDefault()?.Cancel();
}
/// <summary> /// <summary>
/// This method will remove playback calls and get requests from the /// This method will remove playback calls and get requests from the
/// </summary> /// </summary>