我有一个包含youtube ID的数据库。 现在我想播放第一个视频,当视频结束时,我想去 http://www.foo.com/index.php?play=1。所以它将播放下一个YouTube视频。视频完成后,它将转到http://www.foo.com/index.php?play=2 ....在x(x是视频持续时间)秒后,我尝试了一些时间来刷新页面。但是当用户点击暂停按钮时,它会提前刷新。
有人能帮助我吗?
答案 0 :(得分:2)
好吧,您可以使用YouTube JavaScript API播放器。此播放器将触发诸如播放结束,播放暂停和视频提示等事件。您可以在回放结束事件中挂钩函数。查看YouTube JavaScript Player API Reference并向下滚动到events部分。
答案 1 :(得分:0)
解决方案(在我的wordpress网站上工作):下载&将其安装到您的网站 - http://www.tikku.com/jquery-youtube-tubeplayer-plugin
然后在您的页面中插入此代码
但改变了
1) yoursite.com 给你的
2)警告(“你好”); 到你想要的功能;
3) DkoeNLuMbcI 到您的视频ID;
<div id="youtube-player-container" style="float:right"> </div>
<script type="text/javascript" src="http://yoursite.com/folder/jQuery.tubeplayer.min.js"></script>
<script type="text/javascript">
jQuery("#youtube-player-container").tubeplayer({
width: 422, // the width of the player
height: 285, // the height of the player
allowFullScreen: "true", // true by default, allow user to go full screen
initialVideo: "DkoeNLuMbcI?autoplay=1", // the video that is loaded into the player
preferredQuality: "default",// preferred quality: default, small, medium, large, hd720
onPlay: function(id){}, // after the play method is called
onPause: function(){}, // after the pause method is called
onStop: function(){}, // after the player is stopped
onSeek: function(time){}, // after the video has been seeked to a defined point
onMute: function(){}, // after the player is muted
onPlayerEnded: function(){ alert("Hello"); },
onUnMute: function(){} // after the player is unmuted
});
</script>