我如何从YouTube的iframe嵌入播放器中移除“稍后观看”和“分享”按钮?我正在使用以下嵌入代码来嵌入视频剪辑。
<iframe width="854" height="480" src="https://www.youtube.com/embed/cPVgwz5aN1o" frameborder="0" allowfullscreen></iframe>
使用showinfo=0可以移除完整的标题头,该标题头还包括视频标题。
是否可能仅从标题栏中删除“稍后观看”和“分享”按钮?
我如何从YouTube的iframe嵌入播放器中移除“稍后观看”和“分享”按钮?我正在使用以下嵌入代码来嵌入视频剪辑。
<iframe width="854" height="480" src="https://www.youtube.com/embed/cPVgwz5aN1o" frameborder="0" allowfullscreen></iframe>
使用showinfo=0可以移除完整的标题头,该标题头还包括视频标题。
是否可能仅从标题栏中删除“稍后观看”和“分享”按钮?
使用YouTube嵌入的隐私增强模式(youtube-nocookie),它将隐藏“稍后观看”按钮,但不会隐藏“分享”按钮。
<iframe width="854" height="480" src="https://www.youtube-nocookie.com/embed/cPVgwz5aN1o" frameborder="0" allowfullscreen></iframe>
document.getElementsByTagName('iframe')[0].contentWindow.getElementsByClassName('ytp-watch-later-button')[0].style.display = 'none';
https://www.youtube.com/embed/c5cHjtspa7M?mode=opaque&rel=0&autohide=1&showinfo=0&wmode=transparent
showinfo
属性在2018年9月已被弃用。这就是为什么这个答案的解决方案不再起作用的原因。 - inspirednz显示信息
注意:此参数已过时,将在2018年9月25日后被忽略。
支持的值为0和1。
将参数值设置为0会使播放器在视频开始播放之前不显示视频标题和上传者等信息。
如果播放器正在加载一个播放列表,并且您明确将参数值设置为1,则在加载时,播放器还将显示播放列表中视频的缩略图。
由于不可能,如果不想要分享按钮,有一些可能的替代方案:
?controls=0
来控制显示什么:<iframe
src="https://www.youtube-nocookie.com/embed/j8xbAwurfgo?controls=0&rel=0&modestbranding=1&origin=https://key.bio"
frameborder="0"
allow="encrypted-media;"
allowfullscreen>
</iframe>
YouTube Player API iframe嵌入参考 https://developers.google.com/youtube/iframe_api_reference
注意:这只在Chrome上有效,而在Firefox上无效!因为我通常使用FF进行Web开发,所以花了一些时间才弄清楚这个问题。