Frontend School

Interactive Audio Player with Visual Waveform

Machine Coding
hard

Interactive Audio Player with Visual Waveform

Hard
React
TypeScript
Audio
Web Audio API
Canvas
UI/UX
State Management

Overview

Audio experiences are central to many modern applications, from healthcare analytics to media platforms. For Innovaccer, building robust and intuitive user interfaces that handle complex data, like audio, is crucial. This problem challenges you to develop an interactive audio player component with a visual waveform representation, simulating a common feature in medical transcription review or data annotation tools.

What you need to do / Task

Your task is to build a React component that functions as a fully interactive audio player.

  1. Core Playback Controls: Implement play/pause functionality.
  2. Seek/Scrub Functionality: Allow users to click or drag on a progress bar/waveform to seek to a specific point in the audio.
  3. Time Display: Display the current playback time and total duration of the audio in MM:SS format.
  4. Volume Control: Implement a slider to adjust the audio volume.
  5. Waveform Visualization:
    • Render a simplified, static waveform visualization of the audio on a <canvas> element. You will be provided with mock waveform data (an array of numbers representing amplitude peaks).
    • The waveform should visually indicate the current playback position.
    • When seeking, the waveform's playback indicator should update instantly.

UI/UX expectations

  • The audio player should have a clear, functional layout.
  • Controls (play/pause, volume slider) should be easily accessible.
  • The waveform visualization should be prominent and interactive for seeking.
  • Ensure a responsive and smooth user experience for playback and seeking.
  • Consider basic accessibility for interactive elements (e.g., button states).

Acceptance criteria

  • Clicking a play/pause button toggles audio playback.
  • The current time and total duration update accurately during playback.
  • Dragging or clicking on the waveform/progress bar seeks the audio to the selected position.
  • The volume slider correctly adjusts the audio output level.
  • A static waveform is rendered on a canvas element using the provided mock data.
  • A visual indicator (e.g., a vertical line) on the waveform accurately reflects the current playback position and updates on seek/play.

Constraints

Constraints & assumptions

  • You are working in a modern browser environment (Chrome, Firefox, Edge).
  • The audio file will be provided via a URL. Assume it's a standard format (e.g., MP3, WAV).
  • Mock waveform data (an array of numbers) will be provided in App.tsx to simplify the waveform rendering. You do not need to parse actual audio data to generate this.
  • Focus on functional implementation; basic styling is sufficient for clarity.
  • The solution should be implemented using React and TypeScript.

Out of scope

  • Dynamic waveform generation from raw audio data (e.g., using Web Audio API's AnalyserNode).
  • Playlist management or multiple audio tracks.
  • Advanced audio effects or equalization.
  • Backend integration or fetching audio metadata.

What interviewers evaluate

  • Correctness and Robustness: Does the player function as expected across all controls and interactions?
  • Code Structure and Readability: Is the code well-organized, modular, and easy to understand, adhering to React best practices?
  • State Management: Is application state managed effectively and efficiently?
  • UI/UX Implementation: Is the user interface intuitive, responsive, and does it meet the specified visual and interactive requirements?
  • Problem-Solving Approach: How effectively were the specific challenges, especially the waveform visualization, addressed?

Loading editor...