HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<header class="header" role="banner">
<p>Click the full-screen button to take the video full-screen</p>
<em>This demo is for demonstration purposes only, make sure you view it in a modern browser. IE does not support the full-screen API so it's not going to work in IE.</em>
</header>
<main class="main" role="main">
<div class="custom-video" id="custom-video">
<!--THE VIDEO-->
<video id="myvideo" style="width:100%; height:100%;" poster="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/poster-img.jpg" preload="metadata">
<source src="https://d.pr/f/On5R8M+" type="video/webM" />
<p>Your browser does not support the HTML5 Video Element</p>
</video>
<!--CONTROLS-->
<div id="mycontrols">
<button id="playpause" class="icon-play"></button>
<div class="seeker">
<progress id='progressbar' class="progressbar" max='100' value='0'></progress>
<input type="range" id="seekbar" value="0" class="seekbar" />
</div>
<button id="mute" class="icon-volume-2"></button>
<input type="range" id="volumebar" class="volumebar" value="1" min="0" max="1" step="0.1" />
<button id="fullscreen" class="icon-fullscreen-alt"></button>
</div>
</div>
</main>
.clear:before, .clear:after {
content: ' ';
display: table;
}
.clear {
*zoom: 1;
}
.clear:after {
clear: both;
}
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined in IE 8/9.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
summary {
display: block;
}
/**
* Correct `inline-block` display not defined in IE 8/9.
*/
audio,
canvas,
video {
display: inline-block;
}
/**
* Prevent modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Address `[hidden]` styling not present in IE 8/9.
* Hide the `template` element in IE, Safari, and Firefox < 22.
*/
[hidden],
template {
display: none;
}
/* ==========================================================================
Base
========================================================================== */
/**
* 1. Set default font family to sans-serif.
* 2. Prevent iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-family: sans-serif;
/* 1 */
-ms-text-size-adjust: 100%;
/* 2 */
-webkit-text-size-adjust: 100%;
/* 2 */
}
/**
* Remove default margin.
*/
body {
margin: 0;
}
/* ==========================================================================
Links
========================================================================== */
/**
* Remove the gray background color from active links in IE 10.
*/
a {
background: transparent;
}
/**
* Address `outline` inconsistency between Chrome and other browsers.
*/
a:focus {
outline: thin dotted;
}
/**
* Improve readability when focused and also mouse hovered in all browsers.
*/
a:active,
a:hover {
outline: 0;
}
/* ==========================================================================
Typography
========================================================================== */
/**
* Address variable `h1` font-size and margin within `section` and `article`
* contexts in Firefox 4+, Safari 5, and Chrome.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/**
* Address styling not present in IE 8/9, Safari 5, and Chrome.
*/
abbr[title] {
border-bottom: 1px dotted;
}
/**
* Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome.
*/
b,
strong {
font-weight: bold;
}
/**
* Address styling not present in Safari 5 and Chrome.
*/
dfn {
font-style: italic;
}
/**
* Address differences between Firefox and other browsers.
*/
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
/**
* Address styling not present in IE 8/9.
*/
mark {
background: #ff0;
color: #000;
}
/**
* Correct font family set oddly in Safari 5 and Chrome.
*/
code,
kbd,
pre,
samp {
font-family: monospace, serif;
font-size: 1em;
}
/**
* Improve readability of pre-formatted text in all browsers.
*/
pre {
white-space: pre-wrap;
}
/**
* Set consistent quote types.
*/
q {
quotes: "\201C" "\201D" "\2018" "\2019";
}
/**
* Address inconsistent and variable font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` affecting `line-height` in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* ==========================================================================
Embedded content
========================================================================== */
/**
* Remove border when inside `a` element in IE 8/9.
*/
img {
border: 0;
}
/**
* Correct overflow displayed oddly in IE 9.
*/
svg:not(:root) {
overflow: hidden;
}
/* ==========================================================================
Figures
========================================================================== */
/**
* Address margin not present in IE 8/9 and Safari 5.
*/
figure {
margin: 0;
}
/* ==========================================================================
Forms
========================================================================== */
/**
* Define consistent border, margin, and padding.
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/**
* 1. Correct `color` not being inherited in IE 8/9.
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
*/
legend {
border: 0;
/* 1 */
padding: 0;
/* 2 */
}
/**
* 1. Correct font family not being inherited in all browsers.
* 2. Correct font size not being inherited in all browsers.
* 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome.
*/
button,
input,
select,
textarea {
font-family: inherit;
/* 1 */
font-size: 100%;
/* 2 */
margin: 0;
/* 3 */
}
/**
* Address Firefox 4+ setting `line-height` on `input` using `!important` in
* the UA stylesheet.
*/
button,
input {
line-height: normal;
}
/**
* Address inconsistent `text-transform` inheritance for `button` and `select`.
* All other form control elements do not inherit `text-transform` values.
* Correct `button` style inheritance in Chrome, Safari 5+, and IE 8+.
* Correct `select` style inheritance in Firefox 4+ and Opera.
*/
button,
select {
text-transform: none;
}
/**
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
* and `video` controls.
* 2. Correct inability to style clickable `input` types in iOS.
* 3. Improve usability and consistency of cursor style between image-type
* `input` and others.
*/
button,
html input[type="button"],
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button;
/* 2 */
cursor: pointer;
/* 3 */
}
/**
* Re-set default cursor for disabled elements.
*/
button[disabled],
html input[disabled] {
cursor: default;
}
/**
* 1. Address box sizing set to `content-box` in IE 8/9/10.
* 2. Remove excess padding in IE 8/9/10.
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box;
/* 1 */
padding: 0;
/* 2 */
}
/**
* 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome.
* 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome
* (include `-moz` to future-proof).
*/
input[type="search"] {
-webkit-appearance: textfield;
/* 1 */
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
/* 2 */
box-sizing: content-box;
}
/**
* Remove inner padding and search cancel button in Safari 5 and Chrome
* on OS X.
*/
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* Remove inner padding and border in Firefox 4+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/**
* 1. Remove default vertical scrollbar in IE 8/9.
* 2. Improve readability and alignment in all browsers.
*/
textarea {
overflow: auto;
/* 1 */
vertical-align: top;
/* 2 */
}
/* ==========================================================================
Tables
========================================================================== */
/**
* Remove most spacing between table cells.
*/
table {
border-collapse: collapse;
border-spacing: 0;
}
* {
-webkit-font-smoothing: antialiased;
font-smoothing: antialiased;
text-rendering: optimizeLegibility;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
}
html {
font-size: 62.5%;
}
body {
font: 300 13px/1.6 'Helvetica Neue', Helvetica, Arial;
background: #fff;
color: #444;
}
header{
color: white;
font-size: 2em;
text-align: center;
width: 60%;
margin: 100px auto 20px;
}
header em{
font-size:.7em;
}
@font-face {
font-family: 'Font-Name';
src: url("../fonts/font-name.eot");
src: url("../fonts/font-name.eot?#iefix") format("embedded-opentype"), url("../fonts/font-name.woff") format("woff"), url("../fonts/font-name.ttf") format("truetype"), url("../fonts/font-name.svg#font-name") format("svg");
font-weight: normal;
font-style: normal;
}
::selection {
background: #333;
color: #fff;
text-shadow: none;
}
::-moz-selection {
background: #333;
color: #fff;
text-shadow: none;
}
::-webkit-selection {
background: #333;
color: #fff;
text-shadow: none;
}
@media print {
* {
background: transparent !important;
color: #000 !important;
box-shadow: none !important;
text-shadow: none !important;
}
a,
a:visited {
text-decoration: underline;
}
a[href]:after {
content: " (" attr(href) ")";
}
abbr[title]:after {
content: " (" attr(title) ")";
}
.ir a:after,
a[href^="javascript:"]:after,
a[href^="#"]:after {
content: "";
}
pre,
blockquote {
border: 1px solid #999;
page-break-inside: avoid;
}
thead {
display: table-header-group;
}
tr,
img {
page-break-inside: avoid;
}
img {
max-width: 100% !important;
}
@page {
margin: 0.5cm;
}
p,
h2,
h3 {
orphans: 3;
widows: 3;
}
h2,
h3 {
page-break-after: avoid;
}
}
@font-face {
font-family: 'icomoon';
src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/icomoon.eot");
src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/icomoon.eot?#iefix") format("embedded-opentype"), url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/icomoon.woff") format("woff"), url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/icomoon.ttf") format("truetype"), url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/icomoon.svg#icomoon") format("svg");
font-weight: normal;
font-style: normal;
}
.icon-fullscreen-alt, .icon-fullscreen-exit-alt, .icon-play, .icon-pause, .icon-volume, .icon-volume-2 {
font-family: 'icomoon';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
}
.icon-fullscreen-alt:before {
content: "\e000";
}
.icon-fullscreen-exit-alt:before {
content: "\e001";
}
.icon-play:before {
content: "\e002";
}
.icon-pause:before {
content: "\e003";
}
.icon-volume:before {
content: "\e004";
}
.icon-volume-2:before {
content: "\e005";
}
html, body {
height: 100%;
}
body {
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/blurred.jpg) top left repeat;
background-size: cover;
}
* {
-moz-box-sizing: border-box;
box-sizing: border-box;
border: 0;
}
button {
vertical-align: middle;
background-color: transparent;
color: white;
margin:0 1%;
font-size: 1.2em;
}
.custom-video {
position: relative;
height: 260px;
width: 610px;
margin: 40px auto;
background-color: white;
}
video {
display: block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/poster-img.jpg) no-repeat;
background-size: cover;
}
.custom-video::full-screen {
width: 100%;
height: 100%;
}
::-moz-full-screen .custom-video {
width: 100%;
height: 100%;
}
.custom-video::-moz-full-screen {
width: 100%;
height: 100%;
}
.custom-video::-webkit-full-screen {
width: 100%;
height: 100%;
}
#mycontrols {
position: absolute;
bottom: 0;
left: 0;
right: 0;
color: white;
font-size: .8em;
width: 100%;
min-height: 40px;
padding: 10px 5px;
background-color: black;
background-color: rgba(0, 0, 0, 0.75);
z-index: 2147483647;
}
input[type=range] {
border-radius: 2px;
vertical-align: middle;
-webkit-appearance: none;
-moz-appearance: none;
background-color: rgba(255, 255, 255, 0.7);
height: 1px;
border: none;
cursor: pointer;
}
input[type=range]::-moz-range-track {
vertical-align: middle;
border-radius: 2px;
background-color: rgba(255, 255, 255, 0.7);
-moz-appearance: none;
background-color: white;
height: 1px;
cursor: pointer;
}
input[type=range]::-moz-range-thumb {
border-radius: 50%;
height: 8px;
width: 8px;
background-color: white;
border: 0;
}
input[type=range].light::-moz-range-thumb {
box-shadow: 0 0 8px 2px white;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border-radius: 50%;
height: 8px;
width: 8px;
background-color: white;
border: 0;
}
input[type=range].light::-webkit-slider-thumb {
box-shadow: 0 0 8px 2px white;
}
input[type=range]:active::-moz-range-track {
background: orange;
}
.seeker {
position: relative;
width: 65%;
margin: 0 1%;
z-index: 0;
display: inline-block;
margin-right: 5px;
margin: 0 10px;
}
.seekbar {
z-index: 3;
position: relative;
width: 100%;
background-color: transparent !important;
}
.progressbar, .bufferbar {
position: absolute;
left: 0;
top: 8px;
width: 100%;
pointer-events: none;
height: 1px;
z-index: 2;
/* Turns off styling - not usually needed, but good to know. */
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
/* gets rid of default border in Firefox and Opera. */
border: none;
background: rgba(255, 255, 255, 0.1);
color: #c0392b;
}
.progressbar::-moz-progress-bar, .bufferbar::-moz-progress-bar {
background: #c0392b;
}
.progressbar::-webkit-progress-bar, .bufferbar::-webkit-progress-bar {
background: rgba(255, 255, 255, 0.1);
}
.progressbar::-webkit-progress-value, .bufferbar::-webkit-progress-value {
background: #c0392b;
}
.bufferbar {
z-index: 1;
color: #aaa;
}
.bufferbar::-moz-progress-bar {
background: #aaa;
}
.bufferbar::-webkit-progress-value {
background: #aaa;
}
.volumebar {
width: 8%;
margin: 0 1%;
}
/*hide controls from shadow DOM in webkit browsers*/
/* hides controls only in fullscreen, but shows them in normal screen even if controls is set to false*/
/*the most specific pseudo-element to target video controls on full screen*/
video::-webkit-media-controls-enclosure {
display: none !important;
}
// EventListener | MIT/GPL2 | github.com/jonathantneal/EventListener
this.Element &&
Element.prototype.attachEvent &&
!Element.prototype.addEventListener &&
(function() {
function addToPrototype(name, method) {
Window.prototype[name] = HTMLDocument.prototype[name] = Element.prototype[
name
] = method;
}
// add
addToPrototype("addEventListener", function(type, listener) {
var target = this,
listeners = (target.addEventListener.listeners =
target.addEventListener.listeners || {}),
typeListeners = (listeners[type] = listeners[type] || []);
// if no events exist, attach the listener
if (!typeListeners.length) {
target.attachEvent(
"on" + type,
(typeListeners.event = function(event) {
var documentElement = (target.document &&
target.document.documentElement) ||
target.documentElement || { scrollLeft: 0, scrollTop: 0 };
// polyfill w3c properties and methods
event.currentTarget = target;
event.pageX = event.clientX + documentElement.scrollLeft;
event.pageY = event.clientY + documentElement.scrollTop;
event.preventDefault = function() {
event.returnValue = false;
};
event.relatedTarget = event.fromElement || null;
event.stopImmediatePropagation = function() {
immediatePropagation = false;
event.cancelBubble = true;
};
event.stopPropagation = function() {
event.cancelBubble = true;
};
event.target = event.srcElement || target;
event.timeStamp = +new Date();
// create an cached list of the master events list (to protect this loop from breaking when an event is removed)
for (
var i = 0,
typeListenersCache = [].concat(typeListeners),
typeListenerCache,
immediatePropagation = true;
immediatePropagation &&
(typeListenerCache = typeListenersCache[i]);
++i
) {
// check to see if the cached event still exists in the master events list
for (
var ii = 0, typeListener;
(typeListener = typeListeners[ii]);
++ii
) {
if (typeListener == typeListenerCache) {
typeListener.call(target, event);
break;
}
}
}
})
);
}
// add the event to the master event list
typeListeners.push(listener);
});
// remove
addToPrototype("removeEventListener", function(type, listener) {
var target = this,
listeners = (target.addEventListener.listeners =
target.addEventListener.listeners || {}),
typeListeners = (listeners[type] = listeners[type] || []);
// remove the newest matching event from the master event list
for (
var i = typeListeners.length - 1, typeListener;
(typeListener = typeListeners[i]);
--i
) {
if (typeListener == listener) {
typeListeners.splice(i, 1);
break;
}
}
// if no events exist, detach the listener
if (!typeListeners.length && typeListeners.event) {
target.detachEvent("on" + type, typeListeners.event);
}
});
// dispatch
addToPrototype("dispatchEvent", function(eventObject) {
var target = this,
type = eventObject.type,
listeners = (target.addEventListener.listeners =
target.addEventListener.listeners || {}),
typeListeners = (listeners[type] = listeners[type] || []);
try {
return target.fireEvent("on" + type, eventObject);
} catch (error) {
if (typeListeners.event) {
typeListeners.event(eventObject);
}
return;
}
});
// CustomEvent
Object.defineProperty(Window.prototype, "CustomEvent", {
get: function() {
var self = this;
return function CustomEvent(type, eventInitDict) {
var event = self.document.createEventObject(),
key;
event.type = type;
for (key in eventInitDict) {
if (key == "cancelable") {
event.returnValue = !eventInitDict.cancelable;
} else if (key == "bubbles") {
event.cancelBubble = !eventInitDict.bubbles;
} else if (key == "detail") {
event.detail = eventInitDict.detail;
}
}
return event;
};
}
});
// ready
function ready(event) {
if (ready.interval && document.body) {
ready.interval = clearInterval(ready.interval);
document.dispatchEvent(new CustomEvent("DOMContentLoaded"));
}
}
ready.interval = setInterval(ready, 1);
window.addEventListener("load", ready);
})();
/*!
* H5VF
* HTML5 Video Framework
* http://sarasoueidan.com/h5vf
* @author Sara Soueidan
* @version 1.0.0
* Copyright 2013. MIT licensed.
*/
(function($, window, document, undefined) {
"use strict";
$(function() {
var video = document.getElementById("myvideo"),
container = document.getElementById("custom-video"),
playbutton = document.getElementById("playpause"),
mutebutton = document.getElementById("mute"),
fullscreenbutton = document.getElementById("fullscreen"),
seek = document.getElementById("seekbar"),
volume = document.getElementById("volumebar"),
vval = volume.value,
progressbar = document.getElementById("progressbar"),
bufferbar = document.getElementById("bufferbar");
if (video.autoplay) {
playbutton.classList.add("icon-pause");
playbutton.classList.remove("icon-play");
}
video.addEventListener(
"playing",
function() {
seek.classList.add("light");
},
false
);
if (video.muted) {
mutebutton.classList.add("icon-volume");
mutebutton.classList.remove("icon-volume-2");
volume.value = 0;
} else {
mutebutton.classList.add("icon-volume-2");
mutebutton.classList.remove("icon-volume");
}
function playpause() {
if (video.paused) {
video.play();
playbutton.classList.add("icon-pause");
playbutton.classList.remove("icon-play");
seek.classList.add("light");
} else {
video.pause();
playbutton.classList.add("icon-play");
playbutton.classList.remove("icon-pause");
seek.classList.remove("light");
}
}
playbutton.addEventListener("click", playpause, false);
video.addEventListener("click", playpause, false);
mutebutton.addEventListener(
"click",
function() {
if (video.muted) {
video.muted = false;
mutebutton.classList.add("icon-volume-2");
mutebutton.classList.remove("icon-volume");
volume.value = vval;
} else {
video.muted = true;
volume.value = 0;
mutebutton.classList.add("icon-volume");
mutebutton.classList.remove("icon-volume-2");
}
},
false
);
var isFullscreen = false;
fullscreenbutton.addEventListener(
"click",
function() {
if (!isFullscreen) {
if (video.requestFullscreen) {
video.requestFullscreen();
} else if (video.mozRequestFullScreen) {
container.mozRequestFullScreen(); // Firefox
} else if (video.webkitRequestFullscreen) {
video.webkitRequestFullscreen(); // Chrome and Safari
}
isFullscreen = true;
fullscreenbutton.classList.remove("icon-fullscreen-alt");
fullscreenbutton.classList.add("icon-fullscreen-exit-alt");
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
isFullscreen = false;
fullscreenbutton.classList.add("icon-fullscreen-alt");
fullscreenbutton.classList.remove("icon-fullscreen-exit-alt");
}
},
false
);
//change video time when seek changes
seek.addEventListener(
"change",
function() {
var time = video.duration * (seek.value / 100);
video.currentTime = time;
},
false
);
seek.addEventListener(
"mousedown",
function() {
video.pause();
},
false
);
seek.addEventListener(
"mouseup",
function() {
video.play();
//if the user plays the video without clicking play, by starting directly with specifying a point of time on the seekbar, make sure the play button becomes a pause button
playbutton.classList.remove("icon-play");
playbutton.classList.add("icon-pause");
},
false
);
//update progress bar as video plays
video.addEventListener(
"timeupdate",
function() {
var percent = Math.floor(100 / video.duration * video.currentTime);
progressbar.value = percent;
progressbar.getElementsByTagName("span")[0].innerHTML = percent;
},
false
);
//change seek position as video plays
video.addEventListener(
"timeupdate",
function() {
var value = 100 / video.duration * video.currentTime;
seek.value = value;
},
false
);
volume.addEventListener(
"change",
function() {
video.volume = this.value;
vval = this.value;
if (this.value === 0) {
video.muted = true;
mutebutton.classList.add("icon-volume");
mutebutton.classList.remove("icon-volume-2");
} else if (this.value !== 0) {
video.muted = false;
mutebutton.classList.add("icon-volume-2");
mutebutton.classList.remove("icon-volume");
}
},
false
);
video.addEventListener("ended", function() {
video.pause();
video.currentTime = 0;
playbutton.classList.add("icon-play");
playbutton.classList.remove("icon-pause");
seek.classList.remove("light");
});
});
})(jQuery, window, document);
Also see: Tab Triggers