Overview
Building intuitive and accessible media player controls is fundamental to any modern streaming or video-centric application. This problem focuses on creating a custom control overlay for a standard HTML <video> element, ensuring a seamless user experience and adherence to accessibility best practices. This is a common task in developing rich media experiences, and mastering it demonstrates a strong grasp of DOM manipulation, state management, and user interaction design.
What you need to do / Task
Your task is to implement a set of custom interactive controls for a given HTML <video> element. These controls should overlay the video and provide essential playback functionality.
- Play/Pause Button: A button that toggles the video's playback state (play/pause).
- Mute/Unmute Button: A button that toggles the video's audio mute state.
- Progress Bar: A seekable progress bar that visually represents the current playback position and allows users to jump to any point in the video.
- Time Display: Display the current playback time and the total duration of the video in a user-friendly format (e.g.,
MM:SS / MM:SS).
- Keyboard Accessibility: Ensure the primary controls (Play/Pause, Mute/Unmute, Progress Bar) are navigable and operable using the keyboard.
UI/UX expectations
- The controls should appear as an overlay at the bottom of the video player area.
- The Play/Pause button should clearly indicate its current state (e.g., 'Play' icon when paused, 'Pause' icon when playing).
- The Mute/Unmute button should clearly indicate its current state (e.g., 'Mute' icon when unmuted, 'Unmute' icon when muted).
- The progress bar should update smoothly during playback and allow users to click or drag to seek.
- Time displays should be formatted clearly (e.g.,
01:23 / 05:45).
- Users should be able to tab through the controls and activate buttons with
Enter/Space keys. The progress bar should allow seeking using arrow keys when focused.
Acceptance criteria
- The video plays when the Play button is clicked and pauses when the Pause button is clicked.
- The Play/Pause button icon/text toggles correctly with the video state.
- The video mutes when the Mute button is clicked and unmutes when the Unmute button is clicked.
- The Mute/Unmute button icon/text toggles correctly with the audio state.
- The progress bar accurately reflects the current video playback position.
- Dragging or clicking on the progress bar updates the video's playback position.
- The current time and total duration are displayed and updated correctly.
- The Play/Pause button is operable via the
Space key when focused.
- The Mute/Unmute button is operable via the
Space key when focused.
- The progress bar allows seeking using
Left/Right arrow keys when focused.