By referring to another person's blog post, using the WebRTC of JavaScript with the rear camera of the iPhone
I'm trying to display the image I'm shooting, but I get an error.
Videos taken with a PC/Windows10 webcam are displayed without problems in Chrome.
It is only for the display of the video currently being shot, and it will not be recorded or used for audio.
Thank you.

Error message
TypeError: undefined is not an object (evaluating 'navigator.mediaDevices.getUserMedia')
Applicable source code
var video = document.getElementById ("video");
    var medias = {audio: false, video: {}};
    medias.video.facingMode = {exact: "environment"}
    navigator.mediaDevices.getUserMedia (medias) .then (function (stream) {
        // Put the stream in video.srcObject.
        video.srcObject = stream;
    }). catch (function (err) {
        // Please allow the camera.
        window.alert ("Camera usage was not allowed");

The video from the PC webcam was displayed without problems in Chrome.
I tried various parameters of getUserMedia constraints, but I get the same error.

Supplemental information (FW/tool version etc.)

iOS is 11.4.1.

  • Answer # 1

    It is said that you are using Monaca, but the browser used in Monaca seems to be WKWebView or UIWebView, so it seems that getUserMedia cannot be used.

    Cordova plug-in that embeds the camera screen in HTML | Monaca Press


    You can use getUserMedia for camera access in HTML on iOS11 mobile Safari, but this is only for Safari, and it is not yet provided for WKWebView and UIWebView, which are browsers used in the Monaca app.

    By using cordova plug-in cordova-plugin-camera-preview, Monaca seems to be able to use the camera, so why not try that method?

Related articles