Frontend School

Interactive Audio Player with Playlist

Machine Coding
medium

Interactive Audio Player with Playlist

Medium
React
TypeScript
UI
State Management
Audio

Overview

At Uber, we are constantly looking for ways to enhance the user experience across our diverse services. Imagine a scenario where a user is waiting for their Uber Eats order or enjoying a ride, and they want to listen to music or a podcast seamlessly within the app. This problem focuses on building a core component for such a feature: a simple, interactive audio player that manages a playlist and provides essential controls.

This exercise evaluates your ability to build a functional UI component, manage complex state, and handle user interactions effectively, mirroring the kind of frontend challenges faced when building rich interactive features at Uber.

What you need to do / Task

Your task is to implement a React component for an audio player. The player should manage a playlist of tracks and provide the following functionalities:

  1. Display Current Track Information: Show the title and artist of the currently playing track.
  2. Play/Pause Functionality: A button to toggle playback (play if paused, pause if playing).
  3. Next/Previous Track Navigation: Buttons to switch to the next or previous track in the playlist. The playlist should loop (e.g., next after the last track goes to the first, previous before the first goes to the last).
  4. Playback Progress Bar: A visual progress bar that updates in real-time as the 'audio' plays. This bar should also be interactive, allowing users to click or drag to 'seek' to a different point in the track.
  5. Current Time & Duration Display: Show the elapsed time and total duration of the current track, updating as playback progresses.
  6. Volume Control: A slider to adjust the 'volume'.

UI/UX expectations

  • The player should have a clear, functional layout. No need for elaborate styling, but elements should be well-arranged and distinguishable.
  • Track information (title, artist) should be prominent.
  • Control buttons (Play/Pause, Next, Previous) should be easily identifiable and clickable.
  • The progress bar should visually represent the playback position and be interactive for seeking.
  • The volume slider should allow for intuitive adjustment.
  • Basic responsiveness is a plus, but focus on functionality for a desktop-like view.

Acceptance criteria

  • The player component renders successfully with initial track information.
  • Clicking 'Play' starts playback simulation, and 'Pause' stops it.
  • 'Next' and 'Previous' buttons correctly navigate through the mock playlist, wrapping around at the ends.
  • The progress bar visually updates during playback.
  • Clicking/dragging on the progress bar updates the 'current time' and the bar's position.
  • Current time and total duration are displayed and updated correctly.
  • The volume slider adjusts the simulated volume state.

Constraints

Constraints & assumptions

  • You should use React and TypeScript for this problem.
  • No external audio libraries or complex browser APIs (like Web Audio API) are required. Simulate audio playback, current time updates, and duration using simple setTimeout/setInterval or similar mechanisms. Focus on state management and UI updates.
  • A mock playlist will be provided; assume valid track data.
  • The problem focuses on frontend development; no backend integration is needed.
  • Target a modern web browser environment.

Out of scope

  • Actual audio file loading and playback via <audio> tag events. Focus on simulating the state changes.
  • Persistent storage of playback state (e.g., local storage).
  • Advanced UI animations or complex design systems.
  • Extensive error handling for malformed track data or network issues.
  • Keyboard navigation or advanced accessibility features beyond basic interactive elements.

What interviewers evaluate

  • Component Structure & State Management: How well the player's state (playing status, current track, time, volume) is managed and organized within React components.
  • User Interaction Handling: Effectiveness in implementing handlers for play/pause, next/previous, seeking, and volume control.
  • UI Updates & Data Display: Accuracy and responsiveness of the UI in reflecting playback state, progress, and track information.
  • Code Quality: Readability, maintainability, and adherence to React/TypeScript best practices.
  • Problem Solving: Ability to break down the problem and implement core features efficiently within the time limit.

Loading editor...