0

我的 HTML 页面中有以下代码:

<html>
<head>
 <script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.js'></script>
 <script type='text/javascript' src="http://www.tikku.com/scripts/ui/tubeplayer/jQuery.tubeplayer.min.js"></script>
 <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: "rGdViHARBC0",
    // 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>
</head>
<body>
<div id="player"></div>
</body>
</html>

我几乎从这个 JSFiddlePage中得到了它。尽管如此,我的页面变成了完全白色。我想使用 Tubeplayer API 观看 youtube 视频。为什么我的网站不显示视频?

4

1 回答 1

3

您必须等待 DOM 就绪事件。把你的代码包装在里面:

$(function(){ //short hand for: $(document).ready()
    jQuery("#player").tubeplayer({...});
});

或者将脚本标签放在正文的结束标签之前。

于 2013-06-09T10:48:45.017 回答