R
Reactiflux

✅ – BIOLOGY SCIENCE – 14-32 Oct 5

✅ – BIOLOGY SCIENCE – 14-32 Oct 5

RRelativPerspektiv10/5/2022
[Audio API] Audio doesn't play when I use createMediaElementSource on an audio element. (more info + code inside thread)
function start()
{
const audio = new Audio();

const
audioContext = new AudioContext(),
audioAnalyser = new AnalyserNode(audioContext);

audioContext.createMediaElementSource(audio).connect(audioAnalyser); // this line

audio.src = 'E:/Music/Fighter.mp3';

audio.play();
};

start();
function start()
{
const audio = new Audio();

const
audioContext = new AudioContext(),
audioAnalyser = new AnalyserNode(audioContext);

audioContext.createMediaElementSource(audio).connect(audioAnalyser); // this line

audio.src = 'E:/Music/Fighter.mp3';

audio.play();
};

start();
i just have this script inside the head of an html file (no other contents in the html) there is apparently no playback of the audio. but if i remove the marked line, the audio plays. and no errors in the console as well. any idea whats happening ? and a fix (without removing the marked line) ?
Rrubberduckies10/5/2022
you're only piping it to the analyser, not to the speakers after this: audioContext.createMediaElementSource(audio).connect(audioAnalyser); try: audioAnalizer.connect(audioContext.destination)
RRelativPerspektiv10/5/2022
oh ok lemme try cool, it works @rubberduckies thanks 🙂
UUUnknown User10/6/2022
3 Messages Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

✅ – BIOLOGY SCIENCE – 14-32 Oct 5

Join Server