Stanimirovv
Stanimirovv

Reputation: 3172

Disable <iframe> onclick pause

I want to remove all controls from the user. I used: controls=0 to hide the controls and disablekb=1 to remove the keyboard shortcuts. The last left is the mouse click. I did some research, I didn't find the needed answer.

tl;dr How do I remove the mouse pause form an such as this:

<iframe id="ytplayer" type="text/html" width="640" height="390"
  src='http://www.youtube.com/embed/EgBWDPXF2gU?autoplay=1&disablekb=1&controls=0&origin=http://example.com' ></iframe>

EDIT: There is a legal solution. It doesn't work on 100%, but it will be good enough for most cases. The solution is to simply add an event listener which is looking for the "video is paused event" When this event is triggered, simply start playing the current video. That will work flawlessly and unless the user clicks as fast as around 150-180 clicks per minute the difference for the millisecond when the video was paused before the function ran will be unnoticeable.

I will mark the only submitted answer as the solution simply because if anyone finds this he should, at first, know that any further modifications are illegal.

Upvotes: 4

Views: 8783

Answers (4)

Alamin Hossen
Alamin Hossen

Reputation: 1

<div style="pointer-events: none">
  <iframe
    width="1730"
    height="683"
    src="https://www.youtube.com/embed/vSfAPWcrltQ"
    title="YouTube video player"
    frameborder="0"
    allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
    allowfullscreen
  ></iframe>
</div>

<div style="pointer-events: none">
  <iframe></iframe>
</div>

Upvotes: 0

350D
350D

Reputation: 11440

Try this trick for iframe or iframe wrapper:

#ytplayer {pointer-events: none;}

Upvotes: 9

Baltha
Baltha

Reputation: 1

I found a way to disabled the click (if you really need to), put a div on your iframe with these CSS attributes:

position: absolute, 
height: 100%,
width: 100%

Upvotes: -1

ceasar
ceasar

Reputation: 1522

Sorry to say but that is not a legal action. You could be banned for that from youtube. https://developers.google.com/youtube/terms

Upvotes: 2

Related Questions