我想用html获取手机摄像头视图,所以我决定尝试这个插件:https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview但是我试图打开我的应用程序它只是白屏。我正在使用phonegap / cordova系统,平台:Android。对于插件安装,我只写了cordova plugin add https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview.git
行。
Html代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style type="text/css">
html{
background-color: transparent;
}
</style>
<title>Camera View Test</title>
</head>
<body style="background-color='transparent'">
<script type="text/javascript" src="cordova.js"></script>
<script>
var tapEnabled = true; //enable tap take picture
var dragEnabled = true; //enable preview box drag across the screen
var toBack = true; //send preview box to the back of the webview
var rect = {x: 100, y: 100, width: 200, height:200};
cordova.plugins.camerapreview.startCamera(rect, "front", tapEnabled, dragEnabled, toBack)
cordova.plugins.camerapreview.show();
</script>
<script type="text/javascript" src="CameraPreview.js"></script>
</body>
</html>
config.xml中:
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<gap:plugin name="cordova-plugin-camera-preview" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
感谢任何回应,我是创建应用程序的新手,所以我需要帮助!