Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Posts: 1
Registered: ‎06-26-2013
My Device: Q10
My Carrier: 61488789894

HTML5 Camera access - Q10 problem

[ Edited ]
Hey guys,
I am using the file input control, and JS to capture an image from the gallery/camera in the Dev alpha Q10, and Z10... the problem is it is not working on the Q10 as an "app" - but is working as a webapp (through the browser)
On click of the input, photo gallery pops up (on the Q10 and the Z10).
The problem is when I select a photo, it calls the method below (with the file input parameter).
On the Z10 it works 100%. Same as when I test it as a "webapp" on Android & iPhone.
 And returns the jpeg (base64) encoded image... (i use a canvas to convert it from png).
But on the Q10 when in an app - it just does nothing... No errors or anything. 
As mentioned, when it's through the webapp (browser) it works on the Q10
Note, this is the dev alpha version - not sure if that matters.
Anyways, on the off chance a code snippet it's helpful...
       function get_image_uri(file_input, callback) {
		if(file_input.files && file_input.files[0]){

			var file_reader = new FileReader();
			file_reader.onload = $.proxy(function(e) {

				//conversion canvas to convert from png to jpeg.
				var canvas = document.createElement("canvas");
				var ctx = canvas.getContext('2d');
				var img = new Image();

				img.onload = $.proxy(function() {
					canvas.width = img.width;
					canvas.height = img.height;
					ctx.drawImage(img, 0, 0);
					var uri = canvas.toDataURL("image/jpeg");


				}, this);

			}, this);

			var url = file_reader.readAsDataURL(file_input.files[0]);







Posts: 71
Registered: ‎09-19-2012
My Device: No sleep til BlackBerry 10
My Carrier: Bell

Re: HTML5 Camera access - Q10 problem

Have you tried dropping the FileReader part?  It could be a bug with that.  I wasn't able to reproduce on my end so it could just be dev alpha c thing.  However, using FileReader is unnecessary.  Try to just do the following:




and that way you can skip the FileReader load event.


Hope that yields some results!




-_- zZZ