[英]How to access camera onclick on Android app?
I am currently using Visual Studio to work on my project, and i need a function which allows the opening of camera on the press of a button. 我目前正在使用Visual Studio来处理我的项目,我需要一个允许按下按钮打开相机的功能。 I have some codes from a previous project but they don't seem to work now. 我有一些来自之前项目的代码,但它们现在似乎不起作用。 Below are my codes. 以下是我的代码。
js: JS:
function getImage() {
// Retrieve image file location from specified source
navigator.camera.getPicture(uploadPhoto,
function (message) { alert('get picture failed'); },
{ quality: 10, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY }
);
}
HTML: HTML:
<form id="buyforme">
<img id="myimg" height="100">
<input type="button" name="selectimg" id="selectimg" onclick="getImage();" value="Take a picture of this item :)">
Please advise & let me know if there's anything else you need to know! 如果您还需要了解其他信息,请告知我们并告诉我们! Thank you all! 谢谢你们!
For access to mobile phone camera for getting photo
or video
in android
or ios
you can simply use input[type="file"]
like this: 要访问手机摄像头以获取android
或ios
photo
或video
,您只需使用input[type="file"]
如下所示:
Getting photo: 获取照片:
<input type="file" accept="image/*" capture="camera">
Getting video: 获取视频:
<input type="file" name="video" accept="video/*" capture="environment">
For opening back camera: 用于打开后置摄像头:
<input type="file" name="image" accept="image/*" capture="environment">
And for selfie camera (front): 而对于自拍相机(前):
<input type="file" name="image" accept="image/*" capture="user">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.