jquery youtube插件 - 调用方法

时间:2011-12-21 11:51:21

标签: jquery jquery-plugins

我正在使用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'),而不是{{1}}。

有没有人使用这个插件之前指向我为什么会这样?

非常感谢

1 个答案:

答案 0 :(得分:0)

它运行正常,浏览器可能有问题,请尝试使用console.log而不是alert,并检查控制台。

我把你的代码放在一个jsfiddle,它的工作原理 http://jsfiddle.net/sabri/wHpmM/