using System.Threading.Tasks;
using WS;

///<summary>播放音频</summary>
public class PlayAudioComponent : OperateComponent<PlayAudioData>
{
    ///<summary>音频实例</summary>
    private VoiceEntity Voice;

    public override void Init()
    {
    }

    public override void StartOperate()
    {
        Voice = VoiceManager.Instance.Play(VoiceType.Voice, OperateData.AudioName, OnFinished);
    }

    ///<summary>设置操作完成完成</summary>
    private void OnFinished()
    {
        IsComplete = true;
    }

    public override void Update()
    {
    }

    public override Task EndState()
    {
        if (!Voice.IsDisposed)
            VoiceManager.Instance.Stop(Voice);
        return Task.CompletedTask;
    }
    public override void Dispose()
    {
        base.Dispose();
        if (!Voice.IsDisposed)
            VoiceManager.Instance.Stop(Voice);
        Voice = null;
    }
}

///<summary>播放音频数据</summary>
public class PlayAudioData
{
    ///<summary>音频名称</summary>
    public string AudioName { get; set; }


}