视频结束时 YouTube 嵌入动作

发布于 2024-11-19 11:46:02 字数 100 浏览 1 评论 0原文

我想知道嵌入视频完成后是否可以使用 youtube api 执行操作。例如,在我的网站中,我在将鼠标悬停在一个元素上时启动视频,但我希望视频在完成后被静态图像替换。我怎样才能做到这一点?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

任谁 2024-11-26 11:46:02

我有 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>

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>
牵你的手,一向走下去 2024-11-26 11:46:02

使用 http://www.tikku.com/jquery-youtube-tubeplayer-plugin

它让一切变得简单。一旦你完成了设置,这不会花很长时间(有一个简单的操作方法),只需将这一行添加到你的玩家启动中:

    onPlayerEnded: function(){ // Do something here },

这将在玩家结束后执行你想要的任何操作。还有播放器暂停、停止、播放、静音、取消静音、排队等时的回调。

请告诉我这是否有效,或者您在使用 jquery 插件时遇到问题。这确实非常有帮助且简单!

use http://www.tikku.com/jquery-youtube-tubeplayer-plugin

It makes everything easy. Once you have it set up, which shouldn't take long (there is an easy how-to), simply add this line to you player initiation:

    onPlayerEnded: function(){ // Do something here },

This will do whatever you want after the player ends. There are also callbacks for when the player is paused, stopped, played, muted, unmuted, queued, and more

Let me know if this works, or if you have trouble using the jquery plugin. It really is very helpful and easy!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文