Put sound on own simple program
-
Have been trying up an easy program, but now want to try make it more user friendly by maybe playing a song in the background. How can I go about this one.Anyone help please.(C# base). :((
It depends on how you want to do it. The simplest way is:
System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer();
soundPlayer.SoundLocation = @"c:\chord.wav"; // full path to file
soundPlayer.Play();Don't forget to call soundPlayer.Dispose() when you're finished with it!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) -
Have been trying up an easy program, but now want to try make it more user friendly by maybe playing a song in the background. How can I go about this one.Anyone help please.(C# base). :((
Sounds user hostile to me.
-
Sounds user hostile to me.
-
It depends on how you want to do it. The simplest way is:
System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer();
soundPlayer.SoundLocation = @"c:\chord.wav"; // full path to file
soundPlayer.Play();Don't forget to call soundPlayer.Dispose() when you're finished with it!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)Thanks alot that helped and am able to get through.could have kissed you if you were next to me.(just a jok) Now check here, that method can only work with .wav file type only? or you can use other files(file size for a wav file is too large). waiting.... Thanks alot :doh:
-
The user may not want sound playing.
-
Thanks alot that helped and am able to get through.could have kissed you if you were next to me.(just a jok) Now check here, that method can only work with .wav file type only? or you can use other files(file size for a wav file is too large). waiting.... Thanks alot :doh:
IT would have taken less time to change your code to point to an .mp3 file than it did to post the question here.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall
-
Thanks alot that helped and am able to get through.could have kissed you if you were next to me.(just a jok) Now check here, that method can only work with .wav file type only? or you can use other files(file size for a wav file is too large). waiting.... Thanks alot :doh:
You may be better off embedding media player. Right click on your toolbox and select Chose Items (you may have to wait a while for the next dialog!). Click on the COM Components tab and scroll down and select Windows Media Player. Drag and drop (& resize) a WMP onto your form. Set the URL property to point to your file and you're done.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)