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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Contributor
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.

Developer
Posts: 314
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
New Contributor
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...

Retired
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.
Highlighted
New Contributor
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

Developer
Posts: 314
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
New Contributor
Posts: 7
Registered: ‎07-10-2012
My Device: Bold 9700
My Carrier: MTN

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

I have, same problem