fix camera for firefox os

This commit is contained in:
James Long 2013-10-29 15:40:18 -04:00 committed by hermwong
parent e8e420895e
commit 3424ddb39c

View File

@ -17,35 +17,34 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
* *
*/ */
function takePicture(success, error, opts) {
function getPicture(cameraSuccess, cameraError, cameraOptions) {
cameraError = cameraError || function(){};
var pick = new MozActivity({ var pick = new MozActivity({
name: "pick", name: "pick",
data: { data: {
type: ["image/png", "image/jpg", "image/jpeg"] type: ["image/*"]
} }
}); });
pick.onerror = cameraError;
pick.onerror = error || function() {};
pick.onsuccess = function() { pick.onsuccess = function() {
// image is returned as Blob in this.result.blob // image is returned as Blob in this.result.blob
// we need to call cameraSuccess with url or base64 encoded image // we need to call success with url or base64 encoded image
if (cameraOptions && cameraOptions.destinationType == 0) { if (opts && opts.destinationType == 0) {
// TODO: base64 // TODO: base64
return; return;
} }
if (!cameraOptions || !cameraOptions.destinationType || cameraOptions.destinationType > 0) { if (!opts || !opts.destinationType || opts.destinationType > 0) {
// url // url
return cameraSuccess(window.URL.createObjectURL(this.result.blob)); return success(window.URL.createObjectURL(this.result.blob));
} }
}; };
} }
module.exports = { module.exports = {
getPicture: getPicture, takePicture: takePicture,
cleanup: function(){} cleanup: function(){}
}; };