![](/img/trans.png)
[英]JS currentTime for html video tag is not working on chrome
[英]JS currentTime in html video with php script for src don't working on Chrome
我目前正在尝试修改从php脚本(标头方法)获取其源代码的html5视频播放器的currentTime。 视频正确加载,我可以通过JS访问命令:
我通过php脚本将视频加载到html5标签中
<video controls id="MyVideo">
<source src="getVideo.php?nom=sunset_plaine&sens=1&qualite=hd" type="video/mp4" />
<!--<source src="datas/videos/voie_lactee_1_hd.mp4" type="video/mp4" />-->
</video>
我可以控制影片JS
var myvideo = document.getElementById("MyVideo");
myvideo.play();
加载视频(事件可以播放)后,我可以检索有关视频的信息
console.log(myvideo.duration);
console.log(myvideo.currentTime);
我无法更改视频的currentTime,并且该命令不会返回任何错误
console.log(myvideo.currentTime);
myvideo.currentTime = 2.6;
console.log(myvideo.currentTime);
如果我将php脚本替换为直接链接到视频的代码,则可以修改currentTime
<video controls id="MyVideo">
<!--<source src="getVideo.php?nom=sunset_plaine&sens=1&qualite=hd" type="video/mp4" />-->
<source src="datas/videos/voie_lactee_1_hd.mp4" type="video/mp4" />
</video>
此代码在IE和FF上完美运行,问题在chrome下发生
是否有人可以阐明这个问题?
谢谢 !
我通过在我的php脚本getVideos.php
上使用标头找到了解决方案:
在阅读php脚本中的视频之前,我只是使用一个标头:
header('Content-Type: video/mp4');
我添加了一个,并且currentTime现在可以在Chrome上进行编辑(不要问我为什么...):
header("Content-Disposition: inline;");
我借此机会也添加了这些内容:
header('Accept-Ranges: bytes');
header('Content-Length: '. filesize($file_path_name));
header("Content-Transfer-Encoding: binary");
header('Connection: close');
就这样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.