jquery youtube 插件 - 调用方法
我正在使用 jQuery Youtube 插件嵌入 YouTube 视频,并在视频中使用一些 API 方法。
我有以下代码:
<div id="player"></div>
<script type="text/javascript">
jQuery("#player").tubeplayer({
width: 600, // the width of the player
height: 450, // the height of the player
allowFullScreen: "true", // true by default, allow user to go full screen
initialVideo: "VIDEO_ID", // 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
autoPlay: true,
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
onUnMute: function(){}, // after the player is unmuted
onPlayerEnded: function(){alert('ENDED')},
});
</script>
这可以正常播放视频,但是当视频结束时,我希望 onPlayerEnded()
函数启动并给我一个 alert('Ended' )
,但事实并非如此。
有没有人使用过这个插件之前向我指出过为什么会出现这种情况?
非常感谢
I'm using the jQuery Youtube plugin to embed a youtube video and use some of the API methods with the video.
I have the following code:
<div id="player"></div>
<script type="text/javascript">
jQuery("#player").tubeplayer({
width: 600, // the width of the player
height: 450, // the height of the player
allowFullScreen: "true", // true by default, allow user to go full screen
initialVideo: "VIDEO_ID", // 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
autoPlay: true,
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
onUnMute: function(){}, // after the player is unmuted
onPlayerEnded: function(){alert('ENDED')},
});
</script>
This plays the video fine, but when the video has ended, I'd expect the onPlayerEnded()
function to kick in and give me an alert('Ended')
, which it doesn't.
Has anyone used this plugin before point me in any direction as to why this is the case?
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它工作正常,可能是您的浏览器有问题,尝试使用 console.log 而不是警报并检查您的控制台。
我把你的代码放在 jsfiddle 中并且它可以工作
http://jsfiddle.net/sabri/wHpmM/
it works fine, may be a problem with you browser, try to use console.log instead of alert and check you console.
i put your code in a jsfiddle and it works
http://jsfiddle.net/sabri/wHpmM/