ÍøÂçѧԺ w3popÉçÇø ÍøÂç×ÊÔ´ ITÐÂÎÅ

w3pop.com :: ÍøÂçѧԺ :: Internet :: ÔÚÍøÂçÖв¥·ÅÒôƵ

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

Internet
TCP/IP ½éÉÜ
TCP/IP µØÖ·
TCP/IP ЭÒé
TCP/IP µç×ÓÓʼþ
ÍøÕ¾½¨Éè
ÍøÂçÉè¼Æ
ÍøÂçÓû§
ÍøÂç±ê×¼
ÍøÒ³ÈÏÖ¤
ÍòÎ¬ÍøÁªÃË
ÍøÂ簲ȫ
ÍøÂçÊõÓï±í
ÍøÂçËÑË÷ÒýÇæ
ÍøÂç¶àýÌå¼ò½é
¶àýÌåÒôƵ¸ñʽ
¶àýÌåÊÓÆµ¸ñʽ
ÔÚÍøÂçÖв¥·ÅÒôƵ
ÔÚÍøÂçÖв¥·ÅÊÓÆµ
Windows¶àýÌå¸ñÊ..
¶ÔÏóÔªËØ

ÔÚÍøÂçÖв¥·ÅÒôƵ


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-29 ä¯ÀÀ:5124 :: ::

Sounds can be played "inline" or by a "helper", depending on the HTML element you use.
ÉùÒô¿ÉÒÔÔÚ“ÏßÄÚ”²¥·Å»ò×÷Ϊ“ÌáʾÒô”£¬Ö÷Òª¸ù¾ÝÄãËùʹÓõÄHTMLÔªËØÀ´¾ö¶¨¡£


Inline Sound
ÏßÄÚÉùÒô

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.
ÎÒÃǵÄ×î¼Ñ½¨ÒéÊÇ£º½öÔÚÄÇЩÓû§Ï£ÍûÌýµ½ÉùÒôµÄÒ³ÃæÖмÓÔØÉùÒô¡£ÆäÖеÄÒ»¸ö°¸ÀýÊÇ£ºÔÚÓû§µã»÷Ò»¸öÁ´½ÓÖ®ºóÌýµ½ÉùÒôʱÔÚ´ò¿ªÒ³Ãæ¡£


Using A Helper (Plug-In)
ʹÓÃÔÚÏßÖúÊÖ£¨ÄÚÖòå¼þ£©

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.
´ó¶àÊýÖúÊÖ³ÌÐòÖ§³ÖʹÓÃÊÖ¶¯£¨»ò³ÌÐò£©À´¿ØÖÆÒôÁ¿ÊôÐԺͲ¥·Åº¯Êý£¬Èç£ºÖØ¸´¡¢ÔÝÍ£¡¢Í£Ö¹ºÍ²¥·Å¡£


Using The <bgsound> Element
ʹÓÃ<bgsound>ÔªËØ

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¡£


Using The <img> Element
ʹÓÃ<img>ÔªËØ

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¡£


Using The <embed> Element
ʹÓÃ<embed>ÔªËØ

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>ÔªËØÀ´Ìæ´ú¡£


Using The <object> Element
ʹÓÃ<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
classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
<param name="FileName" value="liar.wav" />
</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>ÔªËØµÄÊôÐÔÁбí¿ÉÒÔÔڽ̵̳ĺóÃæÕ½ÚÖÐÕÒµ½¡£


Using A Hyperlink
ʹÓÃÒ»¸ö³¬Á´½Ó

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">
Click here to play the Beatles
</a>

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