-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebsocketclient_demo.html
41 lines (39 loc) · 1.05 KB
/
websocketclient_demo.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>RemoteControl demo</title>
<style type="text/css">
.buttons {
font-size: 1em;
display: flex;
justify-content: center;
}
.button {
padding: 2rem;
border: medium solid;
min-height: 1em;
min-width: 1em;
cursor: pointer;
user-select: none;
}
</style>
</head>
<body>
<div class="buttons">
<div class="play button">Play</div>
<div class="pause button">Pause</div>
</div>
<script>
var websocket = new WebSocket("ws://localhost:8081/");
var play = document.querySelector('.play')
var pause = document.querySelector('.pause')
play.onclick = function (event) {
websocket.send(JSON.stringify({button: 'press_play'}));
}
pause.onclick = function (event) {
websocket.send(JSON.stringify({button: 'press_pause'}));
}
</script>
</body>
</html>