-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
159 lines (140 loc) · 5.43 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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!doctype html>
<html>
<head>
<title>Schrodinger Hat - OBS sound pad</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: 'Arial', sans-serif;
background-size: cover;
margin: 0;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
color: #fff;
}
h1 {
color: #fff;
text-align: center;
padding: 1em;
background: rgba(0, 0, 0, 0.25);
margin: 0 0 1em 0;
display: inline-block;
}
h2 {
text-align: center;
color: #fff;
font-size: 1.2em;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}
.button-container {
margin: 0 auto;
width: 500px;
text-align: center;
background: rgba(0, 0, 0, 0.25);
padding: 20px 0;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 6px;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.5);
}
button.button {
width: 100px;
height: 100px;
margin: 5px;
vertical-align: top;
border: 3px solid rgba(255, 255, 255, 0.5);
background: rgba(247, 28, 64, 0.6);
color: #fff;
font-size: 1.5em;
border-radius: 5px;
box-shadow: 1px 1px 2px rgba(144, 116, 137, 0.6);
}
button.button:hover {
background: rgba(101, 188, 190, 0.64);
border: 3px solid #ccc;
transition: background 0.2s ease-in-out, border 0.2s linear;
color: #fff;
box-shadow: 2px 2px 9px rgba(222, 211, 219, 0.54);
cursor: pointer;
}
#stop {
width: 100px;
height: 100px;
margin: 5px;
border: 3px solid rgba(255, 255, 255, 0.5);
background: rgb(255, 0, 43);
color: #fff;
font-size: 2em;
border-radius: 5px;
box-shadow: 1px 1px 2px rgba(144, 116, 137, 0.6);
}
#stop:hover {
background: rgba(101, 188, 190, 0.64);
border: 3px solid #ccc;
transition: background 0.2s ease-in-out, border 0.2s linear;
color: #fff;
box-shadow: 2px 2px 9px rgba(222, 211, 219, 0.54);
cursor: pointer;
}
</style>
</head>
<body>
<div class="button-container">
<button data-src="nuclear-alarm" class="button">bomba</button>
<button data-src="applause" class="button">clap</button>
<button data-src="drum-roll" class="button">drum roll</button>
<button data-src="joke-drum" class="button">joke drum</button>
<button data-src="sad-trumpet" class="button">fail</button>
<button data-src="crowd-laugh" class="button">crowd laugh</button>
<button data-src="evil-laugh" class="button">evil laugh</button>
<button data-src="hadouken" class="button">hadouken</button>
<button data-src="shoryuken" class="button">shoryuken</button>
<button data-src="wtf" class="button">wtf</button>
<button data-src="phone" class="button">phone</button>
<button data-src="thunder" class="button">thunder</button>
<button data-src="coso.mp3" class="button">12</button>
<button data-src="coso.mp3" class="button">13</button>
<button data-src="coso.mp3" class="button">14</button>
<button data-src="coso.mp3" class="button">15</button>
</div>
<!--
<br />
<textarea rows="3" cols="10" id="google-text"></textarea>
<button id="send-google">Play Google</button>
-->
<br/>
<center>
<button id="stop">STOP</button>
</center>
<script src="https://cdn.jsdelivr.net/npm/socket.io-client@2/dist/socket.io.js"></script>
<script>
window.addEventListener('DOMContentLoaded', function () {
var audio = new Audio();
var socket = io();
socket.on('play-audio', function (src) {
console.log("arrivato: " + src);
audio.src = src;
audio.pause();
audio.play();
});
socket.on('stop-audio', function () {
audio.pause();
});
document.getElementById('stop').addEventListener('click', function () {
socket.emit('stop-audio');
});
// da capire come farlo funzionare nel caso
/*document.getElementById('send-google').addEventListener('click', function () {
var text = encodeURIComponent(document.getElementById('google-text').value);
socket.emit('play-audio', 'https://translate.google.com/translate_tts?ie=UTF-8&q='+ text +'&tl=it-IT&client=tw-ob')
});*/
var buttons = document.querySelectorAll('.button');
for(var i = 0; i < buttons.length - 1; i++) {
console.log(buttons[i].getAttribute('data-src'));
buttons[i].addEventListener('click', function () {
socket.emit('play-audio', '/assets/sounds/' + this.getAttribute('data-src') + '.mp3');
});
}
});
</script>
</body>
</html>