#SOLVED [Audio API] Audio doesn't play when I use createMediaElementSource on an audio element.

4 messages · Page 1 of 1 (latest)

mint idol
#
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) ?

mint idol
#

solution: audioAnalyser.connect(audioContext.destination);

#

SOLVED [Audio API] Audio doesn't play when I use createMediaElementSource on an audio element.

inland patio
#

@mint idol if you've solved it yourself, do you mind sharing the solution for archival purposes?