Play Video on Web

根据您所使用的 HTML 元素,视频可“内联地”或通过某种“助手”进行播放。

内联视频(Inline Videos)

当视频被包含在网页中,或作为网页的一部份,它就被称为内联视频。

通过使用 元素,可向网页添加内联视频。

如果你计划在 web 应用程序中使用内联视频,您需要清楚一点,就是许多人对内联视频非常讨厌。也请注意,一些用户也许已经在他们的浏览器中关闭了内联视频的选项。

我们的建议是,最近仅仅在用户希望听到声音的地方包含内联视频。比方说在用户打开页面后,点击某个链接来观看视频。

使用助手(Plug-In,插件)

助手应用程序,是一种可通过浏览器启动来“帮助”浏览器播放视频的程序。助手应用程序也称为插件(Plug-Ins)。

助手应用程序可通过使用 元素来启动,或者 元素及 元素。

使用助手应用程序的一项巨大优势是,允许用户控制播放器的某些设置。

大多数助手应用程序允许手动地或通过编程控制音量设置以及播放功能,比如回放、暂停、停止和播放。

使用 元素

Internet Explorer 支持 元素中的 dynsrc 属性。

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

上面的代码片断为网页设置了一个嵌入的 AVI 文件。

Note:dynsrc 属性不是标准的 HTML 或 XHTML 元素。仅有 Internet Explorer 支持该属性。

使用 元素

Internet Explorer 和 Netscape 都支持 元素。

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

上面的代码片断为网页设置了一个嵌入的 AVI 文件。

您可在本教程的最后一节找到 元素的属性列表。

Note:Internet Explorer and Netscape both support the <embed> element, but it is not a standard HTML or XHTML element. The World Wide Web Consortium (W3C) recommends using the <object> element instead.

Using <object> element

Internet Explorer and Netscape both support the <object> element.

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

<object data="video.avi" type="video/avi" />

The above code snippet embeds an AVI file in the web page.

You can find the list of attributes for the <object> element in the last section of this tutorial.

Using Hyperlinks

If a web page contains a hyperlink to a media file, most browsers will use an "assistant program" to play the file:

<a href="video.avi">Click here to play the video file</a>

The above code snippet sets a link to an AVI file. If the user clicks on the link, the browser will launch an assistant program (such as Windows Media Player) to play the AVI file.