Frontend School

Interactive Video Player Controls

Machine Coding
medium

Interactive Video Player Controls

Medium
Frontend
React
UI
Video
Controls
Accessibility

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.

  1. Play/Pause Button: A button that toggles the video's playback state (play/pause).
  2. Mute/Unmute Button: A button that toggles the video's audio mute state.
  3. Progress Bar: A seekable progress bar that visually represents the current playback position and allows users to jump to any point in the video.
  4. 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).
  5. 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.

Constraints

Constraints & assumptions

  • You will be provided with a basic React setup and an HTML <video> element. Your focus is on building the custom control component.
  • Assume a single video source. You do not need to handle dynamic source changes or multiple video tracks.
  • You should use the standard HTMLMediaElement API for video interaction (e.g., play(), pause(), muted, currentTime, duration).
  • The styling for basic layout is minimal; focus on functionality and user interaction.
  • Target time budget: ~45 minutes.

Out of scope

  • Volume slider (beyond simple mute/unmute).
  • Fullscreen mode button.
  • Playback speed controls.
  • Caption/subtitle toggles.
  • Error handling for video loading failures.
  • Complex UI animations or custom icon libraries (simple text or basic SVG/unicode icons are fine).

What interviewers evaluate

  • Correctness and Robustness: Does the code accurately control video playback and audio, and handle state changes reliably?
  • Component Design: Is the solution modular, maintainable, and does it effectively utilize React's features (hooks, props)?
  • DOM Interaction: Is the HTMLMediaElement API used correctly and efficiently?
  • User Experience & Accessibility: Are the controls intuitive, and do they meet the specified accessibility requirements?
  • Code Quality: Is the code clean, readable, and well-structured, reflecting best practices for a production environment?

Loading editor...