YouTube视频结束时的操作!

我有一个带有youtube ID的数据库。 现在我想播放第一个视频,当视频结束时,我想要去 http://www.foo.com/index.php?play=1。所以它会播放下一个YouTube视频。在完成视频后,它将转至http://www.foo.com/index.php?play=2 ...。在x(x是视频的持续时间)秒后,我尝试了一些时间刷新页面。但是当用户点击暂停按钮时,它会刷新到早。YouTube视频结束时的操作!

有人可以帮助我吗?

回答:

那么,你可以使用YouTube JavaScript API播放器。该播放器将触发播放结束,播放暂停和视频提示等事件。您可以在播放结束事件中挂钩一个功能。看看YouTube JavaScript Player API Reference并向下滚动到events部分。

回答:

SOLUTION(我的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>

以上是 YouTube视频结束时的操作! 的全部内容, 来源链接: utcz.com/qa/264904.html

回到顶部