Custom Audio Player with YouTube API
How do I make an custom audio player with youtube api?
What is a custom audio player with youtube api? How do you make a custom audio player with youtube api? This script and codes were developed by Emerson Thompson on 11 August 2022, Thursday.
Custom Audio Player with YouTube API - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Custom Audio Player with YouTube API</title> <link rel='stylesheet prefetch' href='http://netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container"> <div class="display hidden"> <iframe id="video" src="//www.youtube.com/embed/LdQjndOvNn4?controls=0&showinfo=0&rel=0&enablejsapi=1&html5=1" frameborder="0" allowfullscreen="allowfullscreen"></iframe> </div> <footer class="footer"><img class="thumb" src="http://img.youtube.com/vi/LdQjndOvNn4/mqdefault.jpg"/> <div class="bar"> <div id="progressBar"> <div></div> </div> </div> <div class="controls"> <button class="icon-fast-backward"></button> <button class="icon-play" id="play"></button> <button class="icon-pause" id="pause"></button> <button class="icon-fast-forward"></button> </div> </footer>
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Custom Audio Player with YouTube API - Script Codes CSS Codes
* { margin: 0; padding: 0; outline: none; box-sizing: border-box;
}
html,
body { width: 100%; height: 100%;
}
body { padding-top: 20%; background-image: -webkit-linear-gradient(54deg, #c05a9c, #223971); background-image: linear-gradient(36deg, #c05a9c, #223971);
}
.container { width: 400px; margin: 0 auto; box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.5); line-height: 0;
}
.display { position: relative; height: 0; width: 100%; padding-bottom: 50%; padding-top: 25px; overflow: hidden;
}
.display iframe { position: absolute; top: 0; left: 0; width: 100%; max-width: 100%; height: 100%;
}
.display.hidden { padding: 0;
}
.footer { position: relative; background: #FFF;
}
.footer .thumb { position: absolute; top: 50%; left: 15px; width: 140px; -webkit-transform: translateY(-50%); transform: translateY(-50%);
}
.footer .bar { background-color: #ddd; width: 100%; padding: 0 5px 0 160px;
}
.footer #progressBar { height: 6px; overflow: hidden;
}
.footer #progressBar div { margin-top: 2px; height: 2px; width: 0; background-color: #2c3e50;
}
.footer .controls { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: end; -ms-flex-pack: end; justify-content: flex-end;
}
.footer .controls button { display: block; width: 50px; height: 50px; font-size: 15px; color: #bbb; background: transparent; border: none; cursor: pointer;
}
.footer .controls button:first-child { border-right: 1px solid #EEE;
}
.footer .controls button:last-child { border-left: 1px solid #EEE;
}
Custom Audio Player with YouTube API - Script Codes JS Codes
var player;
function onYouTubePlayerAPIReady() { player = new YT.Player('video', { events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } });
}
function onPlayerReady(event) { var playButton = document.getElementById("play"), pauseButton = document.getElementById("pause"); playButton.addEventListener("click", function() { player.playVideo(); }); pauseButton.addEventListener("click", function() { player.pauseVideo(); });
}
function progress(percent, $element) { var progressBarWidth = percent * $element.width() / 100; $element.find('div').animate({ width: progressBarWidth });
}
function onPlayerStateChange(event) { if (event.data == YT.PlayerState.PLAYING) { var playerTotalTime = player.getDuration(); var mytimer = setInterval(function() { var playerCurrentTime = player.getCurrentTime(); var playerTimeDifference = (playerCurrentTime / playerTotalTime) * 100; console.log(playerCurrentTime); progress(playerTimeDifference, $('#progressBar')); }, 1000); } else { clearTimeout(mytimer); }
}
var tag = document.createElement('script');
tag.src = "//www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
Developer | Emerson Thompson |
Username | thompsonemerson |
Uploaded | August 11, 2022 |
Rating | 3 |
Size | 4,077 Kb |
Views | 64,768 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Minimalist Email - Flex Box | 3,540 Kb |
CardMove | 3,699 Kb |
Filtro de palavras com JavaScript | 2,400 Kb |
Hashtag Instagram - AngularJS | 2,027 Kb |
Hello World - Angular 2 | 2,964 Kb |
Spider-man with Box-shadow CSS | 4,228 Kb |
Brazil Map SVG | 21,910 Kb |
Reactions Facebook | 2,812 Kb |
Milligram - Logo Animation SVG | 2,955 Kb |
UI Elements - Flat Design | 3,994 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Classy Blockquote Styling | Andrewwright | 3,212 Kb |
Addthis_button | Esambino | 1,691 Kb |
Highbrow Basic HTML Lesson 8 | Kimlarocca | 2,094 Kb |
Another brick in the wall | Fivera | 1,955 Kb |
Expandable Left Side Bar with jQuery animate | Retrofuturistic | 2,483 Kb |
Isometric css island | Xaddict | 2,950 Kb |
Css3 slide | Nakome | 3,190 Kb |
About Mazano | Kiti | 2,585 Kb |
404 Page | Saransh | 2,666 Kb |
React TODO | Enieste | 3,320 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!