Overview
Shiprocket is expanding its internal dashboard capabilities to include multimedia content. One critical feature is an audio player for listening to pre-recorded messages, such as customer service call recordings or internal team announcements. This problem focuses on building a simple, functional audio player component that can display a list of tracks and allow users to select and play them with basic controls. An intuitive and efficient internal tool is crucial for our daily operations.
What you need to do / Task
Your task is to create a React component that implements a basic audio player.
- Display Track List: Render a list of provided mock audio tracks.
- Track Selection: Each track in the list should be clickable. Clicking a track should make it the currently selected track, ready for playback.
- Play/Pause Control: Implement a single button to toggle between 'Play' and 'Pause' functionality for the currently selected track.
- Audio Playback: When a track is selected and the 'Play' button is clicked, the audio should start playing. Clicking 'Pause' should stop the audio.
- Visual Feedback: The player must visually indicate:
- Which track is currently selected.
- Whether the player is in a 'playing' or 'paused' state.
UI/UX expectations
- Layout: The component should have two main sections:
- A list of available audio tracks.
- A control area displaying the title of the currently selected track and the Play/Pause button.
- Interactions:
- Clicking on a track name in the list should select it and update the control area.
- The Play/Pause button text should change based on the current playback state.
- The currently playing track in the list should have a distinct visual style (e.g., different background color, bold text, or a small icon).
- Accessibility: Use semantic HTML elements for lists, buttons, and audio controls where appropriate.
Acceptance criteria
- The component successfully displays the mock list of audio tracks.
- Clicking on any track in the list correctly updates the currently selected track in the control area.
- The 'Play' button initiates audio playback for the selected track.
- The 'Pause' button stops audio playback for the current track.
- The UI accurately reflects the current playback state (playing/paused) and the selected track.
- Only one track can be actively playing at any given time. Selecting a new track while another is playing should stop the previous one and prepare the new one for playback.