<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Custom HTML5 Video Player with Bootstrap Responsive</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<style>
/* Style the video player container */
.video-player {
position: relative;
width: 100%;
height: 500px;
background-color: #000;
}
/* Style the video element */
.video-player video {
width: 100%;
height: 100%;
object-fit: cover;
}
/* Style the controls */
.controls {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
background-color: rgba(0, 0, 0, 0.5);
padding: 10px;
}
/* Style the play/pause button */
.play-pause-button {
cursor: pointer;
}
/* Style the progress bar */
.progress-bar {
width: 100%;
height: 5px;
background-color: #ccc;
}
.progress-bar-fill {
width: 0%;
height: 100%;
background-color: #007bff;
}
</style>
</head>
<body>
<div class="container">
<div class="video-player">
<video id="myVideo" src="https://www.w3schools.com/html/mov_bbb.mp4" controls></video>
<div class="controls">
<button class="play-pause-button" onclick="playPause()">Play/Pause</button>
<progress class="progress-bar" value="0" max="100">
<div class="progress-bar-fill"></div>
</progress>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script>
const video = document.getElementById('myVideo');
const playPauseButton = document.querySelector('.play-pause-button');
const progressBar = document.querySelector('.progress-bar');
const progressBarFill = document.querySelector('.progress-bar-fill');
function playPause() {
if (video.paused) {
video.play();
playPauseButton.innerHTML = 'Pause';
} else {
video.pause();
playPauseButton.innerHTML = 'Play';
}
}
video.addEventListener('timeupdate', () => {
const progress = (video.currentTime / video.duration) * 100;
progressBarFill.style.width = progress + '%';
});
</script>
</body>
</html>