Search code examples
youtubeyoutube-apiyoutube-iframe-api

Youtube disable related videos


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
        }
    });
}

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


Solution

  • 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.

    See https://developers.google.com/youtube/player_parameters#release_notes_08_23_2018 for more details.