Last active
July 30, 2019 18:32
-
-
Save gubleo/6d74f08a52b32b89782ab2c85b8ea80d to your computer and use it in GitHub Desktop.
Acessar câmera do celular através do JQuery utilizando o Apache Cordova. [PLUGIN plugin-cordova-camera]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link type="text/css" rel="stylesheet" href="./css/materialize.min.css" media="screen,projection"/> | |
<script type="text/javascript" src="cordova.js"></script> | |
<script type="text/javascript"> | |
$(function () { //$(document).ready(function(){}); | |
function camSuccess(imgData){ | |
$("#img_camPH").attr("src", imgData); | |
//<img src="file://localondeoarquivoestaemseutelefone/img.jpg"> | |
} | |
function camError(error){ | |
alert(error); | |
} | |
function accessCamera() { | |
var options = { | |
destinationType: Camera.DestinationType.FILE_URI, | |
sourceType: Camera.PictureSourceType.CAMERA // PHOTOGALLERY | |
}; | |
navigator.camera.getPicture(camSuccess, camError, options); | |
} | |
$("#btn_camera").on("click", accessCamera); | |
}); | |
</script> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row"> | |
<div class="col s12 m6"> | |
<h5>Acessar Camera</h5> | |
<button id="btn_camera">Capturar Foto</button> | |
<p><img style="display: none; width: 250px; height: 250px;" id="img_camPH"></p> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment