Javascript 获取当前时间的youtube视频

Javascript 获取当前时间的youtube视频,javascript,html,youtube,youtube-api,Javascript,Html,Youtube,Youtube Api,我正在尝试获取youtube视频的当前时间。我找不到解决方案。在这方面,我正在尝试的用于普通视频的代码是什么 <button onClick="getCurTime()" type="button">Get current time position</button> <button onClick="setCurTime()" type="button">Set time position to 5 seconds</button> <br

我正在尝试获取youtube视频的当前时间。我找不到解决方案。在这方面,我正在尝试的用于普通视频的代码是什么

<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> 
您好@king请查看此链接,我认为这与您的问题有关。
<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>