视频结束时Youtube嵌入的动作

视频结束时Youtube嵌入的动作,youtube,youtube-api,Youtube,Youtube Api,我想知道是否有可能在嵌入视频完成后使用youtube api进行操作。例如,在我的网络中,我在一个元素的悬停上开始视频,但我希望视频结束时被静态图像替换。我该怎么做呢?使用 它使一切变得容易。一旦你设置好了它,这不需要很长时间(有一个简单的操作方法),只需将这一行添加到你的玩家入门: onPlayerEnded: function(){ // Do something here }, 这将在玩家结束后执行你想要的任何操作。当播放器暂停、停止、播放、静音、取消静音、排队等时,还有回调 让

我想知道是否有可能在嵌入视频完成后使用youtube api进行操作。例如,在我的网络中,我在一个元素的悬停上开始视频,但我希望视频结束时被静态图像替换。我该怎么做呢?

使用

它使一切变得容易。一旦你设置好了它,这不需要很长时间(有一个简单的操作方法),只需将这一行添加到你的玩家入门:

    onPlayerEnded: function(){ // Do something here },
这将在玩家结束后执行你想要的任何操作。当播放器暂停、停止、播放、静音、取消静音、排队等时,还有回调


让我知道这是否有效,或者如果您在使用jquery插件时遇到问题。这真的是非常有用和容易

我有wordpress并在以下步骤中使用: 安装

然后将此代码添加到页面中
但是改变
1) yoursite.com到您的
2) 警报(“你好”)到您的另一个所需功能
3) DkoeNLuMbcI到所需的视频id


jQuery(“youtube播放器容器”).tubeplayer({
宽度:422,//播放器的宽度
身高:285,//玩家的身高
allowFullScreen:“true”,//默认为true,允许用户全屏显示
initialVideo:“DkoeNLuMbcI?autoplay=1”//加载到播放器中的视频
preferredQuality:“default”,//首选质量:default、small、medium、large、hd720
onPlay:function(id){},//在调用play方法之后
onPause:function(){},//在调用pause方法之后
onStop:function(){},//在播放器停止后
onSeek:function(time){},//将视频搜索到定义的点后
onMute:function(){},//在播放器静音后
onPlayerEnded:function(){alert(“Hello”);},
onUnMute:function(){}//在播放器取消静音后
});

我已经研究过youtube api,我认为应该使用player.addEventListener来完成,但不知道怎么做
<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>