I'm trying to use the Camera, and I would like to know if you have any exemple on how to make it work on both web / native.
I have this piece of code, borrowed from the ng-cordova doc :
$scope.takePicture = function() {
var options = {
quality: 75,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 100,
targetHeight: 100,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function(imageData) {
// Success! Image data is here
}, function(err) {
// An error occured. Show a message to the user
});
}
When I use it, it works well with my device, but catch an error with the web version
ReferenceError: Camera is not defined
That's why I ask if you have any good way to do that. I could simulate a click on an hidden input, but it doesn't look pretty. If you have any idea :)
You could provide an implementation for the camera access for both Cordova and standard browser. The standard browser implementation could be realized using this
http://www.html5rocks.com/en/tutorials/getusermedia/intro/
and to check, whether you're running in an app or in browser, you could use
ionic.Platform.platform()
documented here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.