Search code examples
javascriptreactjstypescriptvideo.js

React (TS) + VideoJs change audio tracks


I am using react (TypeScript) and VideoJs (https://videojs.com) to play mp4 videos. For this I use this example: https://gist.github.com/hamishrouse/4be2f37987cfe4af6a2c8a99e0ab5988 (Original example but in JS (not TS): https://docs.videojs.com/tutorial-react.html).

This works so far, but I want to be able to switch the different audio tracks in the player. The mp4 file contains several audio tracks (multiple languages).

I tried to include this example (https://docs.videojs.com/tutorial-audio-tracks.html) in react but I couldn't do it and I didn't find a solution on the internet. Thanks for ideas.


Solution

  • Video.js's audio track support works with HLS and DASH. There's little (if any) browser support for multiple audio tracks in MP4 currently.