Xamarin - Camera does not work

Asked

Viewed 45 times

1

I developed a web application. However, in the Webview that I created from this application, when I try to upload files, the code redirects me to the image gallery instead of opening the camera of the mobile phone.

In my HTML, I have the following field:

<input name="localFoto[]" type="file" accept="image/*" capture="camera">

How do I solve?

  • 3

    Possible duplicate of Cordova - Camera does not work

  • I think this has little to do with xamarin. Perhaps I can find more help with the appropriate tags, unfortunately I also do not know what would be to suggest in editing.

1 answer

0

I found the Solution: https://davidwalsh.name/browser-camera

It’s Javascript and HTML testing there! I found ball show I didn’t even know I had how to do it.

In case Link leaves Air...

HTML

<!--
    Ideally these elements aren't created until it's confirmed that the 
    client supports video/camera, but for the sake of illustrating the 
    elements involved, they are created with markup (not JavaScript)
-->
<video id="video" width="640" height="480" autoplay></video>
<button id="snap">Snap Photo</button>
<canvas id="canvas" width="640" height="480"></canvas>

Javascript

// Grab elements, create settings, etc.
var video = document.getElementById('video');

// Get access to the camera!
if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
    // Not adding `{ audio: true }` since we only want video now
    navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) {
        //video.src = window.URL.createObjectURL(stream);
        video.srcObject = stream;
        video.play();
    });
}

/* Legacy code below: getUserMedia 
else if(navigator.getUserMedia) { // Standard
    navigator.getUserMedia({ video: true }, function(stream) {
        video.src = stream;
        video.play();
    }, errBack);
} else if(navigator.webkitGetUserMedia) { // WebKit-prefixed
    navigator.webkitGetUserMedia({ video: true }, function(stream){
        video.src = window.webkitURL.createObjectURL(stream);
        video.play();
    }, errBack);
} else if(navigator.mozGetUserMedia) { // Mozilla-prefixed
    navigator.mozGetUserMedia({ video: true }, function(stream){
        video.srcObject = stream;
        video.play();
    }, errBack);
}
*/

Source: https://davidwalsh.name/browser-camera

  • Vinicius, I tested the code above, but it does not work in Google Chrome mobile and nor in Xamarin.

  • Tried to uncomment the if Else?

  • Yes. Unfortunately, it didn’t work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.