问题描述
|
我有一个带有youtube ID的数据库。
现在我要播放第一个视频,当视频结束时,我想转到
http://www.foo.com/index.PHP?play=1。因此它将播放下一个youtube视频。视频播放完后,它将转到http://www.foo.com/index.PHP?play=2 ...。我尝试了一些时间,以便在x(x是视频持续时间)秒后刷新页面。但是,当用户按下暂停按钮时,它将刷新至较早。
有人能帮我吗?
解决方法
好吧,您可以使用YouTube JavaScript API Player。该播放器将触发事件,例如播放结束,播放暂停和视频提示。您可以在回放结束事件中挂钩函数。查看YouTube JavaScript Player API参考,然后向下滚动到事件部分。
, 解决方案(在我的wordpress网站上工作):下载并将其安装到您的网站-http://www.tikku.com/jquery-youtube-tubeplayer-plugin
然后将此代码插入您的页面
但是改变
1)yoursite.com归您所有
2)alert(\“ Hello \”);达到您想要的功能;
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>