WPF用DirectSound播放声音

示例代码:

var fileName = @"D:WindowsLogon.wav";
DevicesCollection sound_devices = new DevicesCollection();
Device sound_device_output = new Device(sound_devices[0].DriverGuid);
sound_device_output.SetCooperativeLevel(new WindowInteropHelper(this).Handle, CooperativeLevel.Normal);     //设置设备协作级别
SecondaryBuffer secondary_buffer = new SecondaryBuffer(fileName, sound_device_output);                      //创建辅助缓冲区
secondary_buffer.Play(0, BufferPlayFlags.Looping);                                                          //设置缓冲区为循环播放
原文地址:https://www.cnblogs.com/wzwyc/p/7505925.html