From e8f85a08b854271b72f50df79969db7ee196cc74 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 14 Oct 2017 05:58:06 +0300 Subject: [PATCH] Fix audio preview still playing after closing the beatmap overlay --- osu.Game/Overlays/BeatmapSet/Details.cs | 2 ++ osu.Game/Overlays/BeatmapSet/Header.cs | 8 ++++---- osu.Game/Overlays/BeatmapSet/PreviewButton.cs | 10 +++++----- osu.Game/Overlays/BeatmapSetOverlay.cs | 1 + 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Details.cs b/osu.Game/Overlays/BeatmapSet/Details.cs index 2fd0a55d9e..128ea7d2d3 100644 --- a/osu.Game/Overlays/BeatmapSet/Details.cs +++ b/osu.Game/Overlays/BeatmapSet/Details.cs @@ -88,6 +88,8 @@ public Details() }; } + public void StopPreview() => preview.Playing.Value = false; + private class DetailBox : Container { private readonly Container content; diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index a93ccbf704..d4514cbaed 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -27,7 +27,7 @@ public class Header : Container private readonly Container coverContainer; private readonly OsuSpriteText title, artist; private readonly AuthorInfo author; - private readonly Details details; + public Details Details; private DelayedLoadWrapper cover; @@ -42,7 +42,7 @@ public BeatmapSetInfo BeatmapSet if (value == beatmapSet) return; beatmapSet = value; - Picker.BeatmapSet = author.BeatmapSet = details.BeatmapSet = BeatmapSet; + Picker.BeatmapSet = author.BeatmapSet = Details.BeatmapSet = BeatmapSet; title.Text = BeatmapSet.Metadata.Title; artist.Text = BeatmapSet.Metadata.Artist; @@ -192,7 +192,7 @@ public Header() }, }, }, - details = new Details + Details = new Details { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, @@ -204,7 +204,7 @@ public Header() Picker.Beatmap.ValueChanged += b => { - details.Beatmap = b; + Details.Beatmap = b; if (b.OnlineInfo.HasVideo) { diff --git a/osu.Game/Overlays/BeatmapSet/PreviewButton.cs b/osu.Game/Overlays/BeatmapSet/PreviewButton.cs index f77a1f4a0a..52edd1714f 100644 --- a/osu.Game/Overlays/BeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/BeatmapSet/PreviewButton.cs @@ -26,7 +26,7 @@ public class PreviewButton : OsuClickableContainer private readonly PlayButton playButton; private Track preview => playButton.Preview; - private Bindable playing => playButton.Playing; + public Bindable Playing => playButton.Playing; public BeatmapSetInfo BeatmapSet { @@ -66,8 +66,8 @@ public PreviewButton() }, }; - Action = () => playing.Value = !playing.Value; - playing.ValueChanged += newValue => progress.FadeTo(newValue ? 1 : 0, 100); + Action = () => Playing.Value = !Playing.Value; + Playing.ValueChanged += newValue => progress.FadeTo(newValue ? 1 : 0, 100); } [BackgroundDependencyLoader] @@ -80,7 +80,7 @@ protected override void Update() { base.Update(); - if (playing.Value && preview != null) + if (Playing.Value && preview != null) { progress.Width = (float)(preview.CurrentTime / preview.Length); } @@ -88,7 +88,7 @@ protected override void Update() protected override void Dispose(bool isDisposing) { - playing.Value = false; + Playing.Value = false; base.Dispose(isDisposing); } diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index a60429f737..ddd146bcb6 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -98,6 +98,7 @@ protected override void PopIn() protected override void PopOut() { base.PopOut(); + header.Details.StopPreview(); FadeEdgeEffectTo(0, DISAPPEAR_DURATION, Easing.Out); }