Click here to Skip to main content
15,912,082 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
Hi, I want to add background music in my website that I had coded in C#. I want the music to be played whenever I open the page.Please help.
Thanx in advance.
Posted

Well, that not really a C# issue. Just output the right html, have the audio files in place, and if the browser accepts it (or the user to be more precise), you'll have your background music. Just be aware, that usually users don't really like background music, especially if autoplayed.

A short codeproject search can help you: Background Music in HTML 5[^]
 
Share this answer
 
Using the <embed> Tag:-
<embed name="lostmojo" src="abc.wav" loop="false" hidden="true" autostart="true">


or (for IE and opera versions)
<bgsound src="file.mid" loop="infinite">
 
Share this answer
 
Hello,

You can use soundplayer class and use the system.media as a reference to achieve this
http://msdn.microsoft.com/en-us/library/system.media.soundplayer(v=vs.110).aspx[^]




All the best:)
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900