A Pen by K K UPGRADER on CodePen.
Created
August 18, 2022 02:18
-
-
Save HeNy007/c690e519ca0e066399a896548823cbb8 to your computer and use it in GitHub Desktop.
Custom Controls with Plyr.io Video Player
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<video | |
controls | |
crossorigin | |
playsinline | |
data-poster="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg" class="js-player"> | |
<!-- Video files --> | |
<source | |
src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4" | |
type="video/mp4" | |
size="576" | |
/> | |
<source | |
src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4" | |
type="video/mp4" | |
size="720" | |
/> | |
<source | |
src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1080p.mp4" | |
type="video/mp4" | |
size="1080" | |
/> | |
</video> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('DOMContentLoaded', () => { | |
// Controls (as seen below) works in such a way that as soon as you explicitly define (add) one control | |
// to the settings, ALL default controls are removed and you have to add them back in by defining those below. | |
// For example, let's say you just simply wanted to add 'restart' to the control bar in addition to the default. | |
// Once you specify *just* the 'restart' property below, ALL of the controls (progress bar, play, speed, etc) will be removed, | |
// meaning that you MUST specify 'play', 'progress', 'speed' and the other default controls to see them again. | |
const controls = [ | |
'play-large', // The large play button in the center | |
'restart', // Restart playback | |
'rewind', // Rewind by the seek time (default 10 seconds) | |
'play', // Play/pause playback | |
'fast-forward', // Fast forward by the seek time (default 10 seconds) | |
'progress', // The progress bar and scrubber for playback and buffering | |
'current-time', // The current time of playback | |
'duration', // The full duration of the media | |
'mute', // Toggle mute | |
'volume', // Volume control | |
'captions', // Toggle captions | |
'settings', // Settings menu | |
'pip', // Picture-in-picture (currently Safari only) | |
'airplay', // Airplay (currently Safari only) | |
'download', // Show a download button with a link to either the current source or a custom URL you specify in your options | |
'fullscreen' // Toggle fullscreen | |
]; | |
const player = Plyr.setup('.js-player', { controls }); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdn.plyr.io/3.5.6/plyr.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://cdn.plyr.io/3.5.6/plyr.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment