我正在使用 YouTube Player API Reference for iframe 的简单代码
<div id="player"></div>
<script>
//Load player api asynchronously.
var tag = document.createElement('script');
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var done = false;
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '327',
width: '530',
videoId: '_XaWYzsY920',
playerVars: { 'autoplay': 1,'playlist':['Hzgzim5m7oU', 'QvZIYIVNGZ0']},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(evt) {
evt.target.playVideo();
}
function onPlayerStateChange(evt) {
console.log(evt.data);
console.log(evt.target.getVideoUrl());
}
</script>
我想用 evt.data == 5 解决,但它从来没有被解雇过......
有办法吗?