C# play voice

Using System.Media.SoundPlayer;

OpenFileDialog o = new OpenFileDialog();
o.ShowDialog();
SoundPlayer player = new SoundPlayer(o.FileName);
player.Play();//This method only plays onceplayer.PlayLooping();//This method loops playbacko.FileName ​​Here you can directly specify the music file Path




_________________________________________________________________
Use .NETThe built-in class library SoundPlayer to play music. This class supports synchronous and asynchronous playback in the System.Media namespace, and also supports file and stream playback.
Synchronous playback:

System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = @"d:\music\happy.mp3";
player.Load();
player.Play();Asynchronous playback:
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = @"d:\music\happy.mp3";
player.LoadAsync();
player.PlaySync(); Looping:

System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = @"d:\music\happy.mp3";
player.Load();
player.PlayLooping();