<figure>
<video controls id="video" src="https://assets.codepen.io/9632/SampleVideo_1280x720_1mb.mp4"></video>
<figcaption>
<label id="timer" for="progress" role="timer"></label>
<progress id="progress" max="100" value="0">Progress</progress>
</figcaotion>
</figure>
body {
background-image: radial-gradient(circle at top right, #17141d, white);
display: grid;
height: 100vh;
place-items: center;
width: 100%;
}
figure {
box-shadow: 0 2.8px 2.2px rgba(0, 0, 0, 0.034),
0 6.7px 5.3px rgba(0, 0, 0, 0.048), 0 12.5px 10px rgba(0, 0, 0, 0.06),
0 22.3px 17.9px rgba(0, 0, 0, 0.072), 0 41.8px 33.4px rgba(0, 0, 0, 0.086),
0 100px 80px rgba(0, 0, 0, 0.12);
width: 50%;
}
video {
display: block;
width: 100%;
}
figcaption {
align-items: center;
background: #eaeaea;
display: grid;
grid-gap: 1rem;
grid-template-columns: auto min(115px);
padding: 0.5rem;
}
button {
border: 0;
background: #e52e71;
display: inline;
color: white;
order: 1;
padding: 0.5rem;
transition: opacity 0.25s ease-out;
width: 100%;
}
button:hover {
cursor: pointer;
opacity: 0.8;
}
label {
order: 2;
text-align: center;
}
/* Fallback stuff */
progress[value] {
appearance: none;
border: none;
border-radius: 3px;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25) inset;
color: dodgerblue;
display: inline;
height: 15px;
order: 1;
position: relative;
width: 100%;
}
/* WebKit styles */
progress[value]::-webkit-progress-bar {
background-color: whiteSmoke;
border-radius: 3px;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25) inset;
}
progress[value]::-webkit-progress-value {
background-image: linear-gradient(to right, #ff8a00, #e52e71);
border-radius: 3px;
position: relative;
transition: width 1s linear;
}
/* Firefox styles */
progress[value]::-moz-progress-bar {
background-image: -moz-linear-gradient(to right, #ff8a00, #e52e71);
border-radius: 3px;
position: relative;
transition: width 1s linear;
}
const progress = document.getElementById("progress");
const timer = document.getElementById("timer");
function progressLoop() {
setInterval(function () {
progress.value = Math.round((video.currentTime / video.duration) * 100);
timer.innerHTML = Math.round(video.currentTime) + " seconds";
});
}
progressLoop();
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.