Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <video id="video" width="360" height="450">
 <source src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/222579/twitter_cat.mp4"  type="video/mp4">
</video>

<div id="controls">
  <a class="control" id="play" title="play">
    <svg width='24' height='24' viewBox='0 0 24 24'><use xlink:href="#svgplay" /></svg>
  </a>
  <a class="control" id="pause" title="pause">
     <svg width='24' height='24' viewBox='0 0 24 24'><use xlink:href="#svgpause"/></svg>  
  </a>
  <a class="control" id="loop" title="loop">
      <svg width='24' height='24' viewBox='0 0 24 24'><use xlink:href="#svgloop"/></svg>  
  </a>
  <a class="control" id="mute" title="mute">
      <svg width='24' height='24' viewBox='0 0 24 24'>
        <use id="sound" xlink:href="#volumeup"/>
        <use id="notsound" xlink:href="#svgmute"/>
    </svg>
  </a>

  <span id="currentTime">0.00</span> <span>/</span> <span id="duration"></span>
</div>

<!--SVG utilizado para los íconos-->
<svg width='24' height='24' viewBox='0 0 24 24' style="display:none;">
    <path id="svgloop" d='M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26l1.46-1.46c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74l-1.46 1.46c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z'></path>
    
    <path id="svgmute" d='M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z'></path>
    
  <path id="volumeup" d='M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'></path>
  
  <path id="svgpause" d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'></path>

  <path id="svgplay" d='M8 5v14l11-7z'></path>

</svg>
              
            
!

CSS

              
                svg {
  pointer-events: none;
}
#controls {
  width:360px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
a{cursor:pointer;}
#notsound{display:none}

              
            
!

JS

              
                let video = document.getElementById("video");
// cuando se ha cargado la primera fotograma del video
video.onloadeddata = ()=>{
  duration.innerHTML = video.duration.toFixed(2);
  video.volume = 1;
} 

controls.addEventListener("click", handleControls)

function handleControls(e){
  let id = e.target.id;// el id del boton en el cual hacemos clic
 // si hacemos click en el play el video empieza a reproducirse
 if(id == "play"){
    if(video.ended){
      video.load()
    }
    video.play();
  }
  // si hacemos click en el pause para el video
  else if(id == "pause"){
  video.pause();  
  }
  // si hacemos click en el loop cambia el valor del booleano
  else if(id == "loop"){
  video.loop = !video.loop;  
  }
  // si hacemos click en el mute cambia el valor del booleano y cambia el ícono
  else if(id == "mute"){
  video.muted = !video.muted;
    if(video.muted){
      notsound.style.display="block";
      sound.style.display="none";
    }else{
      notsound.style.display="none";
      sound.style.display="block";
    }
  }
}


video.addEventListener("play",()=>{
 currentTime.innerHTML = video.currentTime
  
})


//encontrar el momento actual
window.setInterval( function(){ 
 if(!video.paused && !video.ended){currentTime.innerHTML = video.currentTime.toFixed(2);}
},1000/30);

              
            
!
999px

Console