如何让相机与Blackberry Webworks一起使用

时间:2012-07-10 14:20:22

标签: blackberry-webworks

我是网络新手。我想让相机api工作,我不断收到错误:

支持错误:TypeError:'undefined'不是对象(评估'blackberry.media.camera')

我尝试使用的页面位于托管服务器上。代码如下:

<!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>

我的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.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>

该页面位于:http://www.flyloops.net/mobile/bb/camera.html

过去3个小时我一直在撕扯头发......任何帮助都会非常感激。

2 个答案:

答案 0 :(得分:1)

如果使用PlayBook,请确保定义了正确的元素 https://developer.blackberry.com/html5/apis/blackberry.media.camera.html

否则,如果您尝试从远程网站访问blackberry.media.camera API ,那么您需要在config.xml中正确列出白名单,如下所示:

<access uri="http://www.flyloops.net/" subdomains="true">
   <feature id="blackberry.media.camera" />
</access>

答案 1 :(得分:0)

你在运行什么设备?代码似乎很好,它应该工作。您可以从设备获取事件日志,并查看正在抛出的异常。

由于

Naveen M