Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Creating the Iframe, this is the only place you'll need to edit if you want to simply use it as it, just add your ID where indicated.
- Be careful NOT to delete "&enablejsapi=1" as this will disable the player controls. -->
- <body>
- <iframe id="playlist" src="https://www.youtube.com/embed/videoseries?list=(YOUR URL ID GOES HERE!!!!!)&enablejsapi=1" frameborder="0"></iframe>
- <!--Making the buttons I used SVG images from https://www.svgrepo.com/ There's probably a more efficent way to insert SVGs but this is how I know to do it.
- If you want to change the icons find your desired SVG, open the image in notepad or other text editor and copy and paste the nessecery part into the svg bracket- only
- replace from "fill=" otherwise you will lose the button class and id-->
- <div class="buttons">
- <svg class=button id=BACKWARD fill="#333333" width="800px" height="800px" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
- <path d="M347.6 528.95l383.2 301.02c14.25 11.2 35.2 1.1 35.2-16.95V210.97c0-18.05-20.95-28.14-35.2-16.94L347.6 495.05a21.53 21.53 0 0 0 0 33.9M330 864h-64a8 8 0 0 1-8-8V168a8 8 0 0 1 8-8h64a8 8 0 0 1 8 8v688a8 8 0 0 1-8 8" />
- </svg>
- <svg class=button id="PLAY" fill="#333333" width="800px" height="800px" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon">
- <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm144.1 454.9L437.7 677.8a8.02 8.02 0 0 1-12.7-6.5V353.7a8 8 0 0 1 12.7-6.5L656.1 506a7.9 7.9 0 0 1 0 12.9z" />
- </svg>
- <svg class=button id=PAUSE fill="#333333" width="800px" height="800px" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon">
- <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-80 600c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V360c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v304zm224 0c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V360c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v304z" />
- </svg>
- <svg class=button id=FORWARD fill="#333333" width="800px" height="800px" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
- <path d="M676.4 528.95L293.2 829.97c-14.25 11.2-35.2 1.1-35.2-16.95V210.97c0-18.05 20.95-28.14 35.2-16.94l383.2 301.02a21.53 21.53 0 0 1 0 33.9M694 864h64a8 8 0 0 0 8-8V168a8 8 0 0 0-8-8h-64a8 8 0 0 0-8 8v688a8 8 0 0 0 8 8" />
- </svg>
- </div>
- <!-- Making the Volume slider. You shouldn't change anything here, if you want to change how it looks you'll do so in the CSS elements. -->
- <div class="slidecontainer" id=VOLUME>
- <input type="range" min="0" max="100" value="50" class="slider" id="myRange">
- </div>
- </body>
- <!-- CSS Styling. If you don't have experince in CSS but you'd still like to modify how things look I'd suggest using (https://webcode.tools/generators/css) as a refrence :) -->
- <style>
- /* Layout */
- body {
- display: flex;
- flex-flow: column wrap;
- align-content: space-around;
- justify-content: center;
- }
- /* Buttons, if you want to change the size opacity and hover properties it's done here.*/
- .button {
- width: 48px;
- height: 48px;
- opacity: 1;
- -webkit-transition: .5s;
- transition: opacity .5s;
- }
- }
- .button:hover {
- opacity: 0.5;
- }
- /* Video player, you shouldn't need to touch this since all it does is hide the player. */
- #playlist {
- display: none;
- }
- /* Volume slider, this is where you can change it's appearance. */
- .slider {
- -webkit-appearance: none;
- margin-left: 35px;
- appearence: none;
- border-radius: 20px;
- background-color: #333333;
- height: 5px;
- opacity: 1;
- -webkit-transition: .5s;
- transition: opacity .5s;
- }
- .slider:hover {
- opacity: 0.5;
- }
- .slider::-webkit-slider-thumb {
- -webkit-appearance: none;
- appearance: none;
- width: 25px;
- height: 25px;
- border: 10px double #333333;
- border-radius: 50%;
- background: #ffffff;
- }
- </style>
- <!-- JAVASCRIPT Unless you know what you're doing, don't touch this, it will break everything. -->
- <script>
- //Creating the player variable and onPlayerReady function
- var player;
- function onYouTubePlayerAPIReady() {
- player = new YT.Player("playlist", {
- events: {
- onReady: onPlayerReady
- }
- });
- }
- //Calling the onPlayerReadey function, everything involving interactions with the player should be containted in here in order to work.
- function onPlayerReady(event) {
- //Binding the Play button
- var playButton = document.getElementById("PLAY");
- playButton.addEventListener("click", function() {
- player.playVideo();
- });
- //Binding the Pause button
- var pauseButton = document.getElementById("PAUSE");
- pauseButton.addEventListener("click", function() {
- player.pauseVideo();
- });
- //Binding the Back button
- var backButton = document.getElementById("BACKWARD");
- backButton.addEventListener("click", function() {
- player.previousVideo();
- });
- //Binding the Next button
- var forwardButton = document.getElementById("FORWARD");
- forwardButton.addEventListener("click", function() {
- player.nextVideo();
- });
- //Binding the Volume Slider Slider, I formatted it diffrently since it's slightly more complicated than the buttons and requires and extra
- //variable. Also this is how I learnt to make sliders react and I can't be bothered changing the format to match with everything else, since
- //I might break something lol
- document.getElementById("myRange").addEventListener("change", function() {
- var volume = this.value;
- player.setVolume(volume);
- });
- }
- //API stuff
- var tag = document.createElement("script");
- tag.src = "//www.youtube.com/player_api";
- var firstScriptTag = document.getElementsByTagName("script")[0];
- firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement