Disable <iframe> onclick pause

2019-05-07 14:19发布

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.

3条回答
Melony?
2楼-- · 2019-05-07 14:54

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

查看更多
疯言疯语
3楼-- · 2019-05-07 14:59

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%
查看更多
Luminary・发光体
4楼-- · 2019-05-07 15:01

Try this trick for iframe or iframe wrapper:

#ytplayer {pointer-events: none;}
查看更多
登录 后发表回答