我有一个启用了Browser平台的Cordova应用程序。我想在Chrome中使用相机,但调用相机没有任何反馈。它在我的Android设备上表现得很好。
我通过以下命令启动:
我正在使用https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md中的示例。
在下面的示例中,当我点击链接时,除了日志行“capture”之外什么也不会发生。没有错误,甚至不要求我允许访问我的相机。我已经在HTML5页面上测试了我的相机,并且Chrome可以很好地访问它。
我通过以下命令启动:
cordova run browser
Chrome按预期打开,并显示完美的控制台日志,告诉我Cordova为相机设置了代理: The key "target-densitydpi" is not supported.
cordova.js:851 adding proxy for Camera
index.js:47 Received Event: deviceready
我正在使用https://github.com/apache/cordova-plugin-camera/blob/master/doc/index.md中的示例。
在下面的示例中,当我点击链接时,除了日志行“capture”之外什么也不会发生。没有错误,甚至不要求我允许访问我的相机。我已经在HTML5页面上测试了我的相机,并且Chrome可以很好地访问它。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
<img id="myImage"/>
<a href="javascript: capture()">Camera example</a>
</div>
<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script>
function capture()
{
console.log("capture")
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.DATA_URL
});
}
function onSuccess(imageData) {
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
</body>
</html>
index.js文件是由Cordova生成的一个文件。
cordova -version
=> 4.0.0
cordova plugins
=> org.apache.cordova.camera 0.3.4 "Camera"
如果有人能够指导我完成这个任务,我将非常感激。
提前致谢。
/马丁