gpt4 book ai didi

javascript - 循环选项在 youtube js api 中不起作用

转载 作者:搜寻专家 更新时间:2023-11-01 04:50:29 26 4
gpt4 key购买 nike

我想知道为什么我的代码不播放视频的循环。除了循环选项外,一切正常。我真的需要它。非常感谢。

<script src="jsapi.js"></script>
<script src="swfobject.js"></script>
<div id="ytapiplayer">You need Flash player 8+ and JavaScript enabled to view this video.</div>
<script type="text/javascript">
google.load("swfobject", "2.1");
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("myytplayer");
ytplayer.playVideo();
ytplayer.mute();
// I've tried it, just to.. try hehe ytplayer.setLoop(true);
}
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
swfobject.embedSWF("http://www.youtube.com/v/RLOQCqGKVt8?autoplay=1&loop=1&enablejsapi=1&playerapiid=ytplayer&allowFullScreen=true&version=3&controls=0&showinfo=0&autohide=1&rel=0",
"ytapiplayer", "100%", "100%", "8", null, null, params, atts);
</script>

最佳答案

解决方案是在“playerVars”对象中添加“播放列表”属性。就像这个循环一样有效,也适用于单个视频。

function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '100%',
width: '100%',
playerVars : {
'autoplay' : 1,
'rel' : 0,
'showinfo' : 0,
'showsearch' : 0,
'controls' : 0,
'loop' : 1,
'enablejsapi' : 1,
'playlist': 'your-single-video-ID'
},
videoId: 'your-single-video-ID',
events: {
'onReady': onPlayerReady
}
});
}

关于javascript - 循环选项在 youtube js api 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19795034/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com