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

283
Vistas
Why html player doesnt play audio blob on IOS safari?

So I have two buttons(start/stop), canvas with sound visualizer and html5 audio player. Everything works cool, but not on IOS Safari (tested on 15.3). On IOS it shows that recording was started, that everything is going ok, but when the recording has stopped and blob inserted into audio tag, it shows "error" message inside audio-tag instead of playing this blob. Here is the code:

        var stop = document.querySelector('#rec-stop');        
        var player = document.querySelector('#rec-player'); 
        var totest = document.querySelector('.test-choice-btn'); 
        navigator.mediaDevices.getUserMedia({audio:true})
          .then(stream => {handlerFunction2(stream)})  
          function handlerFunction2(stream) {
            rec = new MediaRecorder(stream);
            audioContext = new AudioContext();
            analyser = audioContext.createAnalyser();
            microphone = audioContext.createMediaStreamSource(stream);
            javascriptNode = audioContext.createScriptProcessor(2048, 1, 1);

            analyser.smoothingTimeConstant = 0.8;
            analyser.fftSize = 1024;

            microphone.connect(analyser);
            analyser.connect(javascriptNode);
            javascriptNode.connect(audioContext.destination);

            canvasContext = $("#rec-canvas")[0].getContext("2d");

            javascriptNode.onaudioprocess = function() {
                var array = new Uint8Array(analyser.frequencyBinCount);
                analyser.getByteFrequencyData(array);
                var values = 0;

                var length = array.length;
                for (var i = 0; i < length; i++) {
                    values += (array[i]);
                }

                var average = values / length;    

                canvasContext.clearRect(0, 0, 150, 270);
                canvasContext.fillStyle = '#BadA55';
                canvasContext.fillRect(0, 270 - average, 150, 270);
                canvasContext.fillStyle = '#262626';            
            }      
            audioChunks = [];
            rec.start();       
            stop.onclick = e => {                               
                rec.stop();   
                totest.classList.add('shown');             
            } 
            
            rec.ondataavailable = e => {
                audioChunks.push(e.data);
                if (rec.state == "inactive"){
                    let blob = new Blob(audioChunks,{type:'audio/mpeg-3'});
                    player.src = URL.createObjectURL(blob);
                    player.controls=true;
                    player.autoplay=true;                
                }
            }
        } 
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