This public link is valid for 7 days and shares a thread, including any personal information you added. This link or copies made by others cannot be deleted. If you share with third parties, their policies apply. Can’t copy the link right now. Try again later.

Use ://youtube-nocookie.com in your API calls for better user privacy. Provide a dark mode CSS theme for the controls?

Raw video time is in seconds. For a YouTube-like display (MM:SS), we require a formatting function.

// update buffer progress function updateBufferProgress() if (!video.buffered.length) return; const duration = video.duration; if (!duration

// Close dropdowns when clicking elsewhere window.addEventListener('click', () => document.querySelectorAll('.dropdown-menu').forEach(menu => menu.style.display = 'none'); );

To get started, create a new Pen on CodePen. You do not need to install any external libraries like jQuery, as modern vanilla JavaScript handles this efficiently.

You'll also need to include the YouTube API script in your HTML. This script loads the API and makes the YT object available globally. CodePen allows you to easily add external scripts.

function updateTimeDisplay() timeDisplay.textContent = `$formatTime(video.currentTime) / $formatTime(video.duration `;

<!-- Center group: seek bar + time --> <div class="controls-center"> <div class="progress-bar-container" id="progressContainer"> <div class="progress-bg"> <div class="progress-fill" id="progressFill"></div> </div> </div> <div class="time-text"> <span id="currentTimeDisplay">0:00</span> / <span id="durationDisplay">0:00</span> </div> </div>

The HTML requires a container to house the player, a hidden div where the YouTube API will inject the video, and a custom controls overlay.