Use audio in Webpage

Source: Internet
Author: User

1. <bgsound> is used to insert background music, but only applies to IE.

<Bgsound src = "" autostart = "true" loop = "-1"/>

Parameter description:

Parameters Description
Src Set the midi path, which can be relative or absolute.
Autostart Whether to play the video automatically after the music is downloaded. True Yes, false no (default)
Loop Whether to enable automatic replay. Loop = 2 indicates repeated twice, loop =-1 indicates infinite Loops

 

2. <embed> is used to insert various multimedia files in the format of midi, wav, aiff, and au.

<Embed src = "" autostart = "true" loop = "true" hidden = "true"/>

Parameter description:

Parameters Description
Src Path
Autostart Whether to play the video automatically after the music is downloaded. True Yes, false no (default)
Loop Whether to enable automatic replay. Loop = 2 indicates Repeat twice, true is, false is not.
Hidden Whether the control screen is completely hidden. True: Yes; false: No.
Starttime = "minute: second" Set the start time of the song. For example, starttime = "" indicates that playback starts from 30th seconds.
Volume Set the volume. The value ranges from 0 to 100. The internal setting is the system's own setting.
Width = "integer" and high = "integer" Set the height and width of the Control Panel
Align Sets the alignment of the control panel and text next to it. The values can be top, bottom, center, baseline, left, right, texttop, middle, absmiddle, and absbottom.
Controls Set the control panel appearance. The default value is console. Console: normal Panel; smallconsole: smaller panel; playbutton: show only the playback button; pausecutton: show only the pause button; stopbutton: show only the stop button; volumelever: only the volume adjustment button is displayed;
Units Unit: pixels or en
Name Object Name
Title Description
Palette Foreground color and background color. Syntax: palette = "color | color"

Example 1:

<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
<Script language = "javascript" type = "text/javascript">
// Use javascript to control audio playback
Function ManageSoundControl (action ){
Var soundControl = document. getElementById ("soundControl ");
If (action = "play "){
SoundControl. play ();
}
If (action = "stop "){
SoundControl. stop ();
}
}
</Script>
</Head>
<Body>
<Form id = "form1" runat = "server">
& Lt; table width = "100%" & gt;
<Tr>
<Td>
<Embed id = "soundControl" src = "*. mp3" mastersound hidden = "true" loop = "false" autostart = "false"> </embed>
<Input id = "btPlay" type = "button" value = "play" onclick = "ManageSoundControl ('play')"/>
<Input id = "btStop" type = "button" value = "stop" onclick = "ManageSoundControl ('stop')"/>
</Td>
</Tr>
</Table>
</Form>
</Body>
</Html>

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.