zzz=setInterval(function(){document.getElementById('bugbox').value =
player.getCurrentTime()}, 1000);
我播放视频,我在bugbox中看到了时间
当我点击按钮时视频加载但setInterval不显示player.getCurrentTime();在bugbox中
onclick="document.getElementById('player').src='http://www.youtube.com/watch_popup?v=vt4X7zFfv4k'
从此代码加载第一个视频:
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
idv='qV5lzRHrGeg';
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: idv,
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
编辑: 解决了! 我使用评论中的@NewToJS解决方案。