How to obtain object from navigator.getUserMedia() in mobile web?
Asked Answered
M

2

5

Trying to get a JavaScript reference/promise to a MediaStream returned from MediaDevices in HTML5 and WebRTC.

JavaScript here is run on Chrome and Safari on iOS and Android.

navigator.mediaDevices.getUserMedia(session, initRec , onErr);

This throws TypeError: undefined is not an object (evaluating 'navigator.mediaDevices.getUserMedia')

Fine, let's try it the slightly older way:

navigator.getUserMedia(parms,initfunc,errfunc);

This throws TypeError: navigator.getuserMedia is not a function. (In 'navigator.getUserMedia(parms,initfunc,errfunc)', 'navigator.getUserMedia' is undefined)

Note: Both of those calls work on desktop versions. Did mobile web EVER work for audio recording?

Mopboard answered 15/6, 2017 at 20:51 Comment(0)
P
3

Safari (or any browser on iOS) does not support getUserMedia and WebRTC until the upcoming Safari 11. See the webkit blog post for details and note that it does not mention the MediaRecorder API.

Penicillin answered 16/6, 2017 at 5:27 Comment(5)
Still seeing this occur in mobile Safari in 2020.Sterlingsterlitamak
I still got this on iOS 14.4 in Feb. 2021 :(Triolein
Safari choose not to implement the 'legacy' API navigator.getUserMedia. Try navigator.mediaDevices.getUserMediaPenicillin
@PhilippHancke mediaDevices is undefined.Eris
Facing same issue on ios 14.0.1 chromeCopulate
V
8

Try to serve the web page over HTTPS. I've read that iOS Safari only allows access to the microphone (and camera) on secure connections.

I had the same problem while implementing ng-audio-recorder in my Ionic Angular app. While working flawlessly on desktop, mobile safari threw this error. Switching to HTTPS solved the problem.

Verdha answered 13/5, 2021 at 12:21 Comment(1)
Thanks. this worked.Tristan
P
3

Safari (or any browser on iOS) does not support getUserMedia and WebRTC until the upcoming Safari 11. See the webkit blog post for details and note that it does not mention the MediaRecorder API.

Penicillin answered 16/6, 2017 at 5:27 Comment(5)
Still seeing this occur in mobile Safari in 2020.Sterlingsterlitamak
I still got this on iOS 14.4 in Feb. 2021 :(Triolein
Safari choose not to implement the 'legacy' API navigator.getUserMedia. Try navigator.mediaDevices.getUserMediaPenicillin
@PhilippHancke mediaDevices is undefined.Eris
Facing same issue on ios 14.0.1 chromeCopulate

© 2022 - 2024 — McMap. All rights reserved.