1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00
osu-lazer/osu.Game/Audio/PreviewTrack.cs
2018-06-01 21:06:37 +03:00

44 lines
1.1 KiB
C#

// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Audio
{
public class PreviewTrack
{
public readonly Track Track;
public readonly OverlayContainer Owner;
private readonly Action<PreviewTrack> onStart;
private readonly Action onStop;
public event Action Stopped;
public event Action Started;
public PreviewTrack(Track track, Action<PreviewTrack> onStart, Action onStop, OverlayContainer owner)
{
Track = track;
this.onStart = onStart;
this.onStop = onStop;
Owner = owner;
}
public void Start()
{
onStart?.Invoke(this);
Track.Restart();
Started?.Invoke();
}
public void Stop()
{
onStop?.Invoke();
Track.Stop();
Stopped?.Invoke();
}
}
}