Welcome!

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

Reply
New Contributor
Craigstock
Posts: 7
Registered: ‎07-10-2012
My Device: Bold 9700
My Carrier: MTN

blackberry.media.camera.takePicture - Please help!

Hello,

 

I am fairly new to webworks. I am trying to get the camera api to work and I keep getting the error:

 

Error in supported: TypeError: 'undefined' is not an object (evaluating 'blackberry.media.camera')

 

The page I am trying to use is on a hosted server. The code is as follows:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scalable=no" />
<script language="javascript" type="text/JavaScript" >
function takePicture() {
try {
blackberry.media.camera.takePicture(successCB, closedCB, errorCB);
} catch(e) {
alert("Error in supported: " + e);
}
}

function successCB(filePath) {
document.getElementById("path").innerHTML = filePath;

//alert("Succeed: " + filePath);
}

function closedCB() {
// alert("Camera closed event");
}

function errorCB(e) {
alert("Error occured: " + e);
}
</script>
<title>Camera Test Widget</title>
</head>
<body >
<p>Test the Camera by pressing the button below</p>
<b><a href="#" onclick="takePicture();">Take a Picture</a></b>
<div id="path"></div>
</body>
</html>

 

And my confix.xml file is as follows:

 

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.0" rim:header="WebWorks Sample">
<access uri="http://www.flyloops.net/" subdomains="true">
<feature id="blackberry.app.event" required="true" version="1.0.0.0"/>
<feature id="blackberry.media.camera" />
</access>
<name>Flyloops.net</name>
<description>This is a sample application.</description>
<content src="index.html"/>
</widget>

 

The page is hosted at: http://www.flyloops.net/mobile/bb/camera.html

 

I have been tearing my hair out for the past 3 hours...any help would be greatly appreciated.

Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: blackberry.media.camera.takePicture - Please help!

what device are you targeting?

Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.
New Contributor
Craigstock
Posts: 7
Registered: ‎07-10-2012
My Device: Bold 9700
My Carrier: MTN

Re: blackberry.media.camera.takePicture - Please help!

Smartphones OS 5 and up...

Please use plain text.
Administrator
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: blackberry.media.camera.takePicture - Please help!

I believe the problem has to do with whitelisting your APIs.  You are loading a local copy of index.html from your config.xml file, however you indicate that your camera.html file is being loaded from a hosted server.

 

I see in your config.xml file that you have nested feature elements within your access element.  This would be correct if you are loading camera.html in your app from a remote location like this (note the new value for the content element):  

 

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.0" rim:header="WebWorks Sample">
<access uri="http://www.flyloops.net/" subdomains="true">
<feature id="blackberry.app.event" required="true" version="1.0.0.0"/>
<feature id="blackberry.media.camera" />
</access>
<name>Flyloops.net</name>
<description>This is a sample application.</description>
<content src="http://www.flyloops.net/mobile/bb/camera.html"/>
</widget>

 

What I think you want to do, is make sure that the local index.html file also has access to the camera features.  Try adding feature elements to the main body of the widget element, like this?

 

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.0" rim:header="WebWorks Sample">
<access uri="http://www.flyloops.net/" subdomains="true">
<feature id="blackberry.app.event" required="true" version="1.0.0.0"/>
<feature id="blackberry.media.camera" />
</access>
<name>Flyloops.net</name>
<description>This is a sample application.</description>
<content src="index.html"/>
<feature id="blackberry.app.event" required="true" version="1.0.0.0"/> <feature id="blackberry.media.camera" />
</widget>

 

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Please use plain text.
New Contributor
Craigstock
Posts: 7
Registered: ‎07-10-2012
My Device: Bold 9700
My Carrier: MTN

Re: blackberry.media.camera.takePicture - Please help!

Thak you for the reply,

 

Unfortunately I still get the same error, even after adding in your edits...

 

I am using ripple to test and also it should be noted that the whole solution is hosted...

 

Any ideas?

 

Thank you

Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: blackberry.media.camera.takePicture - Please help!

I don't think you can test that in ripple.
Try in a simulator or in a real device.
Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.
New Contributor
Craigstock
Posts: 7
Registered: ‎07-10-2012
My Device: Bold 9700
My Carrier: MTN

Re: blackberry.media.camera.takePicture - Please help!

I have, same problem
Please use plain text.