This is an experimental interface to implement a video player using the Bootstrap 5 framework. The HTML structure was deliberately created so that you can customize the player to your own design using Bootstrap's built-in CSS classes.
This project is still experimental! Do not use it in a live environment when you don't know what you're doing ;-)
CONTRIBUTE// You must provide the element ID
var myPlayer = new BootstrapVideoplayer('myCustomPlayer')
/*
* You must provide the element ID
* Settings are optional and will be merged with default settings
* Make sure you change the CSS as well, when you define custom class names here
*/
var myPlayer = new BootstrapVideoplayer('myCustomPlayer',{
selectors:{
video: '.video',
playPauseButton: '.btn-video-playpause',
playIcon: '.bi-play-fill',
pauseIcon: '.bi-pause-fill',
progress: '.progress',
progressbar: '.progress-bar',
pipButton: '.btn-video-pip',
fullscreenButton: '.btn-video-fullscreen',
volumeRange: '.form-range-volume'
}
})
<!--
Make sure to include the Bootstrap CSS and the Video Player CSS file in your website header:
<link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" rel="stylesheet">
<link href="videoplayer.min.css" rel="stylesheet">
-->
<div class="videoplayer" id="myCustomPlayer">
<div class="ratio ratio-16x9 bg-dark">
<video class="video" src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4"></video>
<div>
<div class="controls">
<button class="btn btn-lg btn-video-playpause" type="button" title="Play Video">
<i class="bi bi-play-fill"></i>
<i class="bi bi-pause-fill d-none"></i>
</button>
<div class="px-1 w-100">
<div class="progress w-100">
<div class="progress-bar"></div>
</div>
</div>
<button class="btn btn-lg btn-video-pip" title="Play picture in picture">
<i class="bi bi-pip"></i>
</button>
<button class="btn btn-lg btn-video-fullscreen">
<i class="bi bi-arrows-fullscreen"></i>
</button>
<div class="dropup">
<button class="btn btn-lg btn-video-volume" data-bs-toggle="dropdown" title="Volume">
<i class="bi bi-volume-mute-fill"></i>
</button>
<div class="dropdown-menu dropdown-menu-end dropup-volume">
<input type="range" class="form-range form-range-volume">
</div>
</div>
<div class="dropup">
<button class="btn btn-lg" data-bs-toggle="dropdown" title="More...">
<i class="bi bi-three-dots-vertical"></i>
</button>
<div class="dropdown-menu dropdown-menu-end">
<a class="dropdown-item" href="#">
<i class="bi bi-info-circle-fill"></i> About
</a>
</div>
</div>
</div>
</div>
/*
Make sure to include the Bootstrap CSS and the Video Player CSS file in your website header:
<link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" rel="stylesheet">
<link href="videoplayer.min.css" rel="stylesheet">
*/
.videoplayer {
position: relative;
display: block;
}
.videoplayer video {
max-width: 100%;
max-height: 100%;
}
.videoplayer .controls {
position: absolute;
bottom: 0;
display: flex;
width: 100%;
align-items: center;
bottom: 0;
background-color: #eee;
}
.videoplayer .controls .progress {
background-color: #333;
}
.videoplayer .controls .progress .progress-bar {
transition: none !important;
background-color: #666;
}
.videoplayer .controls.controls-light .bi {
color: #2b2b2b;
}
.videoplayer .controls.controls-dark {
background-color: #2b2b2b;
}
.videoplayer .controls.controls-dark .bi {
color: #eee;
}
.videoplayer .controls.controls-dark .progress {
background-color: #ccc;
}
.videoplayer .controls.controls-dark .progress .progress-bar {
background-color: #999;
}
.videoplayer .controls.auto-hide {
opacity: 0;
transition: opacity 0.5s ease-in-out;
transition-delay: 0.5s;
}
.videoplayer .controls button > *,
.videoplayer .controls .btn > * {
pointer-events: none !important;
}
.videoplayer .overlay {
position: absolute;
z-index: 300;
top: 0;
left: 0;
}
.videoplayer .overlay .title {
font-size: inherit;
color: white;
padding: 0.5rem;
font-weight: bold;
}
.videoplayer .dropup-volume {
position: absolute !important;
bottom: calc(100% + 5px) !important;
padding: 0.75rem 1rem;
transform: none !important;
min-width: inherit;
}
.videoplayer .dropup-volume .form-range {
-webkit-appearance: slider-vertical;
width: 1rem !important;
height: 100% !important;
}
.videoplayer:hover .controls.auto-hide {
opacity: 1;
}
.tooltip {
z-index: 1400;
}
Using the build in Bootstrap Color Schemes
Move your mouse over the video to see controls..
class="controls auto-hide"
Use the integrted Bootstrap aspect ratio classes