Frontend School

Shiprocket Internal Audio Player

Machine Coding
easy

Shiprocket Internal Audio Player

Easy
React
Frontend
UI
Machine Coding
Audio

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.

  1. Display Track List: Render a list of provided mock audio tracks.
  2. Track Selection: Each track in the list should be clickable. Clicking a track should make it the currently selected track, ready for playback.
  3. Play/Pause Control: Implement a single button to toggle between 'Play' and 'Pause' functionality for the currently selected track.
  4. Audio Playback: When a track is selected and the 'Play' button is clicked, the audio should start playing. Clicking 'Pause' should stop the audio.
  5. 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.

Constraints

Constraints & assumptions

  • You must use React for building the UI.
  • Utilize the native HTML <audio> element for audio playback. No external audio libraries are required.
  • Assume a fixed array of audio track data (title, URL) as provided in the starter code.
  • Focus on functional correctness and a clean, maintainable component structure.
  • The expected time to complete this problem is approximately 45 minutes.
  • The solution should run in a standard browser environment.

Out of scope

  • Volume control, seeking/progress bar, or track duration display.
  • Playlist management features like shuffling, repeating, or queuing.
  • Robust error handling for invalid audio URLs or network issues.
  • Complex styling, animations, or advanced responsiveness (basic functional styling is sufficient).
  • Backend integration or fetching track data from an API.

What interviewers evaluate

  • Correct implementation of audio playback logic using React state and effects.
  • Clean component structure, effective state management, and appropriate use of React hooks (useState, useEffect, useRef).
  • Adherence to basic UI/UX expectations, providing clear visual feedback.
  • Efficiency and readability of the code.

Loading editor...