- dùng file wav :
Code:
System.Media.SoundPlay play = new System.Media.SoundPlay();
play.SoundLocation = [ đường dẫn file âm thanh wav ];
play.PlayLooping();
- dùng file mp3 : cái này bạn cần Add Reference -> COM -> Window Media Player
Code:
using MediaPlayer
...
MediaPlayerClass play = new MediaPlayerClass();
play.FileName = [ đường dẫn file âm thanh wav ];
play.AutoRewind = true;
play.Play();
- Nếu để nhạc chạy cùng Form thì bạn phải thêm chức năng tắt nhạc trên Form vì user không phải ai cũng thik nghe nhạc.