diff --git a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs index 637985e3cd..6e22d51958 100644 --- a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs @@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps private DirectPanel currentlyPlaying; - public event Action BeatmapAdded; + public event Action BeganPlayingPreview; public PaginatedBeatmapContainer(BeatmapSetType type, Bindable user, string header, string missing = "None... yet.") : base(user, header, missing) @@ -61,16 +61,22 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps { if (!isPlaying) return; + BeganPlayingPreview?.Invoke(this); if (currentlyPlaying != null && currentlyPlaying != panel) - currentlyPlaying.PreviewPlaying.Value = false; + StopPlayingPreview(); currentlyPlaying = panel; }; - BeatmapAdded?.Invoke(panel); } }; Api.Queue(req); } + + public void StopPlayingPreview() + { + if (currentlyPlaying != null) + currentlyPlaying.PreviewPlaying.Value = false; + } } } diff --git a/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs b/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs index 928ac677a4..f1f2421237 100644 --- a/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs +++ b/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs @@ -26,16 +26,15 @@ namespace osu.Game.Overlays.Profile.Sections new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User, "Graveyarded Beatmaps"), }; - foreach (var beatmapContainer in Children.OfType()) + foreach (var paginatedBeatmapContainer in Children.OfType()) { - beatmapContainer.BeatmapAdded += panel => panel.PreviewPlaying.ValueChanged += isPlaying => + paginatedBeatmapContainer.BeganPlayingPreview += (BeatmapContainer) => { - if (!isPlaying) return; - - if (currentlyPlaying != null && currentlyPlaying != panel) - currentlyPlaying.PreviewPlaying.Value = false; - - currentlyPlaying = panel; + foreach (var bc in Children.OfType()) + { + if (bc != BeatmapContainer) + bc.StopPlayingPreview(); + } }; } }