Is there a way of hiding related Youtube videos on pause with iframe api?
Asked Answered
T

1

6

I'm working with the iframe API and I want to embed some videos on a page, but I don't want to show related videos when a user pauses the video.

I know that after September 2018 Youtube removed the possibility of hiding related videos at the end or when pausing a video.

I know the parameter rel=0 now shows related videos from the same account of the video uploader.

I also know the question has been answered many times, but I've seen at least one site where that's not happening. Example: https://earth.stanford.edu/

To generate the iframe i'm using the following code:

function onYouTubeIframeAPIReady() {
    player = new YT.Player('player1', {
        height: '360',
        width: '640',
        videoId: 'lPVBrRd9wCo',
        playerVars: {
            rel: '0',
            showinfo: '0',
            loop: '1',
            playlist: 'lPVBrRd9wCo',
            autoplay: '1',
            mute: '1',
            iv_load_policy: '3',
            'ytp-pause-overlay': '0'
        },
        events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
        }
    });
}

Full code in https://codepen.io/romualdinho/pen/wZbxmj

Is there another way of hiding related videos on pause? How does Stanford do it? I tried the same way, same parameters, etc, but nothing. They even have been able to hide the title of the video.

Is there some kind of Google Account that allows that? (premium, nonprofit, educational, etc.)

Thank you!

Triturable answered 30/4, 2019 at 20:9 Comment(2)
I had the same problem. You could check my solution in this thread #18894402Wheeling
@DmitriySakhno That's an interesting approach! The controls are hidden, so I have to create my own controls, but I think it's a good alternative. The placeholder image could be obtained directly from youtube: e.g.: img.youtube.com/vi/lPVBrRd9wCo/mqdefault.jpg and playing a bit with absolute positioning and the Youtube API I can cope with the stretched image problem. Thank you!!Triturable
M
3

Google/YouTube ended support of rel=0 back in October 2018. So far, I know of no way to prevent it. I think that with ad and cookie blockers, they are losing revenue, so driving people to YouTube.com is their answer. Again, it's free.

Myrlmyrle answered 3/5, 2019 at 14:8 Comment(2)
Maybe that's one of the reasons but, why some other videos (like the one from Stanford) are not showing related videos? I realized that if you have only one video on your account, using rel=0, the related videos do not appear on pause. That's not an option for me though because we have dozens of videos in our account. Maybe there is a pay account where that's allowed, but I couldn't find anything.Triturable
YouTube should allow developers to pay to remove these ads. They’d make a killingLarimor

© 2022 - 2024 — McMap. All rights reserved.