在youtube视频中使用以下代码时,我在FF 7.0上遇到了问题。
每当在youtube视频上按下播放按钮时,js代码将更改视频周围div的高度,宽度和动画。除了youtube视频从未实际开始播放之外,代码的这一部分工作正常。它迫使用户在开始播放前大约播放5次。
有人可以在下面的代码中找到一个高峰,看看有什么东西跳出来是错误的吗?
<div id="ytapiplayer">
You need Flash player 8+ and JavaScript enabled to view this video.
</div>
<script type="text/javascript">
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
swfobject.embedSWF("http://www.youtube.com/e/uHKbFzluF5w?enablejsapi=1&playerapiid=ytplayer? version=3&autohide=1&showinfo=0&modestbranding=1&iv_load_policy=3&controls=1&border=0",
"ytapiplayer", "150", "84", "8", null, null, params, atts);
</script>
<script>
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("myytplayer");
ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
};
function onytplayerStateChange(newState) {
if (newState == 1) {
$("#rentals-video-section").animate({
height: "216px"
}, 500);
$('#myytplayer').attr('width', '301px');
$('#myytplayer').attr('height', '194px');
$('#rentals-video-section-left').hide();
$('#rentals-video-close-btn a').show();
};
};
$('#rentals-video-close-btn').click(function () {
$("#rentals-video-section").animate({
height: "100px"
}, 500);
$('#myytplayer').attr('width', '150px');
$('#myytplayer').attr('height', '84px');
$('#rentals-video-section-left').show();
$('#rentals-video-close-btn a').hide();
});
function pause() {
if (ytplayer) {
ytplayer.pauseVideo();
}
};
</script>