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:
- Display Current Track Information: Show the title and artist of the currently playing track.
- Play/Pause Functionality: A button to toggle playback (play if paused, pause if playing).
- 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).
- 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.
- Current Time & Duration Display: Show the elapsed time and total duration of the current track, updating as playback progresses.
- 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.