3

I made a Windows Forms Application C# and I want to add music to it, I know how to do it if I have the file in my PC, but what if I want to send the application to a friend and he does not have the sound file what to do? Can you use an URL? Or resources? If yes, how to do it?

Thanks alot !

Alex Kayz
  • 191
  • 1
  • 15

2 Answers2

1

You can create a Windows Setup project and add all necessary files to distribute, including that sound file. The project can be found in Visual Studio under: Other Project Types ->Setup and Deployments: add it to your solution workspace in order to produce .msi and Setup.exe files. Alternatively, you can embed the file as a Resource (re: http://www.codeproject.com/Articles/17422/Embedding-and-Playing-WAV-Audio-Files-in-a-WinForm), but it may substantially increase the size of .exe file.

Alexander Bell
  • 7,842
  • 3
  • 26
  • 42
0

Your music file should be in your app file, but also you can play from url. The best way is to keep it in your app, because the connection to the file will be faster. Here is one way to play from url: How to play .mp3 file from online resources in C#?

Community
  • 1
  • 1
  • What do you mean by keeping it in the app? – Alex Kayz Mar 26 '16 at 14:20
  • Create new folder in your project e.g"Music" then add your music there. Then your method : private void playMusic() { SoundPlayer player = new SoundPlayer(YourResourceFile.stringThatKeepsThePathToYourMusic); player.Play(); } – Kiril Stoilkov Mar 26 '16 at 14:32
  • If you dont know how to work with resources. Here is one example: http://stackoverflow.com/questions/4125698/how-to-play-wav-audio-file-from-resources – Kiril Stoilkov Mar 26 '16 at 14:38