0

I'm trying to create a cross-browser way to change the audio track of an HTML5 video that plays in my web-app. I know that audioTracks video property is not supported in all browsers so I've been digging into an alternate way to do it. I came across this stack overflow question that lead me to the AudioContext class in Javascript. I was able to get the default audio (the audio that is embedded in the video) to play through the AudioContext but I'm at a loss for how to programmatically map a new sound through the same AudioContext instance that is connected to the HTML5 element.

Is it at all possible to change the audio from an HTML5 video element to another audio track that is external (mp3,wav, acc, etc...)?

the basic premise is for an end-user to be able to change the video's audio to a different language.

zero
  • 2,999
  • 9
  • 42
  • 67
  • [audioTracks](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/audioTracks) is a readonly property. You can use to switch audio tracks _if_ they already exist within the video. Afaik you can't change audio tracks using a different audio source with pure client side code. Perhaps it'll be possible using 2 players, 1 with muted video and an invisible one with pure audio. But getting them to sync will be challenging. Otherwise you'll probably have to rely on server side code to edit the actual video first. – icecub May 15 '20 at 13:39
  • The solution I proposed can be found in the answer here btw: https://stackoverflow.com/questions/32313584/loading-a-mute-video-with-a-separate-audio-into-a-html5-video-tag – icecub May 15 '20 at 13:45

0 Answers0