w3pop.com :: ÍøÂçѧԺ :: Internet :: ÔÚÍøÂçÖв¥·ÅÒôƵ
Sounds can be played "inline" or by a "helper", depending on the HTML element you use.
ÉùÒô¿ÉÒÔÔÚ“ÏßÄÚ”²¥·Å»ò×÷Ϊ“ÌáʾÒô”£¬Ö÷Òª¸ù¾ÝÄãËùʹÓõÄHTMLÔªËØÀ´¾ö¶¨¡£
When sound is included in a web page, or as part of a web page, it is called inline sound.
µ±ÉùÒôǶÌ×ÔÚÍøÒ³ÖÐʱ£¬»ò×÷ÎªÍøÒ³µÄÒ»²¿·Öʱ£¬ÎÒÃdzÆÖ®Îª“ÏßÄÚÉùÒô”¡£
Inline sound can be added to a web page by using the <bgsound> element or the <img> element.
ÏßÄÚÉùÒô¿ÉÒÔͨ¹ý<bgsound>ÔªËØ»ò<img>ÔªËØÌí¼Óµ½ÍøÒ³ÖС£
If you plan to use inline sounds in your web applications, be aware that many people find inline sound annoying. Also note that some users might have turned off the inline sound option in their browser.
Èç¹ûÄã¼Æ»®ÔÚÄãµÄÍøÂçÓ¦ÓóÌÐòÖÐʹÓÃÏßÄÚÉùÒô£¬Çë×¢Ò⣬ºÜ¶àÈËÊǷdz£ÌÖÑáÏßÄÚÉùÒôµÄ¡£¶øÇÒ»¹Òª×¢Ò⣬ÓÐЩÓû§¿ÉÄÜ»á¹Ø±ÕÍøÂçä¯ÀÀÆ÷µÄÏßÄÚÉùÒôÑ¡Ïî¡£
Our best advice is to include inline sound only in web pages where the user expects to hear the sound. An example of this is a page which opens after the user has clicked on a link to hear a recording.
ÎÒÃǵÄ×î¼Ñ½¨ÒéÊÇ£º½öÔÚÄÇЩÓû§Ï£ÍûÌýµ½ÉùÒôµÄÒ³ÃæÖмÓÔØÉùÒô¡£ÆäÖеÄÒ»¸ö°¸ÀýÊÇ£ºÔÚÓû§µã»÷Ò»¸öÁ´½ÓÖ®ºóÌýµ½ÉùÒôʱÔÚ´ò¿ªÒ³Ãæ¡£
A helper application is a program that can be launched by the browser to "help" playing sound. Helper applications are also called Plug-Ins.
ÖúÊÖ³ÌÐòʹÓÃÓ뼤·¢²¥·Åä¯ÀÀÆ÷ÄÚÉùÒôµÄÓ¦ÓóÌÐò¡£ÖúÊÖ³ÌÐòÒ²¿ÉÒÔ½Ð×ö²å¼þ³ÌÐò¡£
Helper applications can be launched using the <embed> element, the <applet> element, or the <object> element.
ÖúÊÖ³ÌÐò¿ÉÒÔʹÓÃ<embed>ÔªËØ¡¢<applet>ÔªËØ»ò<object>ÔªËØÀ´¼¤·¢¡£
One great advantage of using a helper application is that you can let some (or all) of the player settings be controlled by the user.
ʹÓÃÖúÊÖ³ÌÐòµÄÒ»¸ö×î´óµÄºÃ´¦¾ÍÊÇ£ºÄã¿ÉÒÔÈÃÓû§À´¿ØÖƲ¥·ÅÆ÷ÉèÖóÌÐò¡£
Most helper applications allows manually (or programmed) control over the volume settings and play functions like rewind, pause, stop and play.
´ó¶àÊýÖúÊÖ³ÌÐòÖ§³ÖʹÓÃÊÖ¶¯£¨»ò³ÌÐò£©À´¿ØÖÆÒôÁ¿ÊôÐԺͲ¥·Åº¯Êý£¬Èç£ºÖØ¸´¡¢ÔÝÍ£¡¢Í£Ö¹ºÍ²¥·Å¡£
Internet Explorer supports an element called <bgsound>.
IEÖ§³Ö<bgsound>ÔªËØ¡£
The purpose of this element is to provide a background sound for a web page:
¸ÃÔªËØµÄÓÃ;ÊÇÔÚÍøÒ³ÖвåÈë±³¾°ÒôÀÖ¡£
<bgsound src="beatles.mid" /> |
The code fragment above displays a MIDI file as background music for a web page.
ÉÏÊö´úÂëÆ¬¶ÏÏÔʾÁË×÷ÎªÍøÒ³±³¾°ÒôÀÖµÄMIDIÎļþ¡£
Click here to try it yourself [×Ô¼º³¢ÊÔÒ»ÏÂ]
A list of attributes for the <bgsound> element can be found in a later chapter of this tutorial.
<bgsound>ÔªËØµÄÊôÐÔÁбí¿ÉÒÔÔڽ̵̳ĺóÃæÕ½ÚÖÐÕÒµ½¡£
Note: The <bgsound> element is not a standard HTML or XHTML element. It is supported by Internet Explorer only.
×¢Ò⣺<bgsound>ÔªËØ²»ÊÇÒ»¸ö±ê×¼µÄHTML»òXHTMLÔªËØ¡£ËüÖ»Ö§³ÖIE¡£
Internet Explorer supports the dynsrc attribute in the <img> element.
IE Ö§³Ö<img>ÔªËØÖеÄdynsrcÊôÐÔ¡£
The purpose of this element is to embed multimedia elements in web page:
¸ÃÔªËØµÄÄ¿µÄÊÇÔÚÍøÒ³ÖÐǶÌ×¶àýÌåÔªËØ£º
<img dynsrc="horse.wav" /> |
The code fragment above displays a WAVE file embedded in a web page.
ÉÏÊö´úÂëÆ¬¶ÏÏÔʾÁËǶÌ×ÔÚÍøÒ³ÖеÄWAVEÎļþ¡£
Click here to try it yourself [×Ô¼º³¢ÊÔÒ»ÏÂ]
Note: The dynsrc attribute is not a standard HTML or XHTML attribute. It is supported by Internet Explorer only.
×¢Ò⣺dynsrcÊôÐÔ²»ÊÇÒ»¸ö±ê×¼µÄHTML»òXHTMLÔªËØ¡£ËüÖ»Ö§³ÖIE¡£
Internet Explorer and Netscape both support an element called <embed>.
IE ºÍ Netscapeä¯ÀÀÆ÷¶¼Ö§³Ö<embed>ÔªËØ¡£
The purpose of this element is to embed multimedia elements in web page:
¸ÃÔªËØµÄÄ¿µÄÊÇÔÚÍøÒ³ÖÐǶÌ×¶àýÌåÔªËØ£º
<embed src="beatles.mid" /> |
The code fragment above displays a MIDI file embedded in a web page.
ÉÏÊö´úÂëÆ¬¶ÏÏÔʾÁËǶÌ×ÔÚÍøÒ³ÖеÄMIDIÎļþ¡£
Click here to try it yourself [×Ô¼º³¢ÊÔÒ»ÏÂ]
A list of attributes for the <embed> element can be found in a later chapter of this tutorial.
<embed>ÔªËØµÄÊôÐÔÁбí¿ÉÒÔÔڽ̵̳ĺóÃæÕ½ÚÖÐÕÒµ½¡£
Note: The <embed> element is supported by both Internet Explorer and Netscape, but it is not a standard HTML or XHTML element. The World Wide Web Consortium (W3C) recommend using the <object> element instead.
×¢Ò⣺<embed>ÔªËØ¿ÉÒÔͬʱ±»IEºÍNetscapeä¯ÀÀÆ÷Ö§³Ö£¬µ«ÊÇ£¬Ëü²¢²»ÊDZê×¼µÄHTMLÔªËØ»òXTHMLÔªËØ¡£ÍòÎ¬ÍøÁªÃË£¨W3C£©ÍƼöʹÓÃ<object>ÔªËØÀ´Ìæ´ú¡£
Internet Explorer and Netscape both support an HTML element called <object>.
IE ºÍ Netscapeä¯ÀÀÆ÷¶¼Ö§³ÖÃûΪ<object>µÄHTMLÔªËØ¡£
The purpose of this element is to embed multimedia elements in web page:
¸ÃÔªËØµÄÄ¿µÄÊÇÔÚÍøÒ³ÖÐǶÌ×¶àýÌåÔªËØ£º
<object |
The code fragment above displays a WAVE file embedded in a web page.
ÉÏÊö´úÂëÆ¬¶ÏÏÔʾÁËǶÌ×ÔÚÍøÒ³ÖеÄWAVEÎļþ¡£
Click here to try it yourself [×Ô¼º³¢ÊÔÒ»ÏÂ]
A list of attributes for the <object> element can be found in a later chapter of this tutorial.
<object>ÔªËØµÄÊôÐÔÁбí¿ÉÒÔÔڽ̵̳ĺóÃæÕ½ÚÖÐÕÒµ½¡£
If a web page includes a hyperlink to a media file, most browsers will use a "helper application" to play the file:
Èç¹ûÍøÒ³°üº¬ÁËÖ¸ÏòýÌåÎļþµÄ³¬Á´½Ó£¬ÄÇô£¬´ó¶àÊýä¯ÀÀÆ÷½«Ê¹ÓÃÒ»¸ö“ÖúÊÖ³ÌÐò”À´²¥·ÅÎļþ£º
<a href="beatles.mid"> |
The code fragment above displays a link to a MIDI file. If the user clicks on the link, the browser will launch a helper application like Windows Media Player to play the MIDI file.
ÉÏÊö´úÂëÆ¬¶ÏÏÔʾÁËǶÌ×ÔÚÍøÒ³ÖеÄMIDIÎļþ¡£Èç¹ûÓû§µã»÷ÁËÁ´½Ó£¬ÄÇôä¯ÀÀÆ÷ÖúÊÖ³ÌÐòÈçWindows Media Player½«²¥·ÅMIDIÎļþ¡£
Click here to try it yourself [×Ô¼º³¢ÊÔÒ»ÏÂ]
ÆÀÂÛ (0)
All