Alan Alvarez
Alan Alvarez

Reputation: 678

In AWS Device Farm if camera goes black, what it means?

I made an app using cordova and "cordova-plugin-camera-preview" plugin. I tried to test it on AWS Device Farm but the screenshots where the plugin supposed to show video-capture is black, when the tests finishes it does not shows me errors.

What does it mean?

These are the two functions I'm using to get video capture (That works on my phone):

function captura_video() {
            try{     

                window.canvas_video_temp = document.createElement("canvas");
                window.contexto_video_temp = canvas_video_temp.getContext("2d");

                var promisifiedOldGUM = function(constraints) {
                    var getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia);

                    if(!getUserMedia) {
                        return Promise.reject(new Error('Este dispositivo no esta preparado para el manejo de camara'));
                    }

                    return new Promise(function(resolve, reject) {
                        getUserMedia.call(navigator, constraints, resolve, reject);
                    });
                }

                if(navigator.mediaDevices === undefined) {
                    navigator.mediaDevices = {};
                }

                if(navigator.mediaDevices.getUserMedia === undefined) {
                    navigator.mediaDevices.getUserMedia = promisifiedOldGUM;
                }

                window.videoElement = document.getElementById("pantalla_video");

                navigator.mediaDevices
                .getUserMedia(window.constraints)
                .then(
                    stream => {
                        window.videoElement.srcObject=stream;
                        window.videoElement.onloadedmetadata = () => {
                            if(window.interruptor_buscador == true){
                                auxiliar_1();
                            }else if(window.interruptor_enlace == true){
                                auxiliar_2();
                            }
                            window.videoElement.play();
                            bucle_cuadros();
                        };
                    }
                ).catch(
                    err => {
                        alert("Error mediaDevices: " + err.code);
                    }
                );
            }catch(err2){
                alert("Error de captura de video: " + err2.message);
            }
        }


        function bucle_cuadros(){
            try{
                if (window.videoElement.readyState === window.videoElement.HAVE_ENOUGH_DATA) {
                    //SOME DIRTY THINGS HERE
                }
                requestAnimationFrame(bucle_cuadros);
            }catch(err){
                alert("Error bucle_captura: " + err.message);
            }
        }

And this is the screenshot provided by AWS Device Farm: enter image description here Thanks.

Upvotes: 0

Views: 810

Answers (1)

jmp
jmp

Reputation: 2375

Are you taking screenshots or taking photos from the camera?

https://aws.amazon.com/device-farm/faqs/

Q: Can I use the device camera?

Yes, you can use the device cameras, both front- and rear-facing. Due to the way the devices are mounted, images and videos may look dark and blurry.

I think this image would be expected in Device Farm right now.

HTH

-James

Upvotes: 1

Related Questions