-
Notifications
You must be signed in to change notification settings - Fork 5
/
17.h5+api.html
54 lines (52 loc) · 1.54 KB
/
17.h5+api.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title></title>
</head>
<body>
<button type="button" id="btn">点击</button>
<button onclick="captureImage()">拍照</button>
<script type="text/javascript">
// 普通弹出层
document.addEventListener('plusready', function() {
//console.log("所有plus api都应该在此事件发生后调用,否则会出现plus is undefined。")
function getModel() {
console.log("Model: " + plus.device.model);
alert("Model: " + plus.device.model)
}
// getModel()
document.querySelector('#btn').onclick = function() {
getModel()
}
});
</script>
<script type="text/javascript">
// 摄像头
// 扩展API加载完毕后调用onPlusReady回调函数
document.addEventListener("plusready", onPlusReady, false);
// 扩展API加载完毕,现在可以正常调用扩展API
function onPlusReady() {
console.log("plusready");
}
// 拍照
function captureImage() {
var cmr = plus.camera.getCamera();
var res = cmr.supportedImageResolutions[0];
var fmt = cmr.supportedImageFormats[0];
console.log("Resolution: " + res + ", Format: " + fmt);
cmr.captureImage(function(path) {
alert("Capture image success 成功: " + path);
},
function(error) {
alert("Capture image failed 失败: " + error.message);
}, {
resolution: res,
format: fmt
}
);
}
</script>
</body>
</html>