Possible to disable “Watch on Youtube” link?

2019-02-21 09:45发布

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

标签: youtube-api
5条回答
干净又极端
2楼-- · 2019-02-21 10:15

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.

查看更多
Summer. ? 凉城
3楼-- · 2019-02-21 10:23

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楼-- · 2019-02-21 10:24

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.

查看更多
Anthone
5楼-- · 2019-02-21 10:25

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.

查看更多
姐就是有狂的资本
6楼-- · 2019-02-21 10:27

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/

查看更多
登录 后发表回答