HTML5视频获取currentTime无法与媒体事件一起使用javascript addEventListener [英] HTML5 video get currentTime not working with media events javascript addEventListener

查看:74
本文介绍了HTML5视频获取currentTime无法与媒体事件一起使用javascript addEventListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试显示视频播放时的当前持续时间(实时打印当前时间)。

Im trying to show the current duration (print currenttime live) when the video is playing.

我确实在检测是否正在播放HTML5视频元素但无济于事

我最终希望将currenttime值携带到php变量$ currenttime中下面的
是我当前的代码

i eventually want to carry the currenttime value to a php variable $currenttime below is my current code

<html> 
<head>  
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
<title>Html5 media events</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head> 
<body >
<div id="output"></div>
<video id="myVideo" width="320" height="176" controls>
    <source src="http://action.news/videos/Britney%20Spears%20-%20Overprotected%20(2009)%20Full%20HD%201080p_60%20fps.mp4" type="video/mp4">
</video>

<script>
    var media = document.getElementById('myVideo');

    // Playing event
    var isPlaying = function(e) {
    #$("#output").html("Playing event triggered");

    };

      // durationchange
    var isdurationchange = function(e) {
        $("#output").html(vid.currentTime);


    };

    media.addEventListener("playing", isPlaying, false);   
    media.addEventListener("durationchange", isdurationchange, true);    
</script>   
</body> 
</html>


推荐答案

您应该能够像这样携带它,专业人士会帮助您语法

you should be able to carry it like this , the pros will help you with syntax

 document.write("<a href=/time.htm?currentTime='.media.addEventListener("timeupdate", isdurationchange, true).'>link</a>;); 

这篇关于HTML5视频获取currentTime无法与媒体事件一起使用javascript addEventListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆