Disable play/pause/full screen for HTML5 <video> on click for YouTube

亡梦爱人 提交于 2020-01-12 09:18:12

问题


Is there a way for us to disable the "play/pause/full screen on click" functionality for a HTML5 video through javascript and later put it back when we need it again?


回答1:


I don't know if you can disable them but you can remove them using css.

video::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-play-button, video::-webkit-media-controls-pausebutton {
    display: none;
}

http://jsfiddle.net/4ce23z2a/

I hope this helps.




回答2:


I'm not sure why <video> doesn't honor event.preventDefault();

The way I go around this is pretty hacky. I just override the click and dblclick events of the parent div to solve my problem since I only want to prevent pause/play/full screen.




回答3:


The below line can solve the purpose.

video.removeAttribute('controls');


来源:https://stackoverflow.com/questions/28389347/disable-play-pause-full-screen-for-html5-video-on-click-for-youtube

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!