Search code examples
androidaudioweb-audio-apigetusermediachrome-for-android

How to record audio using getUserMedia and Web Audio API on Chrome for Android?


I am debugging an application which uses FlashWavRecorder or AudioRecorder to record audio, and then playing it back. The problem is that the application works as intended on Desktop Chrome, but does not record or playback (unsure which) on Chrome for Android. Here's the headers for Android:

Request Headers

URL:blob:http%3A//example.com/8e112ef4-8691-4582-8abb-82da3e312221
Request Method:GET
Status Code:206 Partial Content (from cache)
Range:bytes=0-1
Referer:http://example.com/xyz/MTYwMDc=/abcdefg
User-Agent:Mozilla/5.0 (Linux; Android 4.4.2; LG-E988 Build/KOT49I.E98820a) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.89 Mobile Safari/537.36

Response Headers

Content-Length:2
Content-Range:bytes 0-1/475180
Content-Type:audio/wav

The application first checks whether Flash is supported, if so, FlashWavRecorder is used, if not AudioRecorder is used. AudioRecorder requires Web Audio API, which, according to Can I Use...:

Chrome for Android does not support the Web Audio API in conjunction with getUserMedia.

I am unfamiliar with this API or getUserMedia, but I am guessing getUserMedia is required to request permission to use the microphone. So how can I grab the audio from the microphone and record it without using getUserMedia?

These two answers from 1.5 year ago suggests, however, that it is supported and should be working.

So which is it? Is it simply unsupported, or there's an error in the code?

(If the former, what are the alternatives to using Web Audio API or getUserMedia?)


Solution

  • This should work - get user media and web audio are both supported in chrome for android now.