I have posted a blog post on C #/. net using the mediaplayer control to play MP3 and other music files. Today I will talk about using the class library that comes with. net.System. MediaThe followingSoundplayerTo play music.CodeIt should be a more desirable method.
It is very easy to use. The following is a brief description:
1. Support synchronous and asynchronous playback
2. Supports loop playback.
3. Support for file and stream playback
Synchronous playback:
System. Media. soundplayer player =NewSystem. Media. soundplayer (); player. soundlocation = @"D: \ music \ happy.pdf"; Player. Load (); player. Play ();
Asynchronous playback:
System. Media. soundplayer player =NewSystem. Media. soundplayer (); player. soundlocation = @"D: \ music \ happy.pdf"; Player. loadasync (); player. playsync ();
Loop playback:
System. Media. soundplayer player =NewSystem. Media. soundplayer (); player. soundlocation = @"D: \ music \ happy.pdf"; Player. Load (); player. playlooping ();
OK. I hope I can give you a prompt!