Use track check solution for this

This commit is contained in:
iiSaLMaN 2019-11-10 23:07:51 +03:00
parent 901a8d597b
commit 20ed6c4d52
1 changed files with 9 additions and 10 deletions

View File

@ -46,21 +46,20 @@ public PreviewTrack Get(BeatmapSetInfo beatmapSetInfo)
{
var track = CreatePreviewTrack(beatmapSetInfo, trackStore);
track.Started += () =>
track.Started += () => Schedule(() =>
{
// Stopping track should not be within the below schedule since its stop event schedules a null assign to current.
// Due to that, assigning the new track to current must be scheduled after the null assign to avoid current track loss.
current?.Stop();
var last = current;
current = track;
last?.Stop();
Schedule(() =>
{
current = track;
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, muteBindable);
});
};
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, muteBindable);
});
track.Stopped += () => Schedule(() =>
{
if (current != track)
return;
current = null;
audio.Tracks.RemoveAdjustment(AdjustableProperty.Volume, muteBindable);
});