Possible to disable “Watch on Youtube” link?

2019-02-21 10:01发布

问题:

I am building an app where I am embedding videos and specific sections of video clips. For example, it looks like this

<iframe width="640" height="360" src="https://www.youtube.com/embed/pftnJbQjSBA&modestbranding=1&showinfo=0&autoplay=1&controls=0&modestbranding=1&disablekb=1&rel=0&start=10&end=20" frameborder="0"></iframe>

Is it possible to disable "Watch on youtube" link so the user doesn't end up navigating elsewhere. Just to be clear, I only want to control the flow while the video is being watched (i.e not trying to interfere with ads or YouTube logo).

回答1:

It is possible, just add &modestbranding=1 to your embed code.

Watch this: https://www.youtube.com/watch?v=4NFgV_Et9gY

e.g.

<object width="800" height="450" data="http://www.youtube.com/v/@Model.YoutubeId&rel=0&modestbranding=1"></object>

Note that a small YouTube text label will still display in the upper-right corner of a paused video when the user's mouse pointer hovers over the player.

Learn more about YouTube's iFrame Player API.



回答2:

I found a working solution with no drawbacks:

<iframe
        width="640"
        height="390"
        src="https://www.youtube.com/embed/VgC4b9K-gYU"
        sandbox="allow-forms allow-scripts allow-pointer-lock allow-same-origin allow-top-navigation">
</iframe>

the key is the sandbox attribute. You just need to restrict popups and now the video just stops when you click on the youtube logo.



回答3:

Using controls=0 you can disable the whole control bar. Using autohide=1 the control bar will automatically hide after the video starts.

I don't think there is an option to just disable the "Watch on YT" link. But you could disable the whole control bar and add the required control buttons yourself.



回答4:

It is not possible to remove Watch on Youtube link on control bar. But after you hiding control bar using controls=0 you can use modestbranding=1 to remove the Youtube watermark and link on bottom right corner.

But still you have a link with the video title on the top of the video. Might be in auto hide state. If you want to remove that use showinfo=0. But after doing this the Youtube watermark and link on the bottom right corner will appear.



回答5:

You can't hide that link by default. However using flash parameters you can disable the link from navigating away. Use allownetworking="internal". But be aware that it will disable every link facilities of the player.

Tutorial and demo: http://www.techtweaker.com/disable-links-on-embedded-youtube-video-code-hack/



标签: youtube-api