我们使用以下代码将最新的 YouTube 视频嵌入到我们的播放列表之一。我们已将视频排队等待明天上线,但现在我们的网站显示“视频不可用 - 视频私有”错误。我们检查了 API,但我没有看到任何会跳过私人视频的playerVars。
知道如何获取基本的 Youtube 播放列表来跳过私人或不可嵌入的视频吗?
<div id="muteYouTubeVideoPlayer"></div>
<script async src="https://www.youtube.com/iframe_api"></script>
<script>
function onYouTubeIframeAPIReady() {
var player;
player = new YT.Player('muteYouTubeVideoPlayer', {
width: 940, // Player width (in px)
height: 530, // Player height (in px)
playerVars: {
listType:'playlist',
list: '{{LIST_ID}}',
autoplay: 1, // Auto-play the video on load
controls: 1, // Show pause/play buttons in player
showinfo: 0, // Hide the video title
modestbranding: 1, // Hide the Youtube Logo
loop: 1, // Run the video in a loop
fs: 0, // Hide the full screen button
cc_load_policy: 0, // Hide closed captions
iv_load_policy: 3, // Hide the Video Annotations
autohide: 0 // Hide video controls when playing
},
events: {
onReady: function(e) {
e.target.mute();
}
}
});
}
</script>
如果出现错误,我还尝试添加一些内容来播放下一个视频。它会更改为播放列表中的下一个项目,但不播放。
<div id="muteYouTubeVideoPlayer"></div>
<script async src="https://www.youtube.com/iframe_api"></script>
<script>
function onYouTubeIframeAPIReady() {
var player;
player = new YT.Player('muteYouTubeVideoPlayer', {
width: 940, // Player width (in px)
height: 530, // Player height (in px)
playerVars: {
listType:'playlist',
list: '{{LIST_ID}}',
autoplay: 1, // Auto-play the video on load
controls: 1, // Show pause/play buttons in player
showinfo: 0, // Hide the video title
modestbranding: 1, // Hide the Youtube Logo
loop: 1, // Run the video in a loop
fs: 0, // Hide the full screen button
cc_load_policy: 0, // Hide closed captions
iv_load_policy: 3, // Hide the Video Annotations
autohide: 0 // Hide video controls when playing
},
events: {
onReady: function(e) {
e.target.mute();
},
onError: function(e){
e.target.nextVideo();
e.target.playVideo();
}
}
});
}
</script>