循环选项在youtube js API中不起作用 [英] Loop option doesn't work in the youtube js api
本文介绍了循环选项在youtube js API中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道为什么我的代码没有播放视频的循环.除循环选项外,其他所有东西都在工作.我真的很需要非常感谢.
I'm wondering why my code doesn't play the loop for the video. Everything is working except the loop option. And I really need it. Thanks a lot.
<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"对象中添加播放列表"属性.像此循环一样,也适用于单个视频.
The solution is to adding in the 'playerVars' object, the 'playlist' attributes. Like this loop works, also for single video.
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
}
});
}
这篇关于循环选项在youtube js API中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文