How To Play A Wave Sound File In Background Mode In C#

wave file

this is gonna be a snippet and i call it a useful snippet , you just need to add a namespace and add 4 lines of codes to a event .

add this namespace :

Using System.Media;

after that you need to add these 4 lines of codes for a event (for example form_load , button_click)

SoundPlayer wave = new SoundPlayer();
            string path = "path to .WAV";
            wave.SoundLocation = path; 
            wave.Play(); 

now replace path to .WAV with the destination (for example C:/new folder/hello.wav)

i hope you enjoy this !

Post a Comment

Note: Only a member of this blog may post a comment.