locked
Open Camera from WebView RRS feed

  • Question

  • User175798 posted

    Hi,

    Is it possible to open the camera from WebView? I have been tring to open camera using this code:

    MainActivity.cs

    WebView webview = FindViewById(Resource.Id.webView1); webview.Settings.JavaScriptEnabled = true; webview.SetWebViewClient(new MyWebViewClient()); webview.SetWebChromeClient(new WebChromeClient()); web_view.LoadUrl("http://myurl.com/");

    JavaScript

    try { if (navigator.getUserMedia) { var video = document.getElementById('Video'); video.src = null; navigator.getUserMedia('video', successCallback, errorCallback);

                    function successCallback(stream) {
                        video.src = stream;
                    }
                    function errorCallback(error) {
                        alert("An error occurred: [CODE " + error.code + "]");
                    }
                }
                else {
                    document.getElementById("msg").innerHTML = "Native camera is not supported in this browser!";
                }
            }
            catch (err) {
                document.write("Catch: " + err.message);
    

    }

    When I execute the project showing the follow message: Native camera is not supported in this browser!

    Now, I don't know if is possible to open the camera from webview or if my code it's wrong.

    Tks

    Thursday, February 16, 2017 9:35 PM

Answers

All replies