1

我目前正在尝试修改从 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 下

有没有人可以对这个问题有所了解?

谢谢 !

4

1 回答 1

0

我通过在我的 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');

就这样。

于 2018-11-13T06:42:40.207 回答