Centralise TrackManager.AddItem logic to avoid duplicate adds

This commit is contained in:
Dean Herbert
2017-07-20 17:46:23 +09:00
parent 67b95926c4
commit 3bdd4d7d02
5 changed files with 17 additions and 28 deletions

View File

@ -3,9 +3,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -15,7 +13,6 @@ using osu.Game.Database;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Extensions;
using osu.Framework.Input;
using osu.Framework.Graphics.Shapes;
@ -30,7 +27,6 @@ namespace osu.Game.Overlays.Music
private FilterControl filter;
private PlaylistList list;
private TrackManager trackManager;
private BeatmapDatabase beatmaps;
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
@ -43,7 +39,6 @@ namespace osu.Game.Overlays.Music
{
this.inputManager = inputManager;
this.beatmaps = beatmaps;
trackManager = game.Audio.Track;
Children = new Drawable[]
{
@ -154,13 +149,7 @@ namespace osu.Game.Overlays.Music
private void playSpecified(BeatmapInfo info)
{
beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking);
Task.Run(() =>
{
var track = beatmapBacking.Value.Track;
trackManager.AddItem(track);
track.Start();
}).ContinueWith(task => Schedule(task.ThrowIfFaulted), TaskContinuationOptions.OnlyOnFaulted);
beatmapBacking.Value.Track.Start();
}
}