Audio Codes for HTML
When you are adding audio to your web site, you need to locate the file name and its extension. The best audio files are those that have the extension .wav, mp3, mid or midi. You may find others but these seem to work the best.
There are two ways to add audio – either as a background sound or embedded as part of your web page.
-When you add audio as an embedded file, you can give your viewer some control. You can have a console that the viewer can control.
The codes for embedded sound: <embed src= “url”>
-This code can be written anywhere after the body code. Wherever you write the code that is where the console will appear.
-You can add many other attribute to the code either together or separate depending on what you want.
-To actually show your sound control and change the size of the control
<embed src= “url” controls=console height=25 width=25>
-To force the visitor to click the play button on the console
<embed src= “url” autostart=false>
If you don’t use this attribute the song will start automatically.
-To have the song play repeatedly a defined number of times.
<embed src= “url” loop=#> #-is the number of times it’s repeated
-To give the viewer an opportunity to stop the song from repeating indefinitely
<embed src= “url” loop=true>
-To move your console to the left, right or center of your screen
<embed src= “url” align=left, right or center>
You can include all attributes within the code, some or none.
<embed src= “url” controls=console width=25 height=25 autostart=false loop=2 align=right >
The codes for adding background sound: <bgsound src= “url”>.
-This code is found after the body code.
-You can add an attribute to the code to control the number of times the music will play
To have the song play over and over
<bgsound src= “url” loop=infinite>
To have the song play repeatedly a defined number of times
<bgsound src= “url” loop=#> #- is the number of times it’s repeated
-When you add background sound, there is no console. The viewer has no control.