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

217
Vistas
loading local file in <audio> tag working alternately

I need to load local audio file into <audio> tag.

I did it with the following code.

Let the user choose a file with:

<ion-input type="file" (change)="laodLocalFile($event)">

Prepare it for <audio> tag:

laodLocalFile(event: any)
{    
  file_url = URL.createObjectURL(event.target.files[0]);
  document.getElementById('audio_file').setAttribute("src", file_url);
}

And use it as following:

<audio id="audio_file" type="audio/mpeg" controls></audio>

I tried it with several different mp3 files. It worked several times, but most of the times it didn't work, without any warning or error.

What can be the issue?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to use domeSanitizer and bypassSecurityTrustUrl() this method bypass security and trust the given value to be a safe style URL, i.e. a value that can be used in hyperlinks or src

constructor(private domSanitizer:DomSanitizer) {    }

And in your method: ...

this.mediaSrc = this.domSanitizer.bypassSecurityTrustUrl(file_url);
about 4 years ago · Juan Pablo Isaza Denunciar
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