简体   繁体   中英

How to record audio in browser on iOS?

All tutorials I found make use of getUserMedia() , which doesn't exist in iOS Browsers. Is there any other way to record Audio in the Browser on iOS?

Since iOS 11, getUserMedia is supported in iOS browsers.

You can use this simple example:

constraints = { audio: true, video: true };
navigator.mediaDevices.getUserMedia(constraints).then(handleSuccess);

var handleSuccess = function (stream) {  

    var context = new AudioContext();
    var processor = context.createScriptProcessor(1024, 1, 1);
    var input = context.createMediaStreamSource(stream);

    processor.connect(context.destination);
    input.connect(processor);

    processor.onaudioprocess = function (e) {
        // Get sound packets from microphone            
        // e.inputBuffer.getChannelData(0) will now have sound packets
    };
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM