Is audio recording supported in IWA?

631 views
Skip to first unread message

Xtralogic

unread,
Jul 8, 2024, 9:58:02 PM7/8/24
to iwa-dev
Hi Google Chrome Team ,

I've added the 'microphone' permission to the app manifest and was prompted for permission to use microphone, when navigator.mediaDevices.getUserMedia was called.
But the MediaRecorder 'ondataavailable' callback  is never called after the  MediaRecorder is started and there are no errors reported. This code works fine from a webpage: https://jsfiddle.net/sasivarunan/bv55z5fe/366/

Here is the code snippet:
        navigator.mediaDevices.getUserMedia({ audio: true })
            .then(stream => {
                let audioChunks = [];
                let rec = new MediaRecorder(stream);
                rec.ondataavailable = e => {
                    console.log("New audio data " + e.data);
                    audioChunks.push(e.data);
                }
                rec.start();
            })
            .catch(e => console.log("Audio recording error" + e));

Thanks,
Sergey.

Xtralogic

unread,
Jul 8, 2024, 11:38:31 PM7/8/24
to iwa-dev, Xtralogic
Resolved the problem by providing timeslice parameter to the  MediaRecorder  start method. If the  timeslice parameter is provided, the  ondataavailable is called periodically.

Robbie McElrath

unread,
Jul 9, 2024, 12:52:09 PM7/9/24
to Xtralogic, iwa-dev
Is the timeslice parameter not required on normal web pages? If there's a difference between IWAs and non-IWAs with this API we should fix it.

--
You received this message because you are subscribed to the Google Groups "iwa-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iwa-dev+u...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/iwa-dev/f886fb0f-6150-4e73-8f10-2210284b6fe9n%40chromium.org.

Xtralogic

unread,
Jul 11, 2024, 1:58:22 PM7/11/24
to iwa-dev, rmce...@google.com, iwa-dev, Xtralogic
>Is the timeslice parameter not required on normal web pages? If there's a difference between IWAs and non-IWAs with this API we should fix it.
I've checked using the above referenced fiddle on Chrome. It looks like it behaves the same, if the timeslice is not provided, ondataavailable is fired only when  MediaRecorder  stop() method is called.

Robbie McElrath

unread,
Jul 11, 2024, 4:16:08 PM7/11/24
to Xtralogic, iwa-dev
Great, thanks for confirming.
Reply all
Reply to author
Forward
0 new messages