Get youtube video current time

回眸只為那壹抹淺笑 提交于 2021-01-28 23:22:35

问题


I am trying to get youtube video current time.I cant find solution.could any ne help me in this my code i am trying which works for ordinary videos is

<button onClick="getCurTime()" type="button">Get current time position</button>
<button onClick="setCurTime()" type="button">Set time position to 5 seconds</button>
<br>
<embed width="420" height="315" id="myVideo"
            src="http://www.youtube.com/v/XGSy3_Czz8k"> 
<script>
var vid = document.getElementById("myVideo");

function getCurTime() {
    alert(vid.currentTime);
}
</script> 

回答1:


<embed width="420" height="315" id="myVideo"
        src="http://www.youtube.com/v/XGSy3_Czz8k">



    <script>
        var vid = document.getElementById("myVideo");

        function getCurTime() {
            alert(vid.getCurrentTime());
        }
    </script>  


来源:https://stackoverflow.com/questions/26273066/get-youtube-video-current-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!