-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
54 lines (50 loc) · 1.63 KB
/
index.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 http-equiv="X-UA-Compatible" content="IE=edge">
<title>MJPG-streamer Button</title>
<meta charset="utf-8">
<meta name="description" content="MJPG-streamer カメラをブラウザから起動/終了させる デモ">
<meta name="author" content="Home Made Garbage">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
<!--[if lt IE 9]>
<script src="//cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="shortcut icon" href="">
</head>
<body>
<button type="button" id="cameraOpen">ON</button>
<button type="button" id="cameraClose">OFF</button>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
function postMjpgStreamer(action) {
var url = 'mjpg-streamer.php?action=' + action; // リクエスト先URL
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onreadystatechange = function () {
if (xhr.readyState != 4) {
// リクエスト中
} else if (xhr.status != 200) {
// 失敗
alert('失敗しました。もう一回試してみてね!');
} else {
// 取得成功
alert(xhr.response);
window.location.reload() ;
}
};
xhr.send(null);
}
document.getElementById('cameraOpen').addEventListener('click' ,function() {
postMjpgStreamer('open');
}
,false);
document.getElementById('cameraClose').addEventListener('click' ,function() {
postMjpgStreamer('close');
}
,false);
</script>
</body>
</html>