-->

How to obtain object from navigator.getUserMedia()

2019-09-15 17:31发布

问题:

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?

回答1:

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.