Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
Why audio is not working after using Audio Context?

I developed a Firefox addon to increase the output of the speaker. I used AudioContext for this.

On YouTube videos it is working fine but on other websites it is not working. So I figured out that this was because of DOM is not loaded. So I now if I am waiting for DOM to load completely, there is no sound coming out of the speakers even for YouTube which was working previously.

Here is the code, I tried putting it inside DOMReady and other methods that waits for DOM to load but Audio stops working after this.

let mVideoElement = document.querySelector('video');
let audioCtx = new AudioContext();
let source = audioCtx.createMediaElementSource(mVideoElement);
let gainNode = audioCtx.createGain();

browser.storage.onChanged.addListener((changes, area) => {
    if (area === 'local' && 'value' in changes) {
        increaseVolume(changes.value.newValue);
    }

    if (area === 'local' && 'status' in changes) {
        speakerBoosterStatus(changes.status.newValue);
    }
});

function increaseVolume(value) {
    if (value === undefined) {
        gainNode.gain.value = 1;
    } else {
        gainNode.gain.value = value;
    }
    source.connect(gainNode);
    gainNode.connect(audioCtx.destination);
}


function speakerBoosterStatus(status) {
    if (status === false) {
        gainNode.gain.value = 1;
        source.connect(gainNode);
        gainNode.connect(audioCtx.destination);
        window.location.reload();
    } else {
        browser.storage.local.get('value').then(result => increaseVolume(result.value));
    }
}

browser.storage.local.get('value').then(result => increaseVolume(result.value));
browser.storage.local.get('status').then(result => speakerBoosterStatus(result.value));

Here is the Source Code for better testing.

PR are welcome. Thank you :)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!