-
Notifications
You must be signed in to change notification settings - Fork 4
/
camera.html
144 lines (128 loc) · 3.59 KB
/
camera.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>虎师罗盘</title>
<link rel="stylesheet" type="text/css" href="./css/style.css" />
<style type="text/css">
#camera {
width: 100%;
height: 100%;
position: absolute;
top: 0;
}
.deg-img {
display: none;
}
.noAllow {
pointer-events: none !important;
}
.tools li p {
/* color: #fff; */
}
</style>
</head>
<body>
<div class="scroll">
<video id="camera" autoplay playsinline></video>
<!-- header -->
<div class="header">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/logo2.png">
</div>
<!-- top-tool -->
<div class="top-tool">
</div>
<!-- pan -->
<div class="pan noAllow">
<!-- jia&jian -->
<div class="jia_btn">+</div>
<div class="jian_btn">-</div>
<!-- line -->
<span class="line line-heng"></span>
<span class="line line-shu"></span>
<img class="main-pan" id="compass" src="http://ii.sinelinked.com/miniProgramAssets/compass/pan-map.png">
<img class="deg-img" src="./img/a2.png" alt="" srcset="">
<img class="zhen-img" src="./img/a3.png" alt="" srcset="">
</div>
<!-- tools -->
<ul class="tools">
<li id="switch">
<div class="top">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/001.png">
</div>
<p>模式</p>
</li>
<li id="lock">
<div class="top">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/004.png">
</div>
<p>锁定</p>
</li>
<li id="manual">
<div class="top">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/005.png">
</div>
<p>手动</p>
</li>
<li id="fold">
<div class="top">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/003.png">
</div>
<p>收起</p>
</li>
<li id="change">
<div class="top">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/002.png">
</div>
<p>换盘</p>
</li>
</ul>
</div>
<script src="js/switch.js" type="text/javascript" charset="utf-8"></script>
<script src="js/map.js" type="text/javascript" charset="utf-8"></script>
<script>
var video = document.getElementById('camera')
var clientWidth = document.body.clientWidth
var clientHeight = document.body.offsetHeight
var constraints = window.constraints = {
video: {
width: { min: 1024, ideal: 1280, max: 1920 },
height: { min: 776, ideal: 720, max: 1080 },
facingMode: {
exact: "environment"
}
}
};
function handleSuccess(stream) {
var videoTracks = stream.getVideoTracks();
console.log('Using video device: ' + videoTracks[0].label);
video.srcObject = stream;
}
function handleError(error) {
alert(error);
console.log('getUserMedia error: ' + error.name, error);
}
navigator.mediaDevices.getUserMedia(constraints).then(handleSuccess).catch(handleError);
var change = document.getElementById('change')
var compass = document.getElementById('compass')
var panBg = [
'http://ii.sinelinked.com/miniProgramAssets/compass/pan-map-yellow.png',
'http://ii.sinelinked.com/miniProgramAssets/compass/pan-map.png',
'http://ii.sinelinked.com/miniProgramAssets/compass/pan.png'
]
var num = 0
change.addEventListener('touchstart', function() {
this.children[0].classList.add('active')
})
change.addEventListener('touchend', function() {
num++
if (num >= panBg.length) {
num = 0
}
compass.src = panBg[num]
this.children[0].classList.remove('active')
})
</script>
</body>
</html>