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

274
Views
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
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!