视频结束时 Youtube 嵌入动作 [英] Youtube embeded action when video ends

查看:33
本文介绍了视频结束时 Youtube 嵌入动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

我有 wordpress 并在以下步骤中使用:已安装 http://www.tikku.com/jquery-youtube-tubeplayer-plugin

然后将此代码添加到页面中
但要改变
1) yoursite.com 给你的
2) alert("Hello"); 到你想要的另一个功能;
3) DkoeNLuMbcI 到所需的视频 ID;

<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,//播放器的宽度height: 285,//播放器的高度allowFullScreen: "true",//默认为 true,允许用户全屏initialVideo: "DkoeNLuMbcI?autoplay=1",//加载到播放器中的视频优选质量:默认",//首选质量:默认,小,中,大,hd720onPlay: function(id){},//调用播放方法后onPause: function(){},//调用暂停方法后onStop: function(){},//播放器停止后onSeek: function(time){},//在视频被搜索到一个定义点之后onMute: function(){},//播放器静音后onPlayerEnded: function(){ alert("Hello");},onUnMute: function(){}//播放器取消静音后});

I wonder if it is possible to make an action with youtube api when embeded video finishes. For example, in my web i start video on hover of one element, but i want video tu be replaced by static image when it finishes. How can i do that?

解决方案

I had wordpress and used in suchh steps: installed http://www.tikku.com/jquery-youtube-tubeplayer-plugin

then add this code into page
but change
1) yoursite.com to yours
2) alert("Hello"); to your another desired function;
3) DkoeNLuMbcI to desired video 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 嵌入动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆