Closed cramhead closed 10 years ago
Do you have a repository with a reproduction? I'm not quite sure what you're trying to do and where you are changing the sourceType.
I have a repo, https://github.com/cramhead/mobile-packages. It's a fork of this project. I tried make the smallest change possible to make things work, but right from the initial clone of this repo I had the same problem. You'll notice I adjust the api.versionfrom to '0.9.1', to see if it could force updates to cordova camera package and the meteor release to '0.9.2', that came out moments ago, but it still results in 'Camera.getPicture: source type 1 not available.' https://github.com/cramhead/mobile-packages/compare/meteor:master...master This version does have the sourceType set, as I expects that it defaults to Camera.PictureSourceType.CAMERA, which is want I'd like to have happen. If I passing sourceType: Camera.PictureSourceType.PHOTOLIBRARY the plugin responds as expected.
Are you trying to run the app in an iPhone emulator?
If that's the case, the emulator doesn't support camera functionality, and only supports getting photos from the photo library. Sounds like maybe I should build in an automatic fallback because lots of people will be trying to test their apps on the emulator.
Yes, I trying to run it on the iOS emulator. I didn’t realize that it would not just use the built in camera to take the picture. Wow, what a pain.
Are you thinking of using the browser's access to the camera as the fall back? Thanks for your help.
I talked to a few people, and it looks like a good fallback in the case of the iPhone simulator would be to get the photo from the photo library (use Camera.PictureSourceType.PHOTOLIBRARY just like you have here).
It seems that this is what people do usually when they develop with the iOS simulator, so it seems like a reasonable default for this package.
Other than this particular case, I don't want to build in first-class support for using the photo library right now because that means I also have to build a photo uploader for desktop, which could be a fair amount of work.
I added a note about this to the README, thanks for reporting.
No problem. Thanks for you help. It’s really great to see examples.
On Sep 15, 2014, at 2:26 PM, Sashko Stubailo notifications@github.com wrote:
I added a note about this to the README, thanks for reporting.
— Reply to this email directly or view it on GitHub.
Can you recommend how to check? i'm doing this:
if( ionic.Platform.isIOS() || ionic.Platform.isAndroid() || ionic.Platform.isWindowsPhone() ) { CameraFactory.getPicture(); }
which works on a device. but i would also like to add else if( /* device is iphone simulator / ) { // use Camera.PictureSourceType.PHOTOLIBRARY } else if ( / device is computer / testing / dev */ ) { // use upload image dialog box. }
Yeah it's hard to detect if you are running in a simulator or on an actual device with Cordova. It's also hard to reliably tell the difference between a desktop and mobile browser without relying on screen width. I think your best bet would be to try to get a picture from the camera then use photo library if it fails, and use feature detection to see if you can get a video stream from the browser and use a photo upload box if not.
I've been trying to get the camera to work with the simple-photo example. I consistently get this message. Even after updating to rc8 and changing the camera dependency from 3.0 to 3.1. When I change sourceType to Camera.PictureSourceType.PHOTOLIBRARY it does ask for permission to the photo library and if I allow it shows what's there.
Any thoughts?