【问题标题】:How to get watch time of html5 video in php without any external software?如何在没有任何外部软件的情况下获取 php 中 html5 视频的观看时间?
【发布时间】:2018-03-17 06:12:48
【问题描述】:
<video id='myVideo' controls autoplay>
    <source src='a.mp4#t=00:00:00' type=video/mp4>
</video>

如何在不使用任何外部软件的情况下,在php中获取html5视频的观看时间并存储到php变量中?

【问题讨论】:

    标签: javascript php html html5-video


    【解决方案1】:

    如果我收到您的问题,您想知道视频开始后经过的时间。这是解决方案

    $(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 */
        }
    

    【讨论】:

    • 如何将其存储在php变量中
    • 因为您的跟踪功能是在 javascript 中。您不能在 js 中编写 php,但您可以创建 php 文件并将时间值作为 ajax 请求中的 post/get 参数传递。在 php 中,您可以在 session 或 db 中使用 store 值。
    猜你喜欢
    • 1970-01-01
    • 2018-05-07
    • 2011-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多