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

361
Vistas
What is the best way to detect if media file isn't accessible (403/404s) with js/html player?

Trying to use .onerror error event will trigger only about a 80% rate for me. On my demo page, doesn't matter if it's a refresh, force refresh or URL entry, try a few times and it will not detect the failed load.

Here is the Codepen of all code, with errant ID from google drive. If you replace a valid one like: 1Cguauee-7MKN2nrXM_ZvdYRLEBglCvFG it will play.

Excerpt with just specific parts:

HTML

<audio id="audioFile" src="URI"></audio>

Script

const audio = document.getElementById('audioFile');
audio.onerror = (event) => {
    console.log("Error " + audio.error.code + ": " + audio.error.message);
};

Is this .onerror the best route to go to make sure the media player doesn't hang waiting for a missing/rejected file? With google drive being the source, I do see some 403 errors randomly popping up, that when refreshed a few times later dissipate. I need to convey to reload when this occurs.

The browser always shows the error in dev console. Instead do I do a fetch()?

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