问题
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