C# 使用System.Media.SoundPlayer播放wav格式的声音文件
作者:互联网
using System.Media; string szPath = Application.StartupPath + “\\SoundFile\\sound.wav”; SoundPlayer soundplayer = new SoundPlayer(); 声音文件路径: soundplayer.SoundLocation = szPath; 播放方式: ①同步播放: soundplayer.Load(); soundplayer.Play(); ②异步播放: soundplayer.LoadAsync(); soundplayer.PlaySync(); ③循环播放: soundplayer.Load(); soundplayer.PlayLooping(); ④关闭://关闭时释放资源 soundplayer.Stop(); soundplayer.Dispose();
标签:SoundPlayer,soundplayer,C#,Media,System,声音文件,播放 来源: https://www.cnblogs.com/yc1224/p/12033919.html