Design a Video Player (YouTube / Netflix)
Problem statement
Design a full-featured video player with HLS adaptive bitrate streaming, custom controls, seek bar with buffered range, picture-in-picture, autoplay queue, and keyboard shortcuts.
Asked In
Key Challenges
- ·Adaptive Bitrate Streaming (ABR): Switching quality (360p to 4K) seamlessly based on bandwidth
- ·Custom Control Orchestration: Building a performant, accessible UI on top of native <video> elements
- ·Buffering Strategy: Balancing memory footprint with 'Instant Start' UX (Buffer-ahead logic)
- ·MSE & EME Integration: Using Media Source Extensions for streaming and Encrypted Media Extensions for DRM
- ·Observability (QoE): Tracking rebuffering ratios, startup latency, and bitrate drops at scale
- ·Ad Injection: Seamlessly handling VAST/VMAP ad breaks without breaking playback state
- ·Picture-in-Picture (PiP) and Fullscreen: Managing cross-browser API inconsistencies and focus trapping
2-Minute Answer — High-Level TL;DR
Read this before your interview
HLD Interview Focus
I would split the player into an engine and chrome. The engine owns media element, buffer health, and quality switches; the chrome owns controls, captions, and settings and only reads engine state. Startup shows a poster and skeleton until canplay; rebuffers surface explicitly with retry. ABR changes quality without remounting the media element. Mobile autoplay may be denied — start muted or wait for gesture. Keyboard (Space/arrows), fullscreen, and caption tracks are part of the contract. Telemetry tracks startup time and rebuffer ratio. The hard parts are buffer state machines and accessible controls — not the play icon.
My Approach: Building the Solution
How to think about this problem
I'll start from a rebuffer on a train Wi-Fi — what the user should see — then design engine vs chrome, ABR boundaries, and control a11y.
Why This Approach?
Most candidates wrap <video src> and style a play button. That answer collapses on rebuffers, autoplay rejection, and caption tracks. Strong answers split a media engine from chrome UI and treat buffering, errors, ABR, and accessibility as peer concerns to the scrubber.
The engine is the projector; the chrome is the theater remote. Guests should never need to open the projector cabinet to pause the film.
Requirements: What Makes a Great Solution?
Clarify scope before designing anything
Requirements Exploration Questions
Ask your interviewer these questions to refine requirements
What is the primary streaming format?
- ·HLS (Apple standard, widespread support)
- ·DASH (Standard-agnostic, better for Android/Web)
- ·DRM requirements (Widevine, FairPlay, PlayReady)
What are the interaction goals?
- ·Keyboard shortcuts (J/K/L, Space, M)
- ·Preview thumbnails on seek (VTT sprite maps)
- ·Picture-in-Picture and Multi-audio tracks
- ·Chromecast / AirPlay support
What are the business constraints?
- ·Monetization (VAST/VMAP ad integration)
- ·Analytics (QoE tracking, heartbeat signals)
- ·Offline playback (Service Worker / Cache API)
Functional Requirements
Must Have — MVP
- ✓Custom Play/Pause/Volume controls
- ✓Seek bar with buffered vs played indicators
- ✓Quality selector (Auto/1080p/720p)
- ✓Adaptive Bitrate (ABR) engine
- ✓Subtitles/Captions toggle
- ✓Full-screen mode support
Advanced (If Time Permits)
- +Preview thumbnails on scrub
- +Playback speed control (0.5x - 2x)
- +Audio track switching (Multi-language)
- +PiP (Picture-in-Picture) API integration
- +Ad-break markers and countdowns
- +Keyboard shortcut manager
Non-Functional Requirements
Performance
- ·Startup Latency (VTT) < 1.5s
- ·Rebuffer Ratio < 0.5% (Total time stalled)
- ·Bitrate Efficiency (Optimal quality for bandwidth)
- ·Minimal CPU usage (GPU decoding priority)
Reliability
- ·Graceful fallback on segment fetch failure
- ·State recovery on network reconnect
- ·Consistent playback across Safari, Chrome, and Firefox
Accessibility
- ·WCAG 2.1 AA slider controls (aria-valuenow)
- ·Screen reader announcements for state changes
- ·High-contrast UI and scalable captions
The full solution is part of HelloFrontend Pro
The question above is free to read in full. Upgrade to unlock the interactive workspace and the senior-level walkthrough that go with it.
- Full RADIO-framework walkthrough with architecture diagrams
- Data model, API design, and rendering strategy trade-offs
- Performance, accessibility, and offline sections plus a model answer
Already a member? Log in to open the workspace.