html对象标签应该指定类型为视频/ mp4播放mp4视频? [英] html object tag should we specify type as video/mp4 to play mp4 videos?

查看:305
本文介绍了html对象标签应该指定类型为视频/ mp4播放mp4视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道object标签在html中嵌入对象并且对播放视频/音频非常有用。
当我们使用type =video / mpeg指定对象时,是否使用设备中的默认播放器?

我在播放mp4文件时遇到问题。当我使用对象标签。
它能够播放mpeg-2传输流。


此外,设备播放器规格表示它们支持mp4。



我是否在这里遗漏任何东西。 /camendesign.com/code/video_for_everybodyrel =nofollow noreferrer>这个网站在这个答案中提到了类似的问题

编辑:



html object 标记与用于播放视频的其他标记有一些限制。我认为这个会给你一个更清晰的想法。你会发现最好的解决方案是像这样一起使用3种不同的方法:

 < video width =320 height =240controls =controls> 
< source src =movie.mp4type =video / mp4/>
< source src =movie.oggtype =video / ogg/>
< source src =movie.webmtype =video / webm/>
< object data =movie.mp4width =320height =240>
< embed src =movie.swfwidth =320height =240>
您的浏览器不支持视频
< / embed>
< / object>
< / video>

在此示例中,HTML 5 video 元素尝试播放视频无论是mp4,ogg还是webm格式。如果失败,代码将回退以尝试对象元素。如果这也失败了,它会回退到嵌入元素。
在HTML中显示视频的最简单方法是使用YouTube。
无论如何,如果你在那里阅读所有内容,你会更好地理解它。


I know that object tag embeds objects in html and useful for playing videos/audios. When we specify object with type="video/mpeg" does this use the default player in the device

I am having an issue in playing mp4 files. When i use object tag. It is able to play mpeg-2 transport stream though.

Also the device player specs says they support mp4.

Am i missing anything here.

解决方案

You might get help from this website mentioned in this answer to a similar question.

Edit:

html object tag has some limitations like the other tags used to play videos. I think this will give you a more clear idea. There you'll see that the best solution is to use 3 different methods together like this:

<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">
Your browser does not support video
</embed>
</object>
</video> 

In this example, The HTML 5 video element tries to play the video either in mp4, ogg, or webm formats. If this fails, the code "falls back" to try the object element. If this also fails, it "falls back" to the embed element. And the easiest way to display videos in HTML is to use YouTube. Anyway, you'll understand it better if you read the whole thing there.

这篇关于html对象标签应该指定类型为视频/ mp4播放mp4视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆