直到美國東部時間下午6點左右,這段代碼才能正常工作,但現在onStateChange因爲某種原因沒有開火。我試過多個瀏覽器,並且有朋友檢查過它。看到什麼顯然不對?YouTube Iframe API - OnStateChange突然不工作
<div id="video">
<div id="player_wrap">
<div id="player"></div>
</div>
</div>
<script>
var tag = document.createElement("script");
tag.src = "http://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
function onYouTubeIframeAPIReady() {
var player;
player = new YT.Player("player", {
width: 640,
height: 400,
videoId: "MbfsFR0s-_A",
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady() {
alert ("player ready");
}
function onPlayerStateChange(event) {
alert ("something happened");
}
任何錯誤在開發者控制檯? API沒有最近的變化:https://developers.google.com/youtube/iframe_api_reference – Raptor