隐藏相关视频Youtube Iframe API [英] Hide related videos Youtube Iframe API

查看:107
本文介绍了隐藏相关视频Youtube Iframe API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试隐藏当您暂停视频时显示的相关视频,但正如我从类似问题中发现的那样, 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.


更改的效果是您无法禁用
相关视频。但是,您可以选择指定
播放器中显示的相关视频应该来自与刚播放的视频相同的频道

The effect of the change is that you will not be able to disable related videos. However, you will have the option of specifying that the related videos shown in the player should be from the same channel as the video that was just played.

更具体一点:

在更改之前,如果参数的值设置为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.

这是 JSFiddle

此外参数 showinfo = 0 不再用于隐藏视频标题,请稍后按钮和分享按钮。它已于2018年9月25日弃用但不知何故 KhanAcademy 仍然可以隐藏那些包括相关视频的内容。他们使用不同的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.

播放器名称为 Plyr

HTML:

<div class="plyr__video-embed" id="player">
    <iframe src="https://www.youtube.com/embed/9C1leq--_wM??origin=https://plyr.io&amp;iv_load_policy=3&amp;modestbranding=1&amp;playsinline=1&amp;showinfo=0&amp;rel=0&amp;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%;
}

这是 JSFiddle 。它对我来说很完美。

Here's the JSFiddle. It's working perfectly for me.

这篇关于隐藏相关视频Youtube Iframe API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆