admin管理员组文章数量:1414904
Below code is not working, How can disable HTML5 video tag
document.getElementById("vidEle").disabled=true;
If I use
document.getElementById("vidEle").controls=false;
Still I am able to play using right click.
Below code is not working, How can disable HTML5 video tag
document.getElementById("vidEle").disabled=true;
If I use
document.getElementById("vidEle").controls=false;
Still I am able to play using right click.
Share Improve this question edited Mar 25, 2013 at 12:21 Exception asked Mar 25, 2013 at 12:16 ExceptionException 8,38924 gold badges88 silver badges141 bronze badges4 Answers
Reset to default 1It would be nice if we knew the browser you are using, but here are some workarounds:
You can set a new block element on top of it with the same size as the video player with a translucent background using css.
Or you could set the style of your element to display none:
document.getElementById("vidEle").style.display="none";
And lastly you can also unload the content of the vidEle element. One last thing, make sure the video is not playing if you choose to use the "display:none" method.
You can remove the video source so the video won't be able to play :)
Another way to do it is to disable the context menu like this:
<video oncontextmenu="return false;" controls>
<source src="somedir/somevideo.mp4" type="video/mp4"/>
</video>
function turnOffCamera() {
const videoTracks = currentStream.getVideoTracks();
videoTracks.forEach((track) => {
isVideoOpen = !isVideoOpen;
track.enabled = isVideoOpen; // Disable the video track
toggleTheCameraButtonText();
});
}
function turnOffAudio() {
const audioTracks = currentStream.getAudioTracks();
audioTracks.forEach((track) => {
isAudio = !isAudio;
track.enabled = isAudio; //Disable the audio track
toggleTheAudioButtonText();
});
}
track.enabled worked for me
本文标签: htmlHow to disableenable HTML5 Video tag using JavaScriptStack Overflow
版权声明:本文标题:html - How to disableenable HTML5 Video tag using JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745175082a2646196.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论