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).
You can remove the Watch on YouTube button by removing the video control bar with the controls parameter. Like the modestbranding parameter, the controls parameter needs to be appended to the end of the URL in the HTML code.
At this time, however, it is still possible to disable the "Watch Later" and "Share" buttons on the top right of the video player. Simply put, the plugin does it by forcing the no cookie version of YouTube's embedded player to be loaded.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With