Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

225
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda