Weatherman Weatherman -4 years ago 188
Javascript Question

HTML5 video - show/hide controls programatically

I am looking for a way to show or hide HTML5 video controls at will via javascript. The controls are currently only visible when the video starts to play

Is there a way to do this with the native video controls?

I'm using google chrome browser.

Answer Source
<video id="myvideo">
  <source src="path/to/movie.mp4" />

<p onclick="toggleControls();">Toggle</p>

var video = document.getElementById("myvideo");

function toggleControls() {
  if (video.hasAttribute("controls")) {
  } else {

See it working on jsFiddle:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download