點評: 視頻已經在Web 上廣泛流行了,但是其格式幾乎都是專有的。 YouTube 使用Flash,Microsoft 使用Windows Media®,Apple 使用QuickTime。在一種瀏覽器中用來嵌入這些內容的標記在另一種瀏覽器中是無效的。因此,WhatWG 提議引入一個新的video 元素,用來嵌入任意視
視頻已經在Web 上廣泛流行了,但是其格式幾乎都是專有的。 YouTube 使用Flash,Microsoft 使用Windows Media®,Apple 使用QuickTime。在一種瀏覽器中用來嵌入這些內容的標記在另一種瀏覽器中是無效的。因此,WhatWG 提議引入一個新的video 元素,用來嵌入任意視頻格式。例如,可以用以下代碼嵌入我的QuickTime 電影a Sora in Prospect Park:
<video src= />
對於以哪種格式和解碼器作為首選,仍然有爭議。可能會強力推薦或要求使用Ogg Theora。還可以可選地支持QuickTime 等專有格式和MPEG-4 等受專利限制的格式。實際使用的格式很可能由市場決定,就像是GIF、JPEG 和PNG 格式那樣(這些格式通過市場競爭壓倒了BMP、X-Bitmap 和JPEG 2000 等競爭者,成為img 元素的首選格式)。
還提議引入audio 元素。例如,可以使用以下代碼給Web 頁面加上背景音樂:
<audio src=spacemusic.mp3 autoplay=autoplay loop=20000 />
autoplay 屬性指示瀏覽器在裝載頁面後立即開始播放,而不等待明確的用戶請求。音頻循環播放20,000 次,然後停止(或者在用戶關閉窗口或轉到另一個頁面時停止)。當然,瀏覽器可以(而且應該)允許用戶關閉內嵌的媒體,不應該只按頁面作者的要求去做。
瀏覽器必須支持WAV 格式,還可以支持MP3 等其他格式。
因為老式瀏覽器不支持這些元素,而且它們對於盲人和聾人用戶來說沒有意義,所以audio 和video 元素可以包含額外的標記,用來描述音頻和視頻的內容。這對搜索引擎也有幫助。在理想情況下,這些標記是音頻和視頻內容的完整文字版本。例如,代碼8 顯示用HTML 5 編寫的John F. Kennedy 的就職演說。
<audio src=kennedyinauguraladdrees.mp3>
<p>
Vice President Johnson, Mr. Speaker, Mr. Chief Justice,
President Eisenhower, Vice President Nixon, President Truman,
Reverend Clergy, fellow citizens:
</p>
<p>
We observe today not a victory of party, but a celebration of
freedom -- symbolizing an end, as well as a beginning --
signifying renewal, as well as change. For I have sworn before
you and Almighty God the same solemn oath our forebears
prescribed nearly a century and three-quarters ago.
</p>
<p>
The world is very different now. For man holds in his mortal
hands the power to abolish all forms of human poverty and all
forms of human life. And yet the same revolutionary beliefs for
which our forebears fought are still at issue around the globe --
the belief that the rights of man come not from the
generosity of the state, but from the hand of God.
</p>
<p>
...
</p>
</audio>
(待續)