Add background music to a Web page

Source: Internet
Author: User
Tags file url prefetch shuffle

There are two ways of adding background music
Use the <bgsound> and <embed></embed> tags respectively, when using <embed> Insert background music can be set width and height of 0, hidden player.
The parameters are as follows:

<bgsound>:

<bgsound> is used to insert background music, but only for IE, its parameters are not set much. As follows

<bgsound src= "Your.mid" Autostart=true loop=infinite>

Src= "Your.mid"


Set MIDI files and paths that can be relative or absolute.
Autostart=true
Automatically play after the music file has been downloaded. True Yes, False No (default value).
Loop=infinite
Whether or not it is automatically played again. loop=2 means repeating two times, Infinite means repeating multiple times.

<embed>:

<EMBED> is used to insert a variety of multimedia, format can be Midi, Wav, AIFF, AU and so on, Netscape and the new version of IE are supported. The parameters are set more. The following

<embed src= "Your.mid" autostart= "true" loop= "true" hidden= "true" >

Src= "Your.mid"
Set MIDI files and paths that can be relative or absolute.
Autostart=true
Automatically play after the music file has been downloaded. True Yes, False No (default value).
Loop= "true"
Whether or not it is automatically played again. loop=2 means repeat two times, true Yes, false No.
Hidden= "true"
Whether to completely hide the control screen, true Yes, no is no (default).
Starttime= "Minutes: Seconds"
Sets the time at which the song starts playing. such as starttime= "00:30" means to start playing from 30th seconds.
Volume= "0-100"
Set the volume size to a value between 0 and 100. The default is to use the system itself.
Width= "integers" and high= "integers"
Sets the height and width of the control panel. (If hidden= "no")
align= "Center"
Sets the alignment of the control Panel and the text next to it, with values such as top, bottom, center, baseline, left, right, Texttop, middle, absmiddle, absbottom
Controls= "Smallconsole"
Sets the appearance of the control Panel. The default value is console.
Console General normal panel
Smallconsole smaller panels
PlayButton Show only play button
Pausecutton Show Pause button only
Stopbutton Only Show Stop button
Volumelever only the volume adjustment button is displayed

Instance:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Untitled Document </title>

<body>
<bgsound src= "Http://sj.cpgl.net/sjbbs/midi/md01.mid" Autostart=true loop=infinite>
</body>

Copy Code

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional. DTD ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Untitled Document </title>

<body>
<embed src= "http://www.bricklin.cn/zly/theone/2.wma" width= "0" height= "0" ></embed>
</body>

Copy Code

*************************************************************************************************************** *******************

(i), basic grammar:

Embed Src=url

Description: Embed can be used to insert a variety of multimedia, format can be Midi, Wav, AIFF, AU, MP3 and so on,

Netscape and the new version of IE are supported. The URL is an audio or video file and its path, which can be a relative path or an absolute path.

Example: <embed src= "Your.mid" >

(b), property settings:

1. Auto Play:

Syntax: Autostart=true, False

Description: This property specifies whether an audio or video file will play automatically after it has been downloaded.

True: Music files are automatically played after downloading;

False: The music file does not play automatically after the download is complete.

Example: <embed src= "Your.mid" autostart=true>

<embed src= "Your.mid" autostart=false>

2. Cyclic playback:

Syntax: loop= positive integer, True, False

Description: This property specifies whether audio or video files are looped and cycled.

When the value of the property is a positive integer value, the number of cycles of the audio or video file is the same as the full value;

When the property value is true, the audio or video file loops;

When the property value is false, the audio or video file does not loop.

Example: <embed src= "Your.mid" autostart=trueloop=2>

<embed src= "Your.mid" autostart=trueloop=true>

<embed src= "Your.mid" autostart=trueloop=false>

3. Panel Display:

Syntax: Hidden=ture, flase

Description: This property specifies whether the control panel is displayed and the default value is Flase.

Ture: Hide panel;

Flase: Display panel.

Example: <embed src= "Your.mid" hidden= "ture" >

<embed src= "Your.mid" hidden= "no" >

4. Start time:

Syntax: Starttime=mm:ss (min: sec)

Description: This property specifies the time at which an audio or video file starts playing. Not defined, plays from the beginning of the file.

Example: <embed src= "Your.mid" starttime= "00:10" >

5, Volume Size:

Syntax: An integer between volume=0-100

Description: This property specifies the volume size of an audio or video file. Undefined uses the settings of the system itself.

Example: <embed src= "Your.mid" Volume= "ten" >

6. Container properties:

Syntax: height=# width=#

Note: The value is a positive integer or a percentage, in pixels. This property specifies the height and width of the control panel.

Height: level of Control Panel;

Width: The height of the control Panel.

Example: <embed src= "Your.mid" height=200width=200>

7. Container unit:

Syntax: Units=pixels, en

Description: This property specifies the height and width of the unit for pixels or en.

Example: <embed src= "Your.mid" units= "Pixels" height=200 width=200>

<embed src= "Your.mid" units= "en" height=200 width=200>

8. Appearance setting:

Syntax: Controls=console, Smallconsole, PlayButton, Pausebutton, Stopbutton,

Volumelever Description: This property specifies the appearance of the control Panel. The default value is console.

Console: General normal Panel;

Smallconsole: smaller panel;

PlayButton: Only the play button is displayed;

Pausebutton: Only the pause button is displayed;

Stopbutton: Only the Stop button is displayed;

Volumelever: Only the volume adjustment button is displayed.

Example: <embed src= "Your.mid" controls=smallconsole>

<embed src= "Your.mid" controls=volumelever>

9. Object Name:

Syntax: name=#

Description: #为对象的名称. This property names the object for other objects to take advantage of.

Example: <embed src= "Your.mid" name= "Sound1" >

10. Description text:

Syntax: title=#

Description: #为说明的文字. This attribute specifies the description text for an audio or video file.

Example: <embed src= "Your.mid" title= "first song" >

11. Foreground and background color:

Syntax: Palette=color|color

Description: This property represents the foreground and background color of an embedded audio or video file, the first value is a front color, the second value is the background

Color, middle with | Separated. Color can be an RGB color (RRGGBB) or a color name, or it can be a transparent

(Transparent). Example: <embed src= "Your.mid" palette= "Red|black" >

12, the Alignment method:

Syntax: align=top, bottom, center, baseline, left, right, texttop, middle,

Absmiddle, Absbottom

Description: This property specifies the alignment of the control Panel and the objects in the current row.

Center: Control Panel Center;

Left: The control Panel is right;

Right: The control Panel is on the left;

Top: The topmost part of the control Panel is aligned with the top of the highest object in the current line;

Bottom: The bottom of the control Panel aligns with the baseline of the object in the current line;

Baseline: The bottom of the control Panel is aligned with the baseline of the text;

Texttop: The top of the control Panel is aligned to the top of the highest text in the current line;

Middle: The middle of the control Panel aligns with the baseline of the current line;

Absmiddle: The middle of the control Panel aligns with the middle of the current text or object;

Absbottom: The bottom of the control Panel is aligned with the bottom of the text.

Example: <embed src= "Your.mid" align=top>

<embed src= "Your.mid" align=center>

*************************************************************************************************************** *********************



Insert this piece of code between your You can hear background music when you open a Web site:
<bgsound src=china.mid loop= "-1" >
When the page is minimized, the concert disappears.

Page background Music Code:
<embed src= "Http://XXX.com/XXX.mp3" quality=highpluginspage= "http://www.macromedia.com/shockwave/download/ Index.cgi? P1_prod_version=shockwaveflash "type=" Application/x-shockwave-flash "width=" 1 "height=" 1 "></embed>
1.mid for audio files
<embed src= "1.swf" quality=highpluginspage= "http://www.macromedia.com/shockwave/download/index.cgi? P1_prod_version=shockwaveflash "type=" Application/x-shockwave-flash "width=" 1 "height=" 1 "></embed>
The above page background music code can be added to the absolute address of the Flash animation (or relative address)
<embed width=1 height=1 autostart= "true" loop= "true" Controls=playbutton console=clip1 nolabels=truetype= "audio/ X-pn-realaudio-plugin "src=" 1.ram "></embed>
RAM format music files dedicated page background music code:
<embed src= "1.mid" align= "center" border= "0" width= "1" height= "1" width= "" "autostart=" true "loop=" true ">
Specifies the size of the player (width, heigh), whether it is automatic (autostart tag), whether the loop plays (loop marks), and the viewer can decide whether to play the music autonomously.
This code can be used as a code for inserting Flash animations into a Web page. Just replace the 1.mid with the relative address of the Flash animation or the address on the left is OK.
<embed src= "1.mp3" align= "center" border= "0" width= "1" height= "1" width= "" "autostart=" true "loop=" true ">
This code can add mp3 form of music for the web background music
<embed src= "Http://XXX.com/XXX.mp3" width= "0" height= "0" border=0 autostart= "ture" loop= "Ture" ></EMBED>
1.mid for audio files
<bgsound src= "1.mid" loop=3>
Indicates that the 1.mid audio file is inserted into the page as a background music and played 3 times.
<embed src= "1.mid" hidden= "true" >
1.mid for audio files
<bgsound src= "1.mid" loop= "Infinte" >
1.mid for audio files
<embed src= "1.mid" hidden= "true" loop= "true" >
1.mid for audio files
<bgsound src=1.mid loop= "-1" >
1.mid for audio files

Web background music

The first type: Add <bgsound src= "Music url" loop= "1" > This code between <style></style> in the leaf code.

The point here is that the value in "loop" is the number of times the music cycle can be set to any positive integer, and if set to "1", the music will always loop.

This background music is played directly after the leaves are opened and will not be displayed on the leaves. This is the simplest one.


The second: This method is slightly more complex, but can be set more parameters. Still add a "Embed" tag between the <style></style> tags in the leaf code, and its simplest form is like this:

<embed src= "Music url" autostart= "true" loop= "true" width= "Up" height= ">"

The difference is, here we can set more content, the following is the specific description:

The address of the SRC background music (that is, the URL).
Autostart is automatically played, "true" plays immediately after the music file is read, "False" does not play immediately, the default value is "false"

Loop number of loops, set to "true" for the Perpetual Loop, "false" to play only once, and if set to any positive integer, the number of times the loop is entered.
Volume set the volume, the value range is "0-100", the default value is the system current volume.
StartTime Set the time the music starts playing, in the format "minutes: Seconds",
such as: Starttime= "00:10", is starting from the 10th second play.
Endtime set the time the music ends playing, as in the format above.
Width sets the height of the Music playback Control Panel.
Height sets the altitude of the Music playback Control Panel.
Controls to set the appearance of the music playback Control Panel,
"Console" is the usual panel;
"Smallconsole" is a small panel.
"PlayButton" for whether the play button is displayed;
"Pausebutton" for whether the pause button is displayed;
"Stopbutton" for whether the stop button is displayed;
"Volumelever" for whether the volume adjustment button is displayed,

For example:
Controls= "console/smallconsole/playbutton/
Pausebutton/stopbutton/volumelever ".
Hidden set the display of the Music playback control Panel or not,
"False" is displayed, "true" is hidden.

Now, you can give it a try. Note, however, that the volume of the music file should not be too large, otherwise the page has been open for half a day, but the music has not yet been read. It is recommended to use the WMA format music files.

Here's how to play a movie in a Web page, adding the same method as above.

<embed src= "[/color-red] movie Url[/color]" autostart= "true" loop= "true" width= "" height= ">

RM format with Image:

<object classid= ' CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA ' height=288id=video1 width=305 VIEWASTEXT>
<param name= ' _extentx ' value= ' 5503 ' >
<param name= ' _extenty ' value= ' 1588 ' >
<param name= ' AUTOSTART ' value= '-1 ' >
<param name= ' SHUFFLE ' value= ' 0 ' >
<param name= ' PREFETCH ' value= ' 0 ' >
<param name= ' nolabels ' value= ' 0 ' >
<param name= ' SRC ' value= ' video URL ' >
<param name= ' CONTROLS ' value= ' Imagewindow,statusbar,controlpanel ' >
<param name= ' CONSOLE ' value= ' Raplayer ' >
<param name= ' LOOP ' value= ' 0 ' >
<param name= ' numloop ' value= ' 0 ' >
<param name= ' CENTER ' value= ' 0 ' >
<param name= ' maintainaspect ' value= ' 0 ' >
<param name= ' backgroundcolor ' value= ' #000000 ' >
</OBJECT>

If there is no image of the RM format: such as crosstalk, songs ...

<object id= ' video2 ' width= ' height= ' classid= ' >
<param name= ' _extentx ' value= ' 9657 ' >
<param name= ' _extenty ' value= ' 847 ' >
<param name= ' AUTOSTART ' value= '-1 ' >
<param name= ' SHUFFLE ' value= ' 0 ' >
<param name= ' PREFETCH ' value= ' 0 ' >
<param name= ' nolabels ' value= ' 0 ' >
<param name= ' SRC ' value= ' video URL ' >
<param name= ' CONTROLS ' value= ' Statusbar,controlpanel ' >
<param name= ' CONSOLE ' value= ' Clip1 ' >
<param name= ' LOOP ' value= ' 0 ' >
<param name= ' numloop ' value= ' 0 ' >
<param name= ' CENTER ' value= ' 0 ' >
<param name= ' maintainaspect ' value= ' 0 ' >
<param name= ' backgroundcolor ' value= ' #000000 ' >
</object>

The simplest media format of the player ... Automatically identify if there are no images, but the version is your machine!

<embed src= ' file URL ' width=200height=200 autostart=true loop=true></embed>

Media player with images, automatically calling plugins on the web.

<object id=nstvclassid= ' clsid:6bf52a52-394a-11d3-b153-00c04f79faa6 ' width=280 height=265codebase=http:// activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52
, 701standby=loading Microsoft? Windows Media? Player components...type=application/x-oleobject>
<param name= ' url ' value= ' file URL ' >
<param name= ' uimode ' value= ' full ' ><param name= ' AutoStart ' value= ' true ' >
<param name= ' Enabled ' value= ' true ' >
<param name= ' Enablecontextmenu ' value= ' false ' >
<param name= ' Windowlessvideo ' value= ' true ' ></object>

Media Player without images ... Ditto.

<object id=nstv classid= ' clsid:6bf52a52-394a-11d3-b153-00c04f79faa6 ' width=280 height=60codebase=http:// activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52
, 701standby=loading Microsoft? Windows Media? Player components...type=application/x-oleobject>
<param name= ' url ' value= ' file URL ' >
<param name= ' uimode ' value= ' full ' >
<param name= ' AutoStart ' value= ' true ' >
<param name= ' Enabled ' value= ' true ' >
<param name= ' Enablecontextmenu ' value= ' false ' >
</object>

Just the interface different media plugin player ... This is not recommended, you can look at the situation to do it.

<embed src= ' file url ' type= ' audio/x-pn-realaudio-plugin ' console= ' Clip1 ' controls= ' controlpanel,statusbar ' height= ' "Width= ' 275 ' autostart= ' true ' ></embed>



Background music Code
1. How to paste the Rm,ra,ram type of music, the code is as follows:
<embed width= "0" height= "0" type= "Audio/x-pn-realaudio-plugin" autostart= "true" controls= "ControlPanel" src= "http ://guest.anyp.cn/uploads/01.rm ";>

2. How to paste the midi,asf,wma,asx type of music, the code is as follows:
<embed autostart= "true" loop= "-1" controls= "ControlPanel" width= "0" height= "0" src= "http://guest.anyp.cn/uploads/ 01.mid ";>

Just copy the entire code copy into the article (when editing the article, please click on the HTML code mode and then paste the code, otherwise this code will be displayed as text, can not be executed), with your favorite and available music file URL (URL) instead of the red display of the music address code on it.

Most of the reasons why music cannot be successfully played:
A: Music file error, it is possible that the file itself is not a music file, just a normal HTML page.
B: The music file address is wrong, this music file does not exist at all.
C: No related playback software is installed.

Test method: Please put the music file address in the IE bar input, if you are prompted to save, save the file type is RM, RAM, MIDI and other files are music files. If you open this file to play music automatically or show other content, it is not.

Add Flash with music, then enter your flash address in the pop-up window, note the post-stamp name: http://xxxxx.xxxx, size can be adjusted to, 1*1, so you can play music without showing falsh, but remember to play it automatically, Don't look for flash that needs to press start

Add an online music playback code, recommended: <iframemarginheight=0 src= "http://www.yqchina.com/play.htm"; Frameborder=0noresize width=540 scrolling=no height=25> put this code in the right place of the site, will be 24 hours of uninterrupted singing, the second code by the Wind network radio provided

The following code is provided by [Autumn Wind]: first open my article, enter the editing state, choose HTML format and then you can enter, the following we look at the code, first of all, to see the first, relatively simple:

<bgsound src= "url" loop=-1>
"url" is still the pathname, loop represents the number of loops, 1 means always loop

Look at the second kind:

<embed src= "Music.mid" autostart= "bool" loop= "n" width= "M" height= "K" >

The meanings of each of these properties are as follows:
SRC: Music file path
(optional) AUTOSTART: Automatically play when music files are uploaded, true to play, false to No
Loop: Set loop true to Auto loop, false to No loop, number of times
Width,height for the width and height of the playback control Panel,
The remaining attributes are:
Volume: The value range is "0-100", set the volume, default to the volume of the system itself
StartTime: "Minutes: Seconds", set the time that the song starts to play, such as, starttime= "00:10", starting from the 10th second play
Endtime: "Minutes: Seconds" To set the time at which the song ends playing
Controls: Control Panel appearance controls= "Console/smallconsole/playbutton/pausebutton/stopbutton/volumelever" ·console normal size panel
smallconsole Smaller panels
PlayButton Show Play button
Pausebutton Show Pause button
Stopbutton Show Stop button
volumelever Display Volume adjustment button
Hidden: True when the panel can be hidden

--The following code is provided by the [Wind dance]:
Background Music Code Lite
1, <embed src= "background music url" hidden= "true" autostart= "true" loop= "true" >

--------hidden= "true" means to hide playback, that is, do not show the appearance of the player, to display, "true" to replace "false", so that the default is to minimize playback, if you want to display the size of the player, plus height= "Height value" Width= "width value" is OK.

-------autostart= "True" indicates that the current page is loaded automatically, if you do not want to change to autostart= "false"
Can...

------loop= "true" means that the music is played in an infinite loop until the current page is closed, and you do not want the loop to be replaced with loop= "false" to OK

2, <embed src= "background music url" autostart= "true" loop= "-1" controls= "ControlPanel" width= "0" height= "0" >

-----------loop= "1" means infinite loop playback, can set the number of plays, with a specific number instead, such as I want it to play two times, loop= "2"

---------controls= "ControlPanel" This control option can be omitted

--------width= "0" height= "0" means hide play, as in front.
To set the player's appearance, replace it with a specific value, such as width= "123" height= "100"
--------------------------------------------------
In fact, to say the most simplified playing background music code, then the following code is the simplest--->
<embed src= "background music url" >
-----------------------------------------------------
In addition: Bgsound src= "background music path" loop= "-1" >
This only supports IE browser, and is completely downloaded before starting to play, not as in the previous format can be buffered while playing. This is generally used for mid music or smaller mp3,wav format music. If the larger file or in the format of the previous words ~ ~
<bgsound src= "background music path" loop= "1" > This is played with the opening of the browser, when the window is minimized, it stops playing, and when the window is maximized, it starts playing again.
And, <embed src= "background music url" autostart= "true" loop= "-1" controls= "ControlPanel" width= "0" height= "0" > commonly used in Mid,,wav, MP3 type of music.

This will always play regardless of whether or not the minimized window is played until the current window is closed ~ ~
Supported music file types: supports only the music formats supported by the MP player, such as mp3,asf,wma,asx and so on.
Rm,ram not supported ....
Video files are inserted in the same way as above, set the appropriate
Music Code Explanation
<embed autostart= "true" loop= "-1" controls= "ControlPanel" width= "0" height= "0" src= "http://guest.anyp.cn/uploads/ 01.mid ">
Explain:

Autostart= "True/false"
Do you want to play the music automatically when the music file is finished? TRUE is to
FALSE is not, the default value is not.
loop= "True/false/integer"
Set whether to auto-replay, loop=2 means repeat two times, to repeat available loop= "TRUE" for unlimited times
WIDTH and high= "integers"
Setting the width and height of the control Panel
Controls= "Console/smallconsole/
Playbutton/pausebutton/stopbutton/
Volumelever "
Set the control panel to look like the default value is console



Console General normal panel
Smallconsole smaller panels
PlayButton Show only play button
Pausebutton Show Pause button only
Stopbutton Only Show Stop button
Volumelever only the volume adjustment button is displayed

Add background music to a Web page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.