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