问题描述
我正在尝试隐藏当您暂停视频时显示的相关视频,但正如我从类似问题中发现的那样, 2018年9月25日没有办法禁用相关视频显示。
I am trying to hide related videos that shows up when you pause a video but as I found out from similar questions that as of September 25th 2018 there is no way to disable the related videos from displaying.
更具体一点:
在更改之前,如果参数的值设置为0,那么
播放器不会显示相关视频。更改后,如果rel
参数设置为0,播放器将显示与刚刚播放的视频相同频道的
相关视频。
Prior to the change, if the parameter's value is set to 0, then the player does not show related videos. After the change, if the rel parameter is set to 0, the player will show related videos that are from the same channel as the video that was just played.
这是。
此外参数 showinfo = 0
不再用于隐藏视频标题,请稍后按钮和分享按钮。它已于2018年9月25日弃用但不知何故仍然可以隐藏那些包括相关视频的内容。他们使用不同的API吗?
Also the parameter showinfo=0
dosen't work anymore which was used to hide the video title, watch later button and the share button. It is deprecated as of September 25, 2018 but somehow KhanAcademy is still able to hide those including the related videos. Are they using a different API?
像Khan Academy一样隐藏相关视频或在顶部覆盖缩略图隐藏相关视频对我有用。
Hiding the related videos altogether like Khan Academy does or overlaying a thumbnail on top to hide the related videos will work for me.
推荐答案
所以我找到了一个隐藏所有相关视频的开源播放器,包括标题,分享和稍后观看按钮。
So I found an open source player which does hide all the related videos including the title, the share and watch later button.
播放器名称为。
HTML:
<div class="plyr__video-embed" id="player">
<iframe src="https://www.youtube.com/embed/9C1leq--_wM??origin=https://plyr.io&iv_load_policy=3&modestbranding=1&playsinline=1&showinfo=0&rel=0&enablejsapi=1" allowfullscreen allowtransparency allow="autoplay"></iframe>
</div>
您可以使用以下内容对其进行初始化:
const player = new Plyr('#player', {});
// Expose player so it can be used from the console
window.player = player;
CSS隐藏相关视频:
.plyr__video-embed iframe {
top: -50%;
height: 200%;
}
这是。它对我来说很完美。
Here's the JSFiddle. It's working perfectly for me.
这篇关于隐藏相关视频Youtube Iframe API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!