手机
当前位置:查字典教程网 >网页设计 >HTML5教程 >HTML5的结构和语义(5):内嵌媒体
HTML5的结构和语义(5):内嵌媒体
摘要:视频已经在Web上广泛流行了,但是其格式几乎都是专有的。YouTube使用Flash,Microsoft使用WindowsMedia®...

视频已经在 Web 上广泛流行了,但是其格式几乎都是专有的。YouTube 使用 Flash,Microsoft 使用 Windows Media®,Apple 使用 QuickTime。在一种浏览器中用来嵌入这些内容的标记在另一种浏览器中是无效的。因此,WhatWG 提议引入一个新的 video 元素,用来嵌入任意视频格式。例如,可以用以下代码嵌入我的 QuickTime 电影 “a Sora in Prospect Park”:

<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 页面加上背景音乐:

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

(待续)

【HTML5的结构和语义(5):内嵌媒体】相关文章:

HTML5引入的新数组TypedArray介绍

HTML 5 令人期待的 5 项功能

基于HTML5的齿轮动画特效

HTML5中的新元素介绍

HTML5实现锚点时请使用id取代name

HTML5的Input 类型简介

HTML5安全介绍之内容安全策略(CSP)简介

HTML5新增的表单元素和属性实例解析

使用HTML5的表单验证的简单示例

HTML5 对各个标签的定义与规定:base

精品推荐
分类导航