天天看點

HTML内嵌多媒體

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.

當聲音嵌套在網頁中時,或作為網頁的一部分時,我們稱之為“線内聲音”。

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.

如果你計劃在你的網絡應用程式中使用線内聲音,請注意,很多人是非常讨厭線内聲音的。而且還要注意,有些使用者可能會關閉網絡浏覽器的線内聲音選項。

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:

該元素的用途是在網頁中插入背景音樂。

The code fragment above displays a MIDI file as background music for a web page.

上述代碼片斷顯示了作為網頁背景音樂的MIDI檔案。

<a href="http://blog.51cto.com/example/of/trymedia_soundmidiback" target="_blank">Click here to try it yourself [自己嘗試一下]</a>

A list of attributes for the &lt;bgsound&gt; element can be found in a later chapter of this tutorial.

&lt;bgsound&gt;元素的屬性清單可以在教程的後面章節中找到。

Note: The &lt;bgsound&gt; element is not a standard HTML or XHTML element. It is supported by Internet Explorer only.

注意:&lt;bgsound&gt;元素不是一個标準的HTML或XHTML元素。它隻支援IE。

Internet Explorer supports the dynsrc attribute in the &lt;img&gt; element.

IE 支援&lt;img&gt;元素中的dynsrc屬性。

The purpose of this element is to embed multimedia elements in web page:

該元素的目的是在網頁中嵌套多媒體元素:

The code fragment above displays a WAVE file embedded in a web page.

上述代碼片斷顯示了嵌套在網頁中的WAVE檔案。

<a href="http://blog.51cto.com/example/of/trymedia_soundwaveimg" target="_blank">Click here to try it yourself [自己嘗試一下]</a>

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 &lt;embed&gt;.

IE 和 Netscape浏覽器都支援&lt;embed&gt;元素。

The code fragment above displays a MIDI file embedded in a web page.

上述代碼片斷顯示了嵌套在網頁中的MIDI檔案。

<a href="http://blog.51cto.com/example/of/trymedia_soundmidiembed" target="_blank">Click here to try it yourself [自己嘗試一下]</a>

A list of attributes for the &lt;embed&gt; element can be found in a later chapter of this tutorial.

&lt;embed&gt;元素的屬性清單可以在教程的後面章節中找到。

Note: The &lt;embed&gt; 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 &lt;object&gt; element instead.

注意:&lt;embed&gt;元素可以同時被IE和Netscape浏覽器支援,但是,它并不是标準的HTML元素或XTHML元素。網際網路聯盟(W3C)推薦使用&lt;object&gt;元素來替代。

Internet Explorer and Netscape both support an HTML element called &lt;object&gt;.

IE 和 Netscape浏覽器都支援名為&lt;object&gt;的HTML元素。

<a href="http://blog.51cto.com/example/of/trymedia_soundwaveobject" target="_blank">Click here to try it yourself [自己嘗試一下]</a>

A list of attributes for the &lt;object&gt; element can be found in a later chapter of this tutorial.

&lt;object&gt;元素的屬性清單可以在教程的後面章節中找到。

If a web page includes a hyperlink to a media file, most browsers will use a "helper application" to play the file:

如果網頁包含了指向媒體檔案的超連結,那麼,大多數浏覽器将使用一個“助手程式”來播放檔案:

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檔案。

<a href="http://blog.51cto.com/example/of/trymedia_soundmidilink" target="_blank">Click here to try it yourself [自己嘗試一下]</a>

&lt;OBJECT id=Player  codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701   type=application/x-oleobject height=300  standby="Loading Microsoft Windows Media Player Parts..."  width=350  classid=clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95&gt;

&lt;PARAM NAME="FileName" VALUE="a.asf"&gt;&lt;!--檔案路徑,根據需要修改--&gt;

&lt;PARAM NAME="AutoStart" VALUE="1"&gt;&lt;!--自動播放--&gt;

&lt;PARAM NAME="Loop" VALUE="1"&gt;&lt;!--循環播放--&gt;

&lt;PARAM NAME="ShowStatusBar" VALUE="1"&gt;&lt;!--顯示狀态欄--&gt;

&lt;PARAM NAME="EnableContextMenu" VALUE="0"&gt;&lt;!--屏蔽滑鼠右鍵--&gt;

&lt;!--控制條參數--&gt;

    &lt;PARAM NAME="ShowControls" VALUE="0"&gt;&lt;!--隐藏控制條--&gt;

    &lt;PARAM NAME="ShowPositionControls" VALUE="1"&gt;&lt;!--顯示位置控制--&gt;

    &lt;PARAM NAME="ShowAudioControls" VALUE="1"&gt;&lt;!--顯示音量控制--&gt;

    &lt;PARAM NAME="ShowTracker" VALUE="1"&gt;&lt;!--顯示進度條--&gt;

  &lt;/OBJECT&gt;

realplayer:

      &lt;!--以下為主播放視窗--&gt;

&lt;object classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA width=400 height=200 id=RP1&gt;

        &lt;param name="CONSOLE" value="clip1"&gt;

        &lt;param name="CONTROLS" value="imagewindow"&gt;

        &lt;param name="SRC" value="b.rm"&gt;

        &lt;!--檔案路徑,根據需要調整--&gt;

        &lt;param name="AUTOSTART" value="1"&gt;

        &lt;!--自動播放--&gt;

        &lt;param name="LOOP" value="1"&gt;

        &lt;!--循環播放--&gt;

        &lt;param name="MAINTAINASPECT" value="1"&gt;

        &lt;!--保持影片不被拉伸扭曲--&gt;

        &lt;param name="BACKGROUNDCOLOR" value="#000000"&gt;

&lt;!--空白區域背景色--&gt;

&lt;/object&gt; 

&lt;主播放視窗結束--&gt;

&lt;!--以下為控制條,可根據需要選擇是否在頁面添加--&gt;

 &lt;object id=RP2 height=30 width=400 classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA&gt;

        &lt;param name="CONTROLS" value="ControlPanel"&gt;

    &lt;/object&gt;

&lt;!--控制條完畢--&gt;

&lt;object id="player" height="200" width="240" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"&gt;

&lt;!--是否透明--&gt;

&lt;param name="wmode" value="transparent"&gt;

&lt;param name="AutoStart" VALUE="-1"&gt;

&lt;!--是否自動播放--&gt;

&lt;param name="Balance" VALUE="0"&gt;

&lt;!--調整左右聲道平衡,同上面舊播放器代碼--&gt;

&lt;param name="enabled" value="-1"&gt;

&lt;!--播放器是否可人為控制--&gt;

&lt;param name="EnableContextMenu" VALUE="-1"&gt;

&lt;!--是否啟用上下文菜單--&gt;

&lt;!--播放的檔案位址--&gt;

&lt;param name="PlayCount" VALUE="1"&gt;

&lt;!--播放次數控制,為整數--&gt;

&lt;param name="rate" value="1"&gt;

&lt;!--播放速率控制,1為正常,允許小數,1.0-2.0--&gt;

&lt;param name="currentPosition" value="0"&gt;

&lt;!--控件設定:目前位置--&gt;

&lt;param name="currentMarker" value="0"&gt;

&lt;!--控件設定:目前标記--&gt;

&lt;param name="defaultFrame" value=""&gt;

&lt;!--顯示預設架構--&gt;

&lt;param name="invokeURLs" value="0"&gt;

&lt;!--腳本指令設定:是否調用URL--&gt;

&lt;param name="baseURL" value=""&gt;

&lt;!--腳本指令設定:被調用的URL--&gt;

&lt;param name="stretchToFit" value="0"&gt;

&lt;!--是否按比例伸展--&gt;

&lt;param name="volume" value="50"&gt;

&lt;!--預設聲音大小0%-100%,50則為50%--&gt;

&lt;param name="mute" value="0"&gt;

&lt;!--是否靜音--&gt;

&lt;param name="uiMode" value="mini"&gt;

&lt;!--播放器顯示模式:Full顯示全部;mini最簡化;None不顯示播放控制,隻顯示視訊視窗;invisible全部不顯示--&gt;

&lt;param name="windowlessVideo" value="0"&gt;

&lt;!--如果是0可以允許全屏,否則隻能在視窗中檢視--&gt;

&lt;param name="fullScreen" value="0"&gt;

&lt;!--開始播放是否自動全屏--&gt;

&lt;param name="enableErrorDialogs" value="-1"&gt;

&lt;!--是否啟用錯誤提示報告--&gt;

&lt;param name="SAMIStyle" value&gt;

&lt;!--SAMI樣式--&gt;

&lt;param name="SAMILang" value&gt;

&lt;!--SAMI語言--&gt;

&lt;param name="SAMIFilename" value&gt;

&lt;!--字幕ID--&gt;

&lt;/object&gt;

本文轉自lidup 51CTO部落格,原文連結:http://blog.51cto.com/lidup/317823,如需轉載請自行聯系原作者

繼續閱讀