2012-07-10 47 views
0

我對webworks相當陌生。我試圖讓相機API來工作,我不斷收到錯誤:如何讓相機與Blackberry Webworks一起使用

錯誤的支持:類型錯誤:「未定義」不是(評估「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文件如下:http://www.flyloops.net/mobile/bb/camera.html

我一直在撕裂我的頭髮爲:

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

該頁面在託管過去3小時...任何幫助將不勝感激。

回答

0

你在運行什麼設備?代碼看起來很好,它應該工作。您可以從設備獲取事件日誌並查看引發的異常情況。

感謝

納文中號

1

如果使用的PlayBook,確保有正確的元素(一個或多個)定義 https://developer.blackberry.com/html5/apis/blackberry.media.camera.html

否則,如果您嘗試訪問blackberry.media.camera API from遠程網站,那麼你需要在config.xml中正確的白名單,如下所示:

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