Javascript 在没有任何外部软件的情况下,如何在php中获得html5视频的观看时间?
如何在php中获取html5视频的观看时间,并在没有任何外部软件的情况下将其存储到php变量中?如果我收到您的问题,您想知道视频开始后经过的时间。这是解决办法Javascript 在没有任何外部软件的情况下,如何在php中获得html5视频的观看时间?,javascript,php,html,html5-video,Javascript,Php,Html,Html5 Video,如何在php中获取html5视频的观看时间,并在没有任何外部软件的情况下将其存储到php变量中?如果我收到您的问题,您想知道视频开始后经过的时间。这是解决办法 <video id='myVideo' controls autoplay> <source src='a.mp4#t=00:00:00' type=video/mp4> </video> 如何在php变量中存储它,因为跟踪函数是在javascript中实现的。您不能在js中编写php,但可以
<video id='myVideo' controls autoplay>
<source src='a.mp4#t=00:00:00' type=video/mp4>
</video>
如何在php变量中存储它,因为跟踪函数是在javascript中实现的。您不能在js中编写php,但可以在ajax请求中创建php文件并将时间值作为post/get参数传递。在php中,您可以在会话或数据库中使用存储值。
$(document).ready(function(){
$("#myvideo").on(
"timeupdate",
function(event){
onTrackedVideoFrame(this.currentTime, this.duration);
});
});
function onTrackedVideoFrame(currentTime, duration){
/* Here you can get both currentTIme and duration */
}