我无法让YouTube api尊重我传递给它的一些参数。我感兴趣的具体选项是“控件”,“模型标记”和“开始”,但也有其他选项。我在这里有一个示例页面:http://designdeploy.co.uk/yt.html
完整的HTML:
<html>
<head>
</head>
<body>
<div id="myytplayer"></div>
<script>
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var ytplayer;
window.onYouTubePlayerAPIReady = function() {
ytplayer = new YT.Player('myytplayer', {
height: 600,
width: 800,
enablejsapi: 1,
origin: 'http://designdeploy.co.uk',
modestbranding: 1,
controls: 0,
start: 403,
fs: 0,
showinfo: 0,
videoId: '6KRJr7k6xns'
});
}
</script>
</body>
</html>
正如您所看到的,它仍然从视频的开头开始,而不是403秒,并且仍显示所有品牌。
答案 0 :(得分:1)
一般来说,您尝试设置的选项不是构造函数参数的直接属性,而是playerVars
属性的子项,如下所示:
<html>
<head>
</head>
<body>
<div id="myytplayer"></div>
<script>
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var ytplayer;
window.onYouTubePlayerAPIReady = function() {
ytplayer = new YT.Player('myytplayer', {
height: 600,
width: 800,
playerVars: {
origin: 'http://designdeploy.co.uk',
modestbranding: 1,
controls: 0,
start: 403,
fs: 0,
showinfo: 0
},
videoId: '6KRJr7k6xns'
});
}
</script>
</body>
</html>
这是一个fiddle来演示。