Html 如何链接到我网站中的 .mp4 视频?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7172386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:13:17  来源:igfitidea点击:

How can I link to an .mp4 video in my site?

htmlvideomp4video-player

提问by novellino

I have a web site and I want to link a button to a video. So whenever someone clicks the "video" buttons let's say, I want to open the video.mp4in a new browser. What I do is:

我有一个网站,我想将一个按钮链接到一个视频。因此,每当有人单击“视频”按钮时,比如说,我想video.mp4在新浏览器中打开。我要做的是:

<a href="videos/engine/swf/player.swf?url=../../data/video.mp4&volume=100" target="_blank"><div>...</div></a>

The video is quite big (190MB) so the code above is not working. I start listening to the sound but cannot see the image.

视频很大(190MB)所以上面的代码不起作用。我开始听声音但看不到图像。

Does anyone know how to do it? Or any simple way to just open this video as a link?

有谁知道怎么做?或者有什么简单的方法可以将这个视频作为链接打开?

采纳答案by No_or_yes

You could use HTML5 tag don't forget that MP4 is only supported by IE 9+, Chrome 5+ and Safari 3+. You should at least convert your file to WebM or Ogg to make it compatible with all recent browsers. To do so you would need a new page (where the link goes) and in this page have this code:

您可以使用 HTML5 标签不要忘记 MP4 仅支持 IE 9+、Chrome 5+ 和 Safari 3+。您至少应该将您的文件转换为 WebM 或 Ogg 以使其与所有最近的浏览器兼容。为此,您需要一个新页面(链接所在的位置)并在此页面中包含以下代码:

<video width="320" height="240" controls="controls">
  <source src="movie.ogg" type="video/ogg" />
  <source src="movie.mp4" type="video/mp4" />
  <source src="movie.webm" type="video/webm" />
  Your browser does not support the video tag.
  /* instead of the last line you could also add the flash player*/
</video>

The browser will automatically select the first known format and play it. (source: w3Schools.com)

浏览器将自动选择第一个已知格式并播放。(来源:w3Schools.com

Hope this helps!

希望这可以帮助!