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
Developer
Posts: 588
Registered: ‎05-29-2009
My Device: 9100
Accepted Solution

Error in supported: TypeError: Result of expression 'blackberry.media' [undefined] is not an object

I am trying to take pics within my widget, but when i do the call   

 

blackberry.media.camera.takePicture(successCB, closedCB, errorCB);

 

I got this error in simulator and also in a real device: "Error in supported: TypeError: Result of expression 'blackberry.media' [undefined] is not an object"

 

Also I included the feature in config.xml:

<feature id="blackberry.media.camera" required="true" version="1.0.0.0"/>

 

I don't know what else could be.

 

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Error in supported: TypeError: Result of expression 'blackberry.media' [undefined] is not an object

Hi there,

 

Are you by chance browsing to a webpage that is hosting your widget? Or are you actually packaging the widget and installing it onto the device as a WebWorks application?

 

Note that in addition to the feature:

 

<feature id="blackberry.media.camera" />

You must also include the permission:

 

<rim:permissions>
	<rim:permit>use_camera</rim:permit>
</rim:permissions>

Note that the <permit> is wrapped within the <permissions> element. More information on the <permissions> element can be found here.

 

I found success with the following.

 

config.xml

<?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">
	<name>Sandbox</name>
	<author>Oros</author>
	<content src="index.html"/>
	<feature id="blackberry.media.camera" />
	<rim:permissions>
		<rim:permit>use_camera</rim:permit>
	</rim:permissions>
</widget>

index.html

<!DOCTYPE html>
<html>
	<head>
	</head>
	<body>
		<input type="button" onclick="takePicture();"></input>
		<script type="text/javascript">
			function takePicture() {
				try {
					blackberry.media.camera.takePicture(successCB, closedCB, errorCB);
				} catch(e) {
					alert("Error in supported: " + e);
				}
			}

			function successCB(filePath) {
				alert("Succeed: " + filePath);
			}

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

			function errorCB(e) {
				alert("Error occured: " + e);
			}
		</script>
	</body>
</html>

This was based on the sample at the bottom of this document, but takeVideo was replaced with takePicture:

https://bdsc.webapps.blackberry.com/html5/apis/blackberry.media.camera.html

 

Erik Oros

BlackBerry Development Advisor



Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Developer
Posts: 588
Registered: ‎05-29-2009
My Device: 9100

Re: Error in supported: TypeError: Result of expression 'blackberry.media' [undefined] is not an object

[ Edited ]

I am packaging and installing the widget. And I tried it as you said and I got the same error.

Also, I was thinking permissions were only for playbook applications and this time I am developing for smartphone. am I wrong? Anyway I tried that and it didn't work neither.

 

I also created an empty project only using your code and I got the same error.

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Error in supported: TypeError: Result of expression 'blackberry.media' [undefined] is not an object

Ah yes. Sorry, I assumed a PlayBook. On a smartphone, the permission elements are not a requirements, just the feature.

 

Can you confirm the model and OS version of the smartphone you're trying this on?

 

Erik Oros

BlackBerry Development Advisor


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Developer
Posts: 588
Registered: ‎05-29-2009
My Device: 9100

Re: Error in supported: TypeError: Result of expression 'blackberry.media' [undefined] is not an object

Of course, I am trying on a Curve 9360 and 7.0 OS
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Error in supported: TypeError: Result of expression 'blackberry.media' [undefined] is not an object

Hi there,

 

I don't have a 9360 around me at the moment, but I did just try on a 9900 running 7.0 and the code above ran just fine.

 

On your device, could you please navigate:

Options > Device > Application Management > Search for and highlight the applicatiion > Press the menu button and select Edit Permissions > Set everything to Allow (or as high as it will go) > Save the options and relaunch your application to test.

 

This is more of a longshot, but we need to get a little creative.

 

Also, are you using the latest version (2.3.1) of the smartphone SDK when packaging?

https://bdsc.webapps.blackberry.com/html5/download/sdk

 

I'll try and brainstorm a few more ideas, but the code above should work on a 7.0 device. Perhaps someone from the community can double-check on theirs?

 

Erik Oros

BlackBerry Development Advisor


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
New Developer
Posts: 19
Registered: ‎03-27-2011
My Device: Tour
My Carrier: Sprint

Re: Error in supported: TypeError: Result of expression 'blackberry.media' [undefined] is not an object

If you are actually using a web based server (anything thats not running locally on playbook) to access the camera you must also include the following into your config.xml file for it to work

 

 

<access uri="http://domainofyourserver.com/" subdomains="true">
<feature id="blackberry.app.event" required="true" version="1.0.0.0"/>
<feature id="blackberry.media.camera" />
</access>

 

 

This will then give permission for that "page" to have access to the camera function of the blackberry.