How To Add Background Music To A Web Page? February 17, 2024 Post a Comment How do I add background music to a web page? So that when the visitor opens the page, the music will auto play. I have tried and but thSolution 1: The <bgsound> tag is Internet Explorer-specific and will thus not work in other browsers such as FireFox. The <embed> tag should work in FireFox if you use it correctly. It will use a browser plug-in to play the sound. Below is an example:<embed loop="true" src="sound.wav" hidden="true"type="video/quicktime"></embed> Copyloop="true" specifies to play the sound repeatedly.src="sound.wav" specifies the relative path of the sound file to play. The variety of formats you can play depends on what type= you specify.hidden="true" indicates to not show the media player's interface. Hide it if you want the user to not be able to pause, stop, or navigate through the sound.type="video/quicktime" specifies to use a Quicktime component, which means the client must have Quicktime installed. Use application/x-mplayer2 for Windows Media Player or audio/x-pn-realaudio-plugin for Real Player audio. Quicktime plays more formats and is probably what you will want to use.Alternatively, use <object> in a very similar way. An example is below:<objectdata="sound.wav"type="video/quicktime"width="0"height="0"><paramname="filename"value="sound.wav"><paramname="autostart"value="1"><paramname="playcount"value="true"></object>CopyKeep in mind that, like the <marquee> tag, background sound on a web page is generally frowned upon because it is often obtrusive and annoying. Also, as the user switches between pages or causes post-backs, the sound will restart from the beginning. Only use audio formats that are highly compressed, meaning they have small file sizes, or the sound will not play for several seconds while it downloads to the client machine.Solution 2: To play audio and display the standard controls: <audioautoplay="autoplay"controls="controls"><sourcesrc="http://play.onet4u.com/nazrenz.mp3" /></audio>CopyOr to hide the controls:Baca JugaHow To Save An Html5 Canvas To A PngBlur Event Handler Is Blocked By Jquery Preventdefault() MethodWhy Getboundingclientrect Gives Different Values In Ie And Firefox<audioautoplay="autoplay"><sourcesrc="http://play.onet4u.com/nazrenz.mp3" /></audio>CopySolution 3: The embedding method places a media player in your page. Here's the most basic version of the code:<audio controls="controls"><source src="SoundFile.mp3"type="audio/mpeg" /></audio> CopyThe embedded player looks like this:If you would prefer not to show the player (and give the user no control), use this code: <audio><source src="SoundFile.mp3"type="audio/mpeg" /></audio> CopyFor more information and options such as autoplay, see HTML5 audio. Share You may like these postsResize The Image To Fit The Dimensions Of TdHow Css Increasing Line Spacing Between Select Box ElementsHow Do I Vertically Center The Text Within A Flex Element?How To Cut Off Overflow On The Left Side Post a Comment for "How To Add Background Music To A Web Page?"