mirror of
https://github.com/ppy/osu.git
synced 2024-11-08 13:57:29 +08:00
Fix audio preview muting game audio indefinitely when beatmap p… (#6738)
Fix audio preview muting game audio indefinitely when beatmap panel is off-screen Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
This commit is contained in:
commit
a6d000baa2
@ -13,11 +13,13 @@ namespace osu.Game.Audio
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when this <see cref="PreviewTrack"/> has stopped playing.
|
/// Invoked when this <see cref="PreviewTrack"/> has stopped playing.
|
||||||
|
/// Not invoked in a thread-safe context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action Stopped;
|
public event Action Stopped;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when this <see cref="PreviewTrack"/> has started playing.
|
/// Invoked when this <see cref="PreviewTrack"/> has started playing.
|
||||||
|
/// Not invoked in a thread-safe context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action Started;
|
public event Action Started;
|
||||||
|
|
||||||
@ -29,7 +31,7 @@ namespace osu.Game.Audio
|
|||||||
{
|
{
|
||||||
track = GetTrack();
|
track = GetTrack();
|
||||||
if (track != null)
|
if (track != null)
|
||||||
track.Completed += () => Schedule(Stop);
|
track.Completed += Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -93,6 +95,7 @@ namespace osu.Game.Audio
|
|||||||
hasStarted = false;
|
hasStarted = false;
|
||||||
|
|
||||||
track.Stop();
|
track.Stop();
|
||||||
|
|
||||||
Stopped?.Invoke();
|
Stopped?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,18 +46,18 @@ namespace osu.Game.Audio
|
|||||||
{
|
{
|
||||||
var track = CreatePreviewTrack(beatmapSetInfo, trackStore);
|
var track = CreatePreviewTrack(beatmapSetInfo, trackStore);
|
||||||
|
|
||||||
track.Started += () =>
|
track.Started += () => Schedule(() =>
|
||||||
{
|
{
|
||||||
current?.Stop();
|
current?.Stop();
|
||||||
current = track;
|
current = track;
|
||||||
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, muteBindable);
|
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, muteBindable);
|
||||||
};
|
});
|
||||||
|
|
||||||
track.Stopped += () =>
|
track.Stopped += () => Schedule(() =>
|
||||||
{
|
{
|
||||||
current = null;
|
current = null;
|
||||||
audio.Tracks.RemoveAdjustment(AdjustableProperty.Volume, muteBindable);
|
audio.Tracks.RemoveAdjustment(AdjustableProperty.Volume, muteBindable);
|
||||||
};
|
});
|
||||||
|
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user