我试试这段代码。
<video width="320" height="240" controls="controls" autobuffer="autobuffer">
<source src="data:video/mp4;base64,AAAA<?php echo chunk_split(base64_encode(trim(file_get_contents('kecak.mp4')))); ?>" type="video/mp4" />
Your browser does not support the video tag.
</video>
当我在笔记本(safari、firefox)上玩时它可以工作,但当我在 IPAD2(safari)或三星 Galaxy(Opera)上玩时它就不行。我认为问题出在
src="data:video/mp4;base64,AAAA<?php echo chunk_split(base64_encode(trim(file_get_contents('kecak.mp4')))); ?>
因为当我替换为
src="kecak.mp4"
它适用于所有设备和浏览器。我必须使用base64_encode(trim(file_get_contents('kecak.mp4')))因为在我的实际情况下,它来自 RESTFul 对通过 http 传送视频的响应。来自 http 的字符串响应与 base64_encode(trim(file_get_contents('kecak.mp4'))) 相同。谢谢你的帮助:-)