Frontend School

Custom HTML5 Video Player Controls

Machine Coding
medium

Custom HTML5 Video Player Controls

Medium
Frontend
React
Video
UI/UX
Machine Coding

Overview

Modern web applications often require more than just basic video playback. Custom video player controls enable unique branding, enhanced accessibility features, and tailored user experiences that standard browser controls might not offer. In this problem, you will build a set of essential custom controls for an HTML5 video element, focusing on core playback functionality and user interaction.

What you need to do / Task

Your task is to implement a custom control bar for a given HTML5 video element. You must provide the following functionalities:

  1. Play/Pause Toggle: A button that allows users to start and stop video playback.
  2. Progress Bar: A visual indicator that displays the current playback position and allows users to seek to different parts of the video by dragging or clicking.
  3. Time Display: Show the current playback time and the total duration of the video (e.g., 0:30 / 2:15).
  4. Volume Control: A slider to adjust the video's volume.
  5. Mute/Unmute Toggle: A button to quickly mute and unmute the video.

UI/UX expectations

  • The custom controls should be clearly visible and interactable, positioned below or overlaid on the video element.
  • The Play/Pause button should visually reflect the current playback state (e.g., changing from a 'Play' icon to a 'Pause' icon).
  • The progress bar should update smoothly as the video plays and allow for intuitive seeking.
  • The time display should be formatted for readability.
  • The volume control should accurately reflect and change the video's audio level, with the mute button toggling the sound without affecting the volume slider's position (when unmuted, volume should return to its previous state).

Acceptance criteria

  • Video plays when the 'Play' button is clicked and pauses when the 'Pause' button is clicked.
  • The Play/Pause button icon accurately reflects the current playback state.
  • The progress bar updates in real-time as the video plays.
  • Clicking or dragging the progress bar seeks the video to the corresponding position.
  • The current time and total duration are displayed and updated correctly.
  • The volume slider adjusts the video's audio level between 0% and 100%.
  • Clicking the mute button toggles the video's muted state.
  • When unmuted, the volume returns to its previous level before muting (if applicable).

Constraints

Constraints & assumptions

  • You must use a standard HTML5 <video> element.
  • You are required to use React for building the component.
  • Focus on the core functionality; no need to implement advanced features like fullscreen mode, picture-in-picture, or playback speed controls.
  • Assume a single video source will be provided.
  • The video element's API (HTMLMediaElement) should be used to control playback, volume, and track progress.

Out of scope

  • Implementing full-screen functionality.
  • Adding keyboard shortcuts for controls.
  • Handling multiple video sources or playlists.
  • Complex error handling for video loading.
  • Styling beyond basic layout and control visibility.

What interviewers evaluate

  • Correct and idiomatic use of the HTMLMediaElement API within a React component.
  • Clean component design and effective state management using React hooks.
  • Responsive and intuitive UI/UX for video controls.
  • Attention to detail in handling video events and user interactions.

Loading editor...