我有一個啓用了平臺瀏覽器的Cordova應用程序。我想在Chrome中使用相機,但調用相機完全沒有反饋。它的作用就像我的Android設備上的魅力。Cordorva瀏覽器平臺相機不能正常工作
我通過這個命令來啓動: cordova run browser
打開Chrome瀏覽器如預期有完全正常的控制檯日誌告訴我,科爾多瓦設置相機的代理:
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 -version
=> 4.0.0
cordova plugins
=> org.apache.cordova.camera 0.3.4 「相機」
如果有人能指導我這個問題,我真的它並欣賞。
在此先感謝。
/馬丁
完美。我會稍後再嘗試。感謝您的答覆。 –