视频已经在 Web 上广泛流行了,但是其格式几乎都是专有的。YouTube 使用 Flash,Microsoft 使用 Windows Media®,Apple 使用 QuickTime。在一种浏览器中用来嵌入这些内容的标记在另一种浏览器中是无效的。因此, WhatWG 提议引入一个新的 video 元素,用来嵌入任意视频格式。例如,可以用以下代码嵌入我的 QuickTime 电影 “a Sora in Prospect Park”:
1: <video src="http://www.cafeaulait.org/birds/sora.mov" />
对于以哪种格式和解码器作为首选,仍然有争议。可能会强力推荐或要求使用 Ogg Theora。还可以可选地支持 QuickTime 等专有格式和 MPEG-4 等受专利限制的格式。实际使用的格式很可能由市场决定,就像是 GIF、JPEG 和 PNG 格式那样(这些格式通过市场竞争压倒了 BMP、X-Bitmap 和 JPEG 2000 等竞争者,成为 img 元素的首选格式)。
还提议引入 audio 元素。例如,可以使用以下代码给 Web 页面加上背景音乐:
1: <audio src="spacemusic.mp3" autoplay="autoplay" loop="20000" />
autoplay 属性指示浏览器在装载页面后立即开始播放,而不等待明确的用户请求。音频循环播放 20,000 次,然后停止(或者在用户关闭窗口或转到另一个页面时停止)。当然,浏览器可以(而且应该)允许用户关闭内嵌的媒体,不应该只按页面作者的要求去做。
浏览器必须支持 WAV 格式,还可以支持 MP3 等其他格式。
因为老式浏览器不支持这些元素,而且它们对于盲人和聋人用户来说没有意义,所以 audio 和 video 元素可以包含额外的标记,用来描述音频和视频的内容。这对搜索引擎也有帮助。在理想情况下,这些标记是音频和视频内容的完整文字版本。例如,代码8 显示 用 HTML 5 编写的 John F. Kennedy 的就职演说。
1: <audio src="kennedyinauguraladdrees.mp3">
2: <p>
3: Vice President Johnson, Mr. Speaker, Mr. Chief Justice, 4: President Eisenhower, Vice President Nixon, President Truman, 5: Reverend Clergy, fellow citizens:6: </p>
7: 8: <p>
9: We observe today not a victory of party, but a celebration of 10: freedom -- symbolizing an end, as well as a beginning -- 11: signifying renewal, as well as change. For I have sworn before 12: you and Almighty God the same solemn oath our forebears 13: prescribed nearly a century and three-quarters ago.14: </p>
15: 16: <p>
17: The world is very different now. For man holds in his mortal 18: hands the power to abolish all forms of human poverty and all 19: forms of human life. And yet the same revolutionary beliefs for 20: which our forebears fought are still at issue around the globe -- 21: the belief that the rights of man come not from the 22: generosity of the state, but from the hand of God.23: </p>
24: 25: <p>
26: ...27: </p>
28: 29: </audio>
转载自:52CSS