Frontend School

Custom HTML5 Video Player Controls

Machine Coding
medium

Custom HTML5 Video Player Controls

Medium
UI
React
TypeScript
Video
Controls
HTML5

Overview

At Stripe, rich media like video demonstrations are crucial for product showcases, user education, and internal training. A seamless and intuitive video playback experience is essential for engaging our users and employees. This problem focuses on building a custom, accessible set of controls for an HTML5 video element, allowing for a tailored user experience that goes beyond browser defaults.

What you need to do / Task

Your primary task is to create a custom video player UI that allows users to interact with an HTML5 <video> element. You will implement the following core functionalities:

  1. Video Rendering: Display a standard HTML5 <video> element with a provided source.
  2. Play/Pause Toggle: Implement a button that toggles the video's playback state (play/pause).
  3. Time Display: Show the current playback time and the total duration of the video, formatted clearly (e.g., 0:00 / 2:30). These values should update dynamically during playback.
  4. Seek Bar (Progress Slider): Create a slider input that visually represents the video's current progress and allows the user to click or drag to seek to a different position in the video.
  5. Volume Control: Implement a slider input to control the video's volume level.
  6. Full-Screen Toggle: Add a button to toggle the video element into and out of full-screen mode.

UI/UX expectations

The video player should present a clean and functional interface.

  • The video element should be clearly visible.
  • Controls (play/pause, time, seek bar, volume, fullscreen) should be grouped logically below the video.
  • The seek bar should provide clear visual feedback as the video plays and when the user interacts with it.
  • Volume slider should intuitively adjust the sound output.
  • All interactive elements (buttons, sliders) should be clearly distinguishable and respond to user input.
  • Accessibility: Ensure basic keyboard accessibility for the primary controls (e.g., Space key to toggle play/pause, arrow keys for seeking/volume adjustment if time permits).

Acceptance criteria

Your solution will be evaluated based on the following observable behaviors:

  • Clicking the play/pause button accurately toggles the video's playback state.
  • The current time and total duration display updates smoothly and correctly during playback.
  • The seek bar visually reflects the video's progress and allows users to scrub to any point in the video.
  • The volume slider correctly controls the video's audio level.
  • Clicking the full-screen button toggles the video element into and out of browser full-screen mode.
  • Primary controls (e.g., play/pause) are operable using keyboard input.

Constraints

Constraints & assumptions

  • You should use React and TypeScript for this problem.
  • Assume a modern browser environment with full HTML5 video API support.
  • The video source URL will be provided in the starter code. You do not need to handle dynamic video loading or multiple video sources.
  • Focus on the core UI and JavaScript API interactions; complex CSS animations or highly polished visual designs are not the primary focus, but basic styling for usability is expected.
  • No backend services or API calls are required. All data is client-side.

Out of scope

  • Implementing custom playback speed controls.
  • Adding subtitle/caption track toggles.
  • Picture-in-picture functionality.
  • Advanced error handling for video loading failures beyond basic UI feedback.
  • Complex layout responsiveness for various screen sizes (a single desktop-like layout is sufficient).

What interviewers evaluate

  • Correctness & Functionality: Do all implemented video controls work as expected and interact correctly with the HTML5 video API?
  • Code Structure & Readability: Is the code logically organized, modular, and easy to understand? Are appropriate React hooks and patterns used?
  • State Management: Is the video player's state (e.g., playing status, current time, volume) managed efficiently and effectively using React's mechanisms?
  • UI/UX Implementation: Is the user interface intuitive and responsive to user input? Does it meet basic accessibility expectations?

Loading editor...