youtube-iframe-[=10th=] 嵌入参数不再起作用
youtube-iframe-api embedd parameters is not working anymore
我正在尝试使用以下参数在我的网站上嵌入 YouTube 视频,但它不起作用:
<iframe width="560" height="315" src="https://www.youtube.com/embed/1xPEIXk69lc?rel=0&controls=0&autoplay=1&showinfo=0&modestbranding=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
自 2018 年 9 月至 10 月起,一些参数已被弃用,包括 showinfo 和对 rel=0 的更改。删除它们有帮助。有关更多信息,请参阅 https://developers.google.com/youtube/player_parameters。
如果您使用 IFrame API,(而不是嵌入 iframe ex http://youtu.be/?videoIDxxx...) you can get the event for the stopping (completing) of the video, then cue up the video by ID into the player. See https://developers.google.com/youtube/iframe_api_reference#Playback_controls 以供参考基本播放器。
....
<div id="player1"></div>
<script type="text/javascript">
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 player ;
function onYouTubeIframeAPIReady()
{
player = new YT.Player('player1',
{
videoId: 'YourVideoId',
events: {
'onStateChange': onPlayerStateChange
}
});
}; // onYOuTubeIframeAPIReady
function onPlayerStateChange(event)
{
// Alt approach //if( event.data == 0){ location.reload()}
if( event.data == 0) // video has ended
{ player.cueVideoById({videoId:'YourVideoID',
suggestedQuality: 'hd720'})
};
}
</script>
我正在尝试使用以下参数在我的网站上嵌入 YouTube 视频,但它不起作用:
<iframe width="560" height="315" src="https://www.youtube.com/embed/1xPEIXk69lc?rel=0&controls=0&autoplay=1&showinfo=0&modestbranding=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
自 2018 年 9 月至 10 月起,一些参数已被弃用,包括 showinfo 和对 rel=0 的更改。删除它们有帮助。有关更多信息,请参阅 https://developers.google.com/youtube/player_parameters。
如果您使用 IFrame API,(而不是嵌入 iframe ex http://youtu.be/?videoIDxxx...) you can get the event for the stopping (completing) of the video, then cue up the video by ID into the player. See https://developers.google.com/youtube/iframe_api_reference#Playback_controls 以供参考基本播放器。
....
<div id="player1"></div>
<script type="text/javascript">
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 player ;
function onYouTubeIframeAPIReady()
{
player = new YT.Player('player1',
{
videoId: 'YourVideoId',
events: {
'onStateChange': onPlayerStateChange
}
});
}; // onYOuTubeIframeAPIReady
function onPlayerStateChange(event)
{
// Alt approach //if( event.data == 0){ location.reload()}
if( event.data == 0) // video has ended
{ player.cueVideoById({videoId:'YourVideoID',
suggestedQuality: 'hd720'})
};
}
</script>