CodexBloom - Programming Q&A Platform

Issues displaying custom HTML5 Video Controls in Safari 16

πŸ‘€ Views: 0 πŸ’¬ Answers: 1 πŸ“… Created: 2025-07-27
html video safari HTML

I'm relatively new to this, so bear with me. I'm working on a project and hit a roadblock. I'm currently developing a video player using the HTML5 `<video>` element and I've implemented custom controls using JavaScript and CSS. It works perfectly in Chrome and Firefox, but I'm working with issues in Safari (version 16). The custom controls are not displaying correctly, and the play button is unresponsive. Here's the code I'm using for the video element and the associated controls: ```html <video id="myVideo" width="640" height="360" controls> <source src="movie.mp4" type="video/mp4"> Your browser does not support the video tag. </video> <div class="custom-controls"> <button id="playBtn">Play</button> <button id="pauseBtn">Pause</button> </div> ``` And the JavaScript: ```javascript const video = document.getElementById('myVideo'); const playBtn = document.getElementById('playBtn'); const pauseBtn = document.getElementById('pauseBtn'); playBtn.addEventListener('click', () => { video.play(); }); pauseBtn.addEventListener('click', () => { video.pause(); }); ``` I've tried inspecting the console for errors, but there are no relevant behavior messages. The play button doesn’t trigger the play action in Safari, and it seems like the event listeners are not being attached properly. I've also tested this without other scripts running, and it still doesn't work. Is there a known scenario with custom controls and the `<video>` element in Safari? What am I missing, or is there a different approach I should take to ensure compatibility? Any help would be greatly appreciated! My development environment is macOS. How would you solve this? What would be the recommended way to handle this?