Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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

              
                	<h1>Custom HTML5 Video Player Demo</h1>
	<div id='player'>
		<video id='video-element'>
			<source src='https://www.w3schools.com/html/mov_bbb.mp4' type='video/mp4'>
			<source src='https://www.w3schools.com/html/mov_bbb.ogg' type='video/ogg'>
		</video>
		<div id='controls'>
			<progress id='progress-bar' min='0' max='100' value='0'>0% played</progress>
			<button id='btnReplay' class='replay' title='replay' accesskey="R" onclick='replayVideo();'>Replay</button>	
			<button id='btnPlayPause' class='play' title='play' accesskey="P" onclick='playPauseVideo();'>Play</button>
			<button id='btnStop' class='stop' title='stop' accesskey="X" onclick='stopVideo();'>Stop</button>
      <input type="range" id="volume-bar" title="volume" min="0" max="1" step="0.1" value="1">
			<button id='btnMute' class='mute' title='mute' onclick='muteVolume();'>Mute</button>	
      <button id='btnFullScreen' class='fullscreen' title='toggle full screen' accesskey="T" onclick='toggleFullScreen();'>[&nbsp;&nbsp;]</button>
		</div>
	</div>	
  <div style="clear:both"></div>
  <p>Video courtesy of <a href="http://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>
  <p>Volume bar styled using <a href="http://danielstern.ca/range.css/#/" target="_blank">range.css</a>. </p>

<hr />
<p>If you find this demo useful, please consider <a href="https://www.paypal.me/RobertGravelle/1" target="_blank">donating $1 dollar</a> (secure PayPal link) for a coffee or purchasing one of my songs from <a href="https://ax.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?term=rob%20gravelle" target="_blank">iTunes.com</a> or <a href="http://www.amazon.com/s/ref=ntt_srch_drd_B001ES9TTK?ie=UTF8&field-keywords=Rob%20Gravelle&index=digital-music&search-type=ss" target="_blank">Amazon.com</a> for only 0.99 cents each. I have also released CDs with my band <a href="https://www.cdbaby.com/Artist/IvoryKnight" target="_blank">Ivory Knight</a> and Annihilator main-man Jeff Waters.</p>
<p>Rob uses and recommends <a href="http://www.mochahost.com/2425.html" target="_blank">MochaHost</a>, which provides Web Hosting for as low as $1.95 per month, as well as unlimited emails and disk space!</p>
              
            
!

CSS

              
                    body { 
      font-family: Verdana, Geneva, sans-serif; 
      back    body { 
      font-family: Verdana, Geneva, sans-serif; 
      background-color: lightgray;
    }
    
    p { font-size: 0.9em; }

    h1 { 
    	font-size:16px;
    	color:#333;
    }
    
    #player {
    	float:left;
    	padding:1em 1em .5em;
    	background-color:black;
      border:2px solid darkgreen;
      border-radius: 9px;
    }
    
    #controls {
      border: 1px solid darkgreen;
      width: 420px;
      margin-left: auto;
      margin-right: auto;
      text-align: center;
      margin-top: 5px;
      padding-bottom: 3px;
      border-radius: 7px;
    }
    
    video {
    	border:1px solid darkgreen;
    	width:420px;
    	height:231px;
    	background:black;
    }
    
    button {
    	text-indent:-9999px;
    	width:16px;
    	height:16px;
    	border:none;
    	cursor:pointer;
    	background:transparent url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJEAAAAQCAYAAAAWNJ1eAAAAB3RJTUUH4AMQDS0aGLmsqwAAAAlwSFlzAAAOdAAADnQBaySz1gAAAvZJREFUeNrtmk2u0zAQxyele7gBZcOWcAJ8AKTXFVvKhnW5QbhBD4BEe4GnvgULdkaCNeUE5N2gbJGgeDJ26rhO4rFbKRX5P7mtP+YX2x1PHPdl4ErCa/W6UEmc1ACsVekGQjWyeKwrVWYN+bF63aqU99jsVJqryblvbTGyeKxrkoSPesxC/f3CosyaEBzso0DUvgL5JmZk8VhdoihXKLsnLLtLsYix1jkcf+VIU12wZUwI6LZo89xTN7J4rFOZLxxgxrjG+Vm0WNB27hlvXrWQICb6Im5IXqhU9lwi17Zuh13WS2juF/Dzq0TWW+tzLMvuj2ip47J480W8G5V+qnSwStfg+9KxDbW98V6Bw+qThGdA0WYBPQtmohu507rRYQ/ryg77RU8e9Vmlb1b+q0q3iawPqn+fEllmrF+qlDbGUDVtyRkwQs0YjFll4zpSHMsvikASyHnwVlwALbSV1aq+nU2gfRWGOJPoyaNw33VwyqYDYIXqkqwV0x5vK7sWWy6rSwUcHQgd5b1ebO+AIlvtQNh4GoSkx9RN5P0Vr/HbKTsw7P0sWT9ZxrBET5lMZNnqYs2Yvb7TNF/E4bGkM2/CelInZ0WtVPkPp90bZfvQOBAqzInS9MdTFutE52H5bl92mUxk2eKwhiOzB/L33nIgVJgTpT0tZE7+AcQ70XlY9ioU9TFHXJ9i7UglcOaU9j2FZRvPEidzyR33C9BONoGutYLOg7v99h2+7Mn79Bf8X3w4S9T26ayQ6boca8m0tw83l4msLu31u+hoY+r26ERrz1D7nMdo3ZNHPQWKGEa5LotnySrcThNZobocC/c4tP8oGYwS6AT87gysNm31+1I/6jdFZcZptyaUfwf+2cdOdfz08Gxk8VhNLm1Y3e1DzK0nhdU8kceotIJjFBVADmTq8omumMMxhIVoD8cdvKuRxWMdZTas4ed0l2HRzzNC9xudpQByIgmnj//34w+wQ2ANVf6fPfZ63IUZU+YxHOa/SfwPrCvVP/2nY6KBhDUMAAAAAElFTkSuQmCC') no-repeat 0 0; /* url('buttons.png') */
    }
    
    .pause { background-position:-19px 0; }
    .stop { background-position:-38px 0; }

    #volume-bar {
	    width: 50px;
      vertical-align: middle;
      padding:0px;
    }
    .mute { background-position:-95px 0; }
    .unmute { background-position:-114px 0; }
    .replay { background-position:-133px 0; }
    .fullscreen {
        text-indent: 0px;
        color: #00c600;
        background-color: black;
        background-image: none;
        padding: 0px;
        font-weight: bold;
        padding-bottom: 3px;
    }

    
    progress {
      color: green;
      font-size: 12px;
      width: 220px;
      height: 16px;
      border: none;
      margin-right: 10px;
      background: #434343;
      border-radius: 9px;
      vertical-align: middle;
    }
    progress::-moz-progress-bar { 
      color:green;
      background:#434343; 
    }
    
    progress[value]::-webkit-progress-bar {
      background-color: #434343;
      border-radius: 2px;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;
    }
    
    progress[value]::-webkit-progress-value {
      background-color: green;
    }
    
    input[type=range] {
      -webkit-appearance: none;
      width: 100%;
      margin: 6.8px 0;
    }
    input[type=range]:focus {
      outline: none;
    }
    input[type=range]::-webkit-slider-runnable-track {
      width: 100%;
      height: 4.4px;
      cursor: pointer;
      box-shadow: 0.9px 0.9px 1.7px #002200, 0px 0px 0.9px #003c00;
      background: #205928;
      border-radius: 1px;
      border: 1.1px solid #18d501;
    }
    input[type=range]::-webkit-slider-thumb {
      box-shadow: 2.6px 2.6px 3.7px #00aa00, 0px 0px 2.6px #00c300;
      border: 2.5px solid #83e584;
      height: 18px;
      width: 9px;
      border-radius: 3px;
      background: #439643;
      cursor: pointer;
      -webkit-appearance: none;
      margin-top: -7.9px;
    }
    input[type=range]:focus::-webkit-slider-runnable-track {
      background: #276c30;
    }
    input[type=range]::-moz-range-track {
      width: 100%;
      height: 4.4px;
      cursor: pointer;
      box-shadow: 0.9px 0.9px 1.7px #002200, 0px 0px 0.9px #003c00;
      background: #205928;
      border-radius: 1px;
      border: 1.1px solid #18d501;
    }
    input[type=range]::-moz-range-thumb {
      box-shadow: 2.6px 2.6px 3.7px #00aa00, 0px 0px 2.6px #00c300;
      border: 2.5px solid #83e584;
      height: 18px;
      width: 9px;
      border-radius: 3px;
      background: #439643;
      cursor: pointer;
    }
    input[type=range]::-ms-track {
      width: 100%;
      height: 4.4px;
      cursor: pointer;
      background: transparent;
      border-color: transparent;
      color: transparent;
    }
    input[type=range]::-ms-fill-lower {
      background: #194620;
      border: 1.1px solid #18d501;
      border-radius: 2px;
      box-shadow: 0.9px 0.9px 1.7px #002200, 0px 0px 0.9px #003c00;
    }
    input[type=range]::-ms-fill-upper {
      background: #205928;
      border: 1.1px solid #18d501;
      border-radius: 2px;
      box-shadow: 0.9px 0.9px 1.7px #002200, 0px 0px 0.9px #003c00;
    }
    input[type=range]::-ms-thumb {
      box-shadow: 2.6px 2.6px 3.7px #00aa00, 0px 0px 2.6px #00c300;
      border: 2.5px solid #83e584;
      height: 18px;
      width: 9px;
      border-radius: 3px;
      background: #439643;
      cursor: pointer;
      height: 4.4px;
    }
    input[type=range]:focus::-ms-fill-lower {
      background: #205928;
    }
    input[type=range]:focus::-ms-fill-upper {
      background: #276c30;
    }ground-color: lightgray;
    }
    
    p { font-size: 0.9em; }

    h1 { 
    	font-size:16px;
    	color:#333;
    }
    
    #player {
    	float:left;
    	padding:1em 1em .5em;
    	background-color:black;
      border:2px solid darkgreen;
      border-radius: 9px;
    }
    
    #controls {
      border: 1px solid darkgreen;
      width: 420px;
      margin-left: auto;
      margin-right: auto;
      text-align: center;
      margin-top: 5px;
      padding-bottom: 3px;
      border-radius: 7px;
    }
    
    video {
    	border:1px solid darkgreen;
    	width:420px;
    	height:231px;
    	background:black;
    }
    
    button {
    	text-indent:-9999px;
    	width:16px;
    	height:16px;
    	border:none;
    	cursor:pointer;
    	background:transparent url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJEAAAAQCAYAAAAWNJ1eAAAAB3RJTUUH4AMQDS0aGLmsqwAAAAlwSFlzAAAOdAAADnQBaySz1gAAAvZJREFUeNrtmk2u0zAQxyele7gBZcOWcAJ8AKTXFVvKhnW5QbhBD4BEe4GnvgULdkaCNeUE5N2gbJGgeDJ26rhO4rFbKRX5P7mtP+YX2x1PHPdl4ErCa/W6UEmc1ACsVekGQjWyeKwrVWYN+bF63aqU99jsVJqryblvbTGyeKxrkoSPesxC/f3CosyaEBzso0DUvgL5JmZk8VhdoihXKLsnLLtLsYix1jkcf+VIU12wZUwI6LZo89xTN7J4rFOZLxxgxrjG+Vm0WNB27hlvXrWQICb6Im5IXqhU9lwi17Zuh13WS2juF/Dzq0TWW+tzLMvuj2ip47J480W8G5V+qnSwStfg+9KxDbW98V6Bw+qThGdA0WYBPQtmohu507rRYQ/ryg77RU8e9Vmlb1b+q0q3iawPqn+fEllmrF+qlDbGUDVtyRkwQs0YjFll4zpSHMsvikASyHnwVlwALbSV1aq+nU2gfRWGOJPoyaNw33VwyqYDYIXqkqwV0x5vK7sWWy6rSwUcHQgd5b1ebO+AIlvtQNh4GoSkx9RN5P0Vr/HbKTsw7P0sWT9ZxrBET5lMZNnqYs2Yvb7TNF/E4bGkM2/CelInZ0WtVPkPp90bZfvQOBAqzInS9MdTFutE52H5bl92mUxk2eKwhiOzB/L33nIgVJgTpT0tZE7+AcQ70XlY9ioU9TFHXJ9i7UglcOaU9j2FZRvPEidzyR33C9BONoGutYLOg7v99h2+7Mn79Bf8X3w4S9T26ayQ6boca8m0tw83l4msLu31u+hoY+r26ERrz1D7nMdo3ZNHPQWKGEa5LotnySrcThNZobocC/c4tP8oGYwS6AT87gysNm31+1I/6jdFZcZptyaUfwf+2cdOdfz08Gxk8VhNLm1Y3e1DzK0nhdU8kceotIJjFBVADmTq8omumMMxhIVoD8cdvKuRxWMdZTas4ed0l2HRzzNC9xudpQByIgmnj//34w+wQ2ANVf6fPfZ63IUZU+YxHOa/SfwPrCvVP/2nY6KBhDUMAAAAAElFTkSuQmCC') no-repeat 0 0; /* url('buttons.png') */
    }
    
    .pause { background-position:-19px 0; }
    .stop { background-position:-38px 0; }

    #volume-bar {
	    width: 50px;
      vertical-align: middle;
      padding:0px;
    }
    .mute { background-position:-95px 0; }
    .unmute { background-position:-114px 0; }
    .replay { background-position:-133px 0; }
    .fullscreen {
        text-indent: 0px;
        color: #00c600;
        background-color: black;
        background-image: none;
        padding: 0px;
        font-weight: bold;
        padding-bottom: 3px;
    }

    
    progress {
      color: green;
      font-size: 12px;
      width: 220px;
      height: 16px;
      border: none;
      margin-right: 10px;
      background: #434343;
      border-radius: 9px;
      vertical-align: middle;
    }
    progress::-moz-progress-bar { 
      color:green;
      background:#434343; 
    }
    
    progress[value]::-webkit-progress-bar {
      background-color: #434343;
      border-radius: 2px;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;
    }
    
    progress[value]::-webkit-progress-value {
      background-color: green;
    }
    
    input[type=range] {
      -webkit-appearance: none;
      width: 100%;
      margin: 6.8px 0;
    }
    input[type=range]:focus {
      outline: none;
    }
    input[type=range]::-webkit-slider-runnable-track {
      width: 100%;
      height: 4.4px;
      cursor: pointer;
      box-shadow: 0.9px 0.9px 1.7px #002200, 0px 0px 0.9px #003c00;
      background: #205928;
      border-radius: 1px;
      border: 1.1px solid #18d501;
    }
    input[type=range]::-webkit-slider-thumb {
      box-shadow: 2.6px 2.6px 3.7px #00aa00, 0px 0px 2.6px #00c300;
      border: 2.5px solid #83e584;
      height: 18px;
      width: 9px;
      border-radius: 3px;
      background: #439643;
      cursor: pointer;
      -webkit-appearance: none;
      margin-top: -7.9px;
    }
    input[type=range]:focus::-webkit-slider-runnable-track {
      background: #276c30;
    }
    input[type=range]::-moz-range-track {
      width: 100%;
      height: 4.4px;
      cursor: pointer;
      box-shadow: 0.9px 0.9px 1.7px #002200, 0px 0px 0.9px #003c00;
      background: #205928;
      border-radius: 1px;
      border: 1.1px solid #18d501;
    }
    input[type=range]::-moz-range-thumb {
      box-shadow: 2.6px 2.6px 3.7px #00aa00, 0px 0px 2.6px #00c300;
      border: 2.5px solid #83e584;
      height: 18px;
      width: 9px;
      border-radius: 3px;
      background: #439643;
      cursor: pointer;
    }
    input[type=range]::-ms-track {
      width: 100%;
      height: 4.4px;
      cursor: pointer;
      background: transparent;
      border-color: transparent;
      color: transparent;
    }
    input[type=range]::-ms-fill-lower {
      background: #194620;
      border: 1.1px solid #18d501;
      border-radius: 2px;
      box-shadow: 0.9px 0.9px 1.7px #002200, 0px 0px 0.9px #003c00;
    }
    input[type=range]::-ms-fill-upper {
      background: #205928;
      border: 1.1px solid #18d501;
      border-radius: 2px;
      box-shadow: 0.9px 0.9px 1.7px #002200, 0px 0px 0.9px #003c00;
    }
    input[type=range]::-ms-thumb {
      box-shadow: 2.6px 2.6px 3.7px #00aa00, 0px 0px 2.6px #00c300;
      border: 2.5px solid #83e584;
      height: 18px;
      width: 9px;
      border-radius: 3px;
      background: #439643;
      cursor: pointer;
      height: 4.4px;
    }
    input[type=range]:focus::-ms-fill-lower {
      background: #205928;
    }
    input[type=range]:focus::-ms-fill-upper {
      background: #276c30;
}
              
            
!

JS

              
                // Get a handle to the player
	player       = document.getElementById('video-element');
	btnPlayPause = document.getElementById('btnPlayPause');
	btnMute      = document.getElementById('btnMute');
	progressBar  = document.getElementById('progress-bar');
  volumeBar    = document.getElementById('volume-bar');

  // Update the video volume
  volumeBar.addEventListener("change", function(evt) {
		player.volume = evt.target.value;
	});
  document.getElementById('btnFullScreen').disabled = true;
	// Add a listener for the timeupdate event so we can update the progress bar
	player.addEventListener('timeupdate', updateProgressBar, false);
	
	// Add a listener for the play and pause events so the buttons state can be updated
	player.addEventListener('play', function() {
		// Change the button to be a pause button
		changeButtonType(btnPlayPause, 'pause');
	}, false);
  
	player.addEventListener('pause', function() {
		// Change the button to be a play button
		changeButtonType(btnPlayPause, 'play');
	}, false);
	
	player.addEventListener('volumechange', function(e) { 
		// Update the button to be mute/unmute
		if (player.muted) changeButtonType(btnMute, 'unmute');
		else changeButtonType(btnMute, 'mute');
	}, false);	
  
	player.addEventListener('ended', function() { this.pause(); }, false);	
  
  progressBar.addEventListener("click", seek);

  function seek(e) {
      var percent = e.offsetX / this.offsetWidth;
      player.currentTime = percent * player.duration;
      e.target.value = Math.floor(percent / 100);
      e.target.innerHTML = progressBar.value + '% played';
  }

  function playPauseVideo() {
  	if (player.paused || player.ended) {
  		// Change the button to a pause button
  		changeButtonType(btnPlayPause, 'pause');
  		player.play();
  	}
  	else {
  		// Change the button to a play button
  		changeButtonType(btnPlayPause, 'play');
  		player.pause();
  	}
  }
  
  // Stop the current media from playing, and return it to the start position
  function stopVideo() {
  	player.pause();
  	if (player.currentTime) player.currentTime = 0;
  }
  
  // Toggles the media player's mute and unmute status
  function muteVolume() {
  	if (player.muted) {
  		// Change the button to a mute button
  		changeButtonType(btnMute, 'mute');
  		player.muted = false;
  	}
  	else {
  		// Change the button to an unmute button
  		changeButtonType(btnMute, 'unmute');
  		player.muted = true;
  	}
  }
  
  // Replays the media currently loaded in the player
  function replayVideo() {
  	resetPlayer();
  	player.play();
  }
  
  // Update the progress bar
  function updateProgressBar() {
  	// Work out how much of the media has played via the duration and currentTime parameters
  	var percentage = Math.floor((100 / player.duration) * player.currentTime);
  	// Update the progress bar's value
  	progressBar.value = percentage;
  	// Update the progress bar's text (for browsers that don't support the progress element)
  	progressBar.innerHTML = percentage + '% played';
  }
  
  // Updates a button's title, innerHTML and CSS class
  function changeButtonType(btn, value) {
  	btn.title     = value;
  	btn.innerHTML = value;
  	btn.className = value;
  }
  
  function resetPlayer() {
  	progressBar.value = 0;
  	// Move the media back to the start
  	player.currentTime = 0;
  	// Set the play/pause button to 'play'
  	changeButtonType(btnPlayPause, 'play');
  }  
  
  function exitFullScreen() {
    if (document.exitFullscreen) {
        document.exitFullscreen();
    } else if (document.msExitFullscreen) {
        document.msExitFullscreen();
    } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    } else if (document.webkitExitFullscreen) {
        document.webkitExitFullscreen();
    }
  }
  
  function toggleFullScreen() {
    //var player = document.getElementById("player");

    if (player.requestFullscreen)
        if (document.fullScreenElement) {
            document.cancelFullScreen();
        } else {
            player.requestFullscreen();
        }
        else if (player.msRequestFullscreen)
        if (document.msFullscreenElement) {
            document.msExitFullscreen();
        } else {
            player.msRequestFullscreen();
        }
        else if (player.mozRequestFullScreen)
        if (document.mozFullScreenElement) {
            document.mozCancelFullScreen();
        } else {
            player.mozRequestFullScreen();
        }
        else if (player.webkitRequestFullscreen)
        if (document.webkitFullscreenElement) {
            document.webkitCancelFullScreen();
        } else {
            player.webkitRequestFullscreen();
        }
    else {
        alert("Fullscreen API is not supported");
        
    }
  }
              
            
!
999px

Console