jQuery YouTube插件-调用方法 [英] jquery youtube plugin - calling methods
问题描述
我正在使用jQuery Youtube插件嵌入youtube视频,并在视频中使用某些API方法.
I'm using the jQuery Youtube plugin to embed a youtube video and use some of the API methods with the video.
我有以下代码:
<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')
,但我没有.
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?
非常感谢
推荐答案
它工作正常,可能是您的浏览器出现问题,请尝试使用console.log代替警报并检查您的控制台.
it works fine, may be a problem with you browser, try to use console.log instead of alert and check you console.
我将您的代码放在jsfiddle中,并且可以正常工作 http://jsfiddle.net/sabri/wHpmM/
i put your code in a jsfiddle and it works http://jsfiddle.net/sabri/wHpmM/
这篇关于jQuery YouTube插件-调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!