simplevideoplayer icon indicating copy to clipboard operation
simplevideoplayer copied to clipboard

Add audio track switching for videos with multiple audio streams

Open Copilot opened this issue 7 months ago • 5 comments

This PR implements audio track switching functionality for videos that contain multiple audio streams, allowing users to switch between different languages, commentary tracks, or audio mixes.

  • [x] Initial project setup and build issue fixes
  • [x] Implement AudioTrackSelector component with HTML5 audioTracks API
  • [x] Add smart detection for multiple audio tracks
  • [x] Integrate with existing video controls UI
  • [x] Add comprehensive documentation in AUDIO_TRACKS.md
  • [x] Enhanced UX with better browser compatibility handling
  • [x] Merge master branch to include copilot-instructions.md

What was implemented

AudioTrackSelector Component: A new React component that automatically detects and manages multiple audio tracks in video files. The component uses the HTML5 audioTracks API when available and provides graceful fallbacks for unsupported browsers.

Smart Detection: The component only appears when:

  • The browser supports the audioTracks API
  • The loaded video file contains multiple audio tracks
  • The tracks are properly detected and accessible

User Experience: The audio track selector appears as a music note icon in the video controls, positioned between the volume slider and fullscreen button. When clicked, it shows a dropdown with available audio tracks, displaying track labels and languages when available.

Browser Compatibility Handling

Since the audioTracks API has limited browser support, the implementation includes robust fallback behavior:

  • Supported browsers with multiple tracks: Shows active selector with functional dropdown
  • Supported browsers with single track: Shows disabled button with explanatory tooltip
  • Unsupported browsers: Shows disabled button that explains the limitation when clicked

The component logs helpful debug information to the console, making it clear to users what audio tracks are detected and why the selector may or may not be available.

Technical Details

  • Uses TypeScript interfaces for proper type safety with the audioTracks API
  • Integrates seamlessly with existing video controls styling
  • Provides console logging for debugging and user education
  • Includes comprehensive documentation in AUDIO_TRACKS.md

Visual Integration

The feature integrates cleanly into the existing video player interface without disrupting the current user experience.

Fixes #56.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Sep 09 '25 16:09 Copilot