private void LoadAndPlay(SoundFlags flags) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return; } if (_streamData == null) { int streamLen = (int)_stream.Length; _streamData = new byte[streamLen]; _stream.Read(_streamData, 0, streamLen); } Winmm.PlaySound(_streamData, IntPtr.Zero, SoundFlags.SND_MEMORY | SoundFlags.SND_NODEFAULT | flags); }
public void Stop() { Winmm.PlaySound((byte[])null, IntPtr.Zero, SoundFlags.SND_PURGE); }