在 HTML5 上播放 FLV 视频

发布于 2024-09-26 20:16:25 字数 1254 浏览 2 评论 0 原文

我告诉我的老板使用 HTML5,并使用 FLASH。

但他说他希望FLASH作为第一选择,如果浏览器(ipad或任何其他)无法识别FLASH,它应该播放我们得到的MP4文件。

我建议使用 HTML5 并使用 Flash。但他想要相反的结果。

我怎样才能做到这一点?你们有示例代码吗?

解决方案 使用 SWFObject(google 一下)和 SWF 控制器(如 FlashMediaPlayback.swf)。 了解 iPad 对视频大小的限制非常重要。 因此 MP4 文件不能大于 720p 和音频 160kbps。

我将在下面发布我的代码。您可以将其变成您的,并以您自己的方式使用它。

<div style="text-align:center" >
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
    var flashvars = {};
    flashvars.src = "demo.flv";
    flashvars.controlBarMode = "floating";
    flashvars.autostart="true";
    var params = {};
    params.allowfullscreen = "true";
    params.allowscriptaccess = "always";
    params.bgcolor = "#1a1a1a";
    params.scale = "showall";
    var attributes = {};
    swfobject.embedSWF("demo_controller.swf", "videoDiv", "920", "560", "10.1.0", "expressInstall.swf", flashvars, params, attributes);
</script>

<div id="videoDiv" style="text-align:center">
<video controls="controls" width="720" height="480">
<source src="demo.mp4" type="video/mp4"/>
<source src="demo.ogv" type="video/ogg"/>
</video>
</div>
</div>

I told my boss to use HTML5 with a fallback on FLASH.

But he said he wants FLASH as the first option, and if the browser (ipad or any other) can't recognize the FLASH , it should play the MP4 file we got.

I suggested HTML5 with fallback on Flash. But he wants the opposite.

How can I get that done ? Do you guys have sample code ?

Solution
Using SWFObject (google it) and a SWF Controller (like FlashMediaPlayback.swf).
It's very important to understand that the iPad has limitations with video size.
So the MP4 file can't be bigger than 720p and 160kbps for audio.

I'll post my code right below. You can make it yours and use it your own way.

<div style="text-align:center" >
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
    var flashvars = {};
    flashvars.src = "demo.flv";
    flashvars.controlBarMode = "floating";
    flashvars.autostart="true";
    var params = {};
    params.allowfullscreen = "true";
    params.allowscriptaccess = "always";
    params.bgcolor = "#1a1a1a";
    params.scale = "showall";
    var attributes = {};
    swfobject.embedSWF("demo_controller.swf", "videoDiv", "920", "560", "10.1.0", "expressInstall.swf", flashvars, params, attributes);
</script>

<div id="videoDiv" style="text-align:center">
<video controls="controls" width="720" height="480">
<source src="demo.mp4" type="video/mp4"/>
<source src="demo.ogv" type="video/ogg"/>
</video>
</div>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情话墙 2024-10-03 20:16:25

如果您使用 SWFObject 我想您可以在 SWFObject 替换为 Flash 的 div 中放置一个视频标签如果安装了Flash。

If you use SWFObject I guess you could put a video tag in the div that SWFObject replaces with Flash if Flash is installed.

白鸥掠海 2024-10-03 20:16:25

视频播放器创建者将此称为“后退”,这可能会对您的搜索有所帮助。

我鼓励您查看一些现有的解决方案,这些解决方案通常将 Flash 播放器包装在类似 HTML5 的 API 中,以获得更好的兼容性。 Kaltura HTML5 beta 在 http://www.kaltura.org/advanced-examples< 处有一个后退示例/a>.

Video player creators are calling this "fall-forward", which may help in your search.

I'd encourage you to look at some of the existing solutions, which often wrap the flash player in an HTML5-like API for better compatibility. The Kaltura HTML5 beta has a fall-forward example at http://www.kaltura.org/advanced-examples.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文