我正在尝试获取 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>
最佳答案
<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>
关于javascript - 获取 YouTube 视频当前时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26273066/