以下API不起作用。我该如何解决这个问题?
<div id="player"></div>
<script src="http://www.youtube.com/player_api"></script>
<script>
// Create YouTube player
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: '0Bmhjf0rKe8',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// Autoplay video
function onPlayerReady(event) {
event.target.playVideo();
}
// When video ends
function onPlayerStateChange(event) {
if(event.data === 0) {
alert('done');
}
}
</script>