关于YouTube API-是否可以确定某人是开始观看视频还是结束观看视频?
答案 0 :(得分:0)
如您在上面的文档linked中所述,我建议遵循所示的实现方式
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
}
// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 6000);
done = true;
}
}