Error trying to access Rho.Camera

// Expert user has replied.
R Remco van 't Land 3 years ago
4 4 0

Hi all,

We recently were asked to allow the MC40's and TC55's being used by our client to make pictures and send those. Expecting this to be a simple feature in Rho I started off but soon ran into problems.

This is the code:

function TakePicture() {
    try {
        var pCam = { desiredWidth: 768, desiredHeight: 1024 };
        Rho.Camera.take_picture(pCam, HandlePicture(e));
    } catch (err) {
        alert(err);
    }
}

function HandlePicture(params) {
    if (params["status"] == "ok") {
        Rho.Camera.saveImageToDeviceGallery(Rho.Application.expandDatabaseBlobFilePath(params["imageUri"]));
    }
}

Triggering the TakePicture() function returns the caught error: "TypeError: 'undefined' is not an object (evaluating 'Rho.Camera.take_picture')

The camera seems unavailable in the object:

The camera is under "capabilities" in the Build.yml.

Any suggestions would be very welcome, thanks in advance!

Please register or login to post a reply

4 Replies

P Patrick Simons

Hello

I'm experiencing the same problems as discussed here.
When I implement the tag below I get errors on the ORM.
   
gives:
    TypeError: 'undefined' is not an object (evaluating 'Rho.ORM.addModel')

I'm creating a SPA application using Angular JS so I have to include all javascript in the index.html.

When setting rho_javascript_api as the last script, I don't get ORM faults anymore. But I get different errors browsing trough the application. Some examples are:
     Error: 'undefined' is not an object (evaluating 'Rho.RhoConnectClient.isLoggedIn')
     Error: 'undefined' is not an object (evaluating 'Rho.Application.databaseFilePath')

When I don't use the rho_javascript_api everything works fine, but I really need the Camera to work!
Is there a sollution to fix this? Or do I have to wait untill the javascript API implements the Camera API for javascript?

As attachment my build.yml & index.html.

P Pietro Francesco Maggi

Hi Remco,
which rhoapi-modules.js are you using?

this file is generated from your build.yml configuration. By default it does not contains all the objects and can be platform specific.

Take a look at this documentation page:
http://docs.rhomobile.com/en/4.1.0/guide/webapps#connecting-with-your-w…

You can use the console command:

#platform may be: win32, wm, android, iphone, wp8
rake update_rho_modules_js[all]

~Pietro

R Remco van 't Land

Hi Pietro,

I used the rake you suggested, but the file is identical to the one I was using. I am using Rho 4.0 btw, not 4.1, not sure if this makes any difference.

The filesize is 267.680 bytes.

V Vedsatx Saddvv

The Camera API is one that hasn't completed the move to the new 4.x RhoMobile API, instead you can 2.2 Javascript API for the Camera. Take a look at the Camera documentation for how to implement it specifically (a different JS lib required) Rhomobile | Camera API.

CONTACT
Can’t find what you’re looking for?