public PlayParameters Suspend(float fadeoutTime = 0) { if (!AudioSystem.Active) { return(null); } if (fadeoutTime > 0) { fadeSpeed = -1 / fadeoutTime; fadePurpose = FadePurpose.Suspend; } else { fadeSpeed = 0; fadeVolume = 0; SuspendImmediate(); } Volume = volume; return(new PlayParameters { Decoder = decoder, Group = Group, Pan = pan, Volume = volume, Pitch = pitch, Path = SamplePath, Priority = Priority, Looping = looping, }); }
public void Stop(float fadeoutTime = 0) { if (!AudioSystem.Active) { return; } if (fadeoutTime > 0) { fadeSpeed = -1 / fadeoutTime; fadePurpose = FadePurpose.Stop; } else { fadeSpeed = 0; fadeVolume = 0; StopImmediate(); } Volume = volume; }
private void FadeFinished() { switch (fadePurpose) { case FadePurpose.Play: break; case FadePurpose.Stop: StopImmediate(); break; case FadePurpose.Pause: PauseImmediate(); break; case FadePurpose.Suspend: SuspendImmediate(); break; } fadePurpose = FadePurpose.None; }
public void Resume(float fadeinTime = 0) { if (!AudioSystem.Active) { return; } if (decoder == null) { throw new InvalidOperationException("Audio decoder is not set"); } if (fadeinTime > 0) { fadeVolume = 0; fadeSpeed = 1 / fadeinTime; fadePurpose = FadePurpose.Play; } else { fadeSpeed = 0; fadeVolume = 1; } Volume = volume; PlayImmediate(); }