HTML Video
- Previous Page HTML Audio
- Next Page HTML YouTube
在 HTML 中播放视频的方法有很多种。
Example
<video width="320" height="240" controls="controls"> <source src="movie.mp4" type="video/mp4" /> <source src="movie.ogg" type="video/ogg" /> <source src="movie.webm" type="video/webm" /> <object data="movie.mp4" width="320" height="240"> <embed src="movie.swf" width="320" height="240" /> </object> </video>
问题,问题,以及解决方法
在 HTML 中播放视频并不容易!
您需要谙熟大量技巧,以确保您的视频文件在所有浏览器中(Internet Explorer, Chrome, Firefox, Safari, Opera)和所有硬件上(PC, Mac , iPad, iPhone)都能够播放。
在本章,CodeW3C.com 为您总结了问题和解决方法。
使用
下面的 HTML 代码显示嵌入网页的 Flash 视频:
Example
Rashin samu
- HTML4 无法识别
- 如果浏览器不支持 Flash,那么视频将无法播放
- iPad 和 iPhone 不能显示 Flash 视频。
- 如果您将视频转换为其他格式,那么它仍然不能在所有浏览器中播放。
使用
下面的 HTML 片段显示嵌入网页的一段 Flash 视频:
Example
Rashin samu
- 如果浏览器不支持 Flash,将无法播放视频。
- iPad 和 iPhone 不能显示 Flash 视频。
- 如果您将视频转换为其他格式,那么它仍然不能在所有浏览器中播放。
使用
<video> kaiyance yana kaiya fim a rufe a hukun yanar gizo na HTML.
Rarraba HTML na yau zai kaiya fim a rufe ogg, mp4 ko webm a hukun yanar gizo:
Example
<video width="320" height="240" controls="controls"> <source src="movie.mp4" type="video/mp4" /> <source src="movie.ogg" type="video/ogg" /> <source src="movie.webm" type="video/webm" /> Kaiyance ya samu rashin samu fim a kowace yanar gizo. </video>
Rashin samu
- Ka samu fim a yawa dake dake.
- <video> kaiyance yana kaiya rashin samu a kowace yanar gizo da ya tsara.
- <video> kaiyance yana kaiya rashin duba da HTML 4 da XHTML.
Hakimi HTML kama yana samu
HTML 5 + <object> + <embed>
<video width="320" height="240" controls="controls"> <source src="movie.mp4" type="video/mp4" /> <source src="movie.ogg" type="video/ogg" /> <source src="movie.webm" type="video/webm" /> <object data="movie.mp4" width="320" height="240"> <embed src="movie.swf" width="320" height="240" /> </object> </video>
An gina fim a 4 nau'ikan a cikin tasiri na yau. HTML 5 <video> kaiyance yana samu fim a kowace dake dake daga mp4, ogg ko webm don rufe fim. Bugu da ɗaya, kaiyance yana samu <embed> kaiyance.
Rashin samu
- Ka samu fim a yawa dake dake.
- <video> kaiyance yana kaiya rashin duba da HTML 4 da XHTML.
- <embed> kaiyance yana kaiya rashin duba da HTML 4 da XHTML.
Rarrabawa:A samu rashin duba da <!DOCTYPE html> (HTML5) don samu rashin duba.
Hakimi youku
Yanar gizo kama yana samu fim a HTML, ka gina ganin youku da saurayi yanar gizo.
Iya ka da kaiya fim a hukun yanar gizo, ka kaiya fim a youku da saurayi yanar gizo, kuma ka kaiya koda HTML a hukun yanar gizo, ka kaiya fim a rufe:
<embed src="http://player.youku.com/player.php/sid/XMzI2NTc4NTMy/v.swf" width="480" height="400" type="application/x-shockwave-flash"> </embed>
Using Hyperlinks
If the web page contains hyperlinks to media files, most browsers will use an "assistant application" to play the file.
The following code snippet shows a link to an AVI file. If the user clicks on the link, the browser will launch an "assistant application", such as Windows Media Player, to play this AVI file:
Example
<a href="movie.swf">Play a video file</a>
A note about inline video
When video is included in a web page, it is called inline video.
If you plan to use inline video in a web application, you need to be aware that many people find inline video annoying.
At the same time, please note that the user may have already turned off the inline video option in the browser.
Our best advice is to only include them where the user wants to see inline video. A positive example is, when the user needs to see the video and click on a link, the page opens and the video plays.
HTML 4.01 Multimedia Tags
Tag | Description |
---|---|
<applet> | Not Recommended.Define embedded applet. |
<embed> | Not Recommended.Define embedded objects. (Allowed in HTML5) |
<object> | Define embedded objects. |
<param> | Define object parameters. |
HTML 5 Multimedia Tags
Tag | Description |
---|---|
<video> | Tags define sounds, such as music or other audio streams. |
<embed> | Tags define embedded content, such as plugins. |
- Previous Page HTML Audio
- Next Page HTML YouTube