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

问题描述

我正在使用 Youtube iframe API 向我的页面添加视频,但在视频即将结束时显示相关视频,即使我已将rel"参数设置为 0.

I'm using Youtube iframe API to add a video to my page, but it's showing related videos when the video is about to end even though i have set the 'rel' parameter to 0.

这是我的代码的相关部分:

Here is the concerned part of my code:

function onYouTubeIframeAPIReady() {
    player = new YT.Player('homeplayer', {
        height: '1070',
        width: '1920',
        videoId: videoID,
        playerVars: {
                'controls': 0,
                'loop': 1,
                'modestbranding': 1,
                'rel': 0,
                'showinfo': 0,
                'playlist': videoID
        },
        events: {
            'onReady': onPlayerReady
        }
    });
}

也许这个问题已经有人问过了,但我找不到解决方案,因为 youtube api 已经更新了多次.

Maybe this question has already been asked but i can't find a solution as youtube api has been updated multiple times.

推荐答案

rel 参数的功能已更改;2018 年 8 月,YouTube 弃用了它,并在 2018 年 9 月修改了播放器 API,因此您无法再隐藏相关视频.相反,如果您将 rel 设置为 0,则嵌入式播放器将仅显示来自刚刚播放的视频所在频道的相关视频.如果省略 rel,则嵌入式播放器将显示 YouTube 上任何位置的相关视频.不再有任何方法可以完全删除相关视频.

The functionality of the rel parameter has changed; in August of 2018, YouTube deprecated it and in September of 2018 they modified the player API so you can no longer hide related videos. Rather, if you set rel to 0, the embedded player will only show related videos from the channel that the just-played video is from. If you omit rel, then the embedded player will show related videos from anywhere on YouTube. There is no longer any way to remove related videos altogether.

请参阅https://developers.google.com/youtube/player_parameters#release_notes_08_23_2018了解更多详情.

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

08-06 19:14