-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudios.html
More file actions
401 lines (351 loc) · 14.5 KB
/
audios.html
File metadata and controls
401 lines (351 loc) · 14.5 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ANECDOTAS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Firebase -->
<script src="https://www.gstatic.com/firebasejs/9.9.0/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.9.0/firebase-storage-compat.js"></script>
<!-- Bootstrap CSS (opcional) -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<!-- CSS Personalizado -->
<style>
@font-face {
font-family: 'Level Up Level Up';
src: url('./fonts/Level Up Level Up.otf') format('truetype');
}
body {
background: url('https://github.com/daantesiito/daantesiito.github.io/blob/main/images/MinecraftFondo.gif?raw=true') no-repeat center center fixed;
background-size: cover;
color: #999;
font-family: 'Level Up Level Up', sans-serif;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
h2, h3 {
color: white;
font-size: 7em; /* Tamaño de fuente predeterminado para computadoras */
font-family: 'Level Up Level Up', sans-serif;
text-shadow: 2px 2px 5px #000, -2px 2px 5px #000, 2px -2px 5px #000, -2px -2px 5px #000;
margin: 0.05em 0; /* Ajuste de margen */
}
/* Media query para dispositivos móviles con ancho máximo de 600px (ajustar según necesidades) */
@media (max-width: 600px) {
h2, h3 {
font-size: 1.99em; /* Tamaño de fuente ajustado para dispositivos móviles */
}
}
h4, h5 {
color: white;
font-family: 'Raleway', sans-serif;
text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
margin: 0.5em 0; /* Ajuste de margen */
}
#uploadForm {
margin-bottom: 20px;
text-align: center;
font-family: 'Raleway', sans-serif;
}
#uploadForm input[type="text"] {
margin: 5px;
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
outline: none;
}
#uploadForm button,
#imageInput {
padding: 10px 20px;
background-color: #4CAF50;
font-family: 'Raleway', sans-serif;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
outline: none;
margin: 5px;
}
#uploadForm button:hover,
#imageInput:hover {
background-color: #45a049;
}
#imageUploadForm button{
padding: 10px 20px;
background-color: #4CAF50;
font-family: 'Raleway', sans-serif;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
outline: none;
margin: 5px;
}
#controls {
margin-top: 20px;
color: black;
font-family: 'Raleway', sans-serif;
text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
}
#controls button {
padding: 10px 20px;
margin: 5px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
outline: none;
}
#imageInput {
padding: 10px 20px;
margin: 5px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
outline: none;
}
#controls button:hover {
background-color: #45a049;
}
#audioPlayer {
width: 100%; /* Ocupa todo el ancho disponible */
max-width: 300px; /* Ancho máximo para evitar que se extienda demasiado */
margin: 20px auto; /* Centrado horizontal */
text-align: center;
}
#confirmButton {
color: black;
font-family: 'Raleway', sans-serif;
display: block;
margin: 20px auto 0;
padding: 10px 20px;
}
#recordingMessage {
font-size: 1.2em;
color: white;
font-family: 'Raleway', sans-serif;
text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
display: none;
}
#warningMessage {
color: white;
font-family: 'Raleway', sans-serif;
text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
text-align: center;
margin: 10px 0;
display: none;
}
.center-content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
#imageUploadForm,
#textInputForm {
margin-top: 20px;
}
#textInputForm textarea {
width: 80%;
max-width: 500px;
margin-bottom: 10px;
padding: 10px;
border-radius: 10px;
border: 1px solid #fff;
background: rgba(255, 255, 255, 0.2);
color: #fff;
outline: none;
font-family: 'Roboto', sans-serif;
font-size: 1em;
}
#textInputForm button {
padding: 10px 20px;
margin: 5px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
outline: none;
}
</style>
</head>
<body>
<!-- Textos Agregados -->
<div>
<h2>ANECDOTAS</h2>
</div>
<div>
<h3>PARANORMALES</h3>
</div>
<div>
<h4>El boton "ELEGIR IMAGEN" sirve para adjuntar imagenes relacionadas a la historia.</h4>
</div>
<!-- Formulario para la grabación de audio -->
<form id="uploadForm">
<input type="text" id="username" placeholder="Username" required>
<button type="button" onclick="startRecording()">Comenzar a Grabar</button>
<button type="button" id="chooseImageButton" onclick="showImageUpload()">Elegir Imagen</button>
<button type="button" id="writeStoryButton" onclick="showTextInput()">Escribir Historia</button>
</form>
<div id="controls" style="display: none;">
<div id="recordingMessage">Grabando...</div>
<button id="stopButton" onclick="stopRecording()">Detener</button>
<audio id="audioPlayer" controls style="display:none;"></audio>
<div class="center-content">
<div id="warningMessage">Si el audio no tiene sonido no te preocupes que se grabó bien. Por permisos de navegador no te deja reproducirlo en algunos celulares.</div>
<button id="confirmButton" style="display: none;" onclick="confirmAndUploadAudio()">Confirmar Audio y Enviar</button>
</div>
</div>
<div id="anonymInstructions">
<div>
<h4>Si queres mandar un audio ANONIMO, inserta de usuario "ANONIMO".</h4>
</div>
<div>
<h5>Tene en cuenta que si es ANONIMO y mandas mas de 1 audio, tenes que poner alguna palabra clave.</h5>
</div>
<div>
<h5>Pone "ANONIMO" + "PALABRA CLAVE" + "NUMERO DE AUDIO" que haga referencia a tu audio.</h5>
</div>
</div>
<!-- Formulario para la carga de imágenes -->
<div id="imageUploadForm" style="display: none;">
<input type="file" id="imageInput" accept="image/*">
<button type="button" onclick="confirmAndUploadImage()">Confirmar y Enviar Imagen</button>
</div>
<div id="textInputForm" style="display: none;">
<textarea id="textInput" rows="10" cols="30" placeholder="Escribe tu historia aquí..."></textarea>
<button type="button" onclick="this.disabled = true; uploadText()">Enviar</button>
</div>
<!-- Firebase -->
<script>
// Configuración de Firebase
const firebaseConfig = {
apiKey: "AIzaSyBlsZmRgBEGkzgT3_c00CbEBqzYnVf4oYk",
authDomain: "audiosweb-74dc8.firebaseapp.com",
projectId: "audiosweb-74dc8",
storageBucket: "audiosweb-74dc8.appspot.com",
messagingSenderId: "865220172127",
appId: "1:865220172127:web:54f3bf705dbae82b22feea",
measurementId: "G-CTFJN6PC37"
};
// Inicializar Firebase
firebase.initializeApp(firebaseConfig);
let mediaRecorder;
let audioChunks = [];
let audioBlob;
function startRecording() {
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({ audio: true })
.then(function(stream) {
mediaRecorder = new MediaRecorder(stream);
mediaRecorder.ondataavailable = event => {
audioChunks.push(event.data);
};
mediaRecorder.onstop = () => {
audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
const audioUrl = URL.createObjectURL(audioBlob);
const audioPlayer = document.getElementById('audioPlayer');
audioPlayer.src = audioUrl;
audioPlayer.style.display = 'block';
document.getElementById('confirmButton').style.display = 'block';
document.getElementById('warningMessage').style.display = 'block'; // Mostrar el mensaje de advertencia después de grabar
// Ocultar el texto de instrucciones y el botón de detener
document.getElementById('anonymInstructions').style.display = 'none';
document.getElementById('stopButton').style.display = 'none';
};
audioChunks = []; // Limpiar el array antes de empezar una nueva grabación
mediaRecorder.start();
document.getElementById('uploadForm').style.display = 'none';
document.getElementById('controls').style.display = 'block';
document.getElementById('stopButton').disabled = false;
document.getElementById('recordingMessage').style.display = 'block';
document.getElementById('anonymInstructions').style.display = 'none';
}).catch(function(err) {
alert('Error al acceder al micrófono: ' + err.message);
});
} else {
alert('getUserMedia no es soportado en este navegador.');
}
}
function stopRecording() {
mediaRecorder.stop();
document.getElementById('stopButton').disabled = true;
document.getElementById('recordingMessage').style.display = 'none';
}
function showImageUpload() {
document.getElementById('uploadForm').style.display = 'none';
document.getElementById('anonymInstructions').style.display = 'none';
document.getElementById('imageUploadForm').style.display = 'block';
}
async function confirmAndUploadAudio() {
const username = document.getElementById('username').value;
if (username) {
const storageRef = firebase.storage().ref();
const timestamp = Date.now();
const audioRef = storageRef.child(`Mari/audios/${username}.wav`);
try {
await audioRef.put(audioBlob);
alert('Audio subido exitosamente.');
location.reload(); // Recargar la página después de la subida exitosa
} catch (error) {
alert('Error al subir el audio: ' + error.message);
}
} else {
alert('Por favor complete todos los campos.');
}
}
async function confirmAndUploadImage() {
const file = document.getElementById('imageInput').files[0];
const username = document.getElementById('username').value;
if (file && username) {
const storageRef = firebase.storage().ref();
const timestamp = Date.now();
const imageRef = storageRef.child(`Mari/imagenes/${username}_${file.name}`);
try {
await imageRef.put(file);
alert('Imagen subida exitosamente.');
location.reload(); // Recargar la página después de la subida exitosa
} catch (error) {
alert('Error al subir la imagen: ' + error.message);
}
} else {
alert('Por favor complete todos los campos.');
}
}
function showTextInput() {
document.getElementById("textInputForm").style.display = "block";
document.getElementById('uploadForm').style.display = 'none';
document.getElementById('controls').style.display = 'none';
document.getElementById('recordingMessage').style.display = 'none';
document.getElementById('anonymInstructions').style.display = 'none';
}
async function uploadText() {
const username = document.getElementById("username").value;
const textInput = document.getElementById("textInput").value;
const textFileName = `${username}.txt`;
if (textInput && username) {
const blob = new Blob([textInput], { type: 'text/plain' });
const storageRef = firebase.storage().ref().child(`Mari/texto/${textFileName}`);
try {
await storageRef.put(blob);
alert("Texto subido exitosamente.");
location.reload();
} catch (error) {
alert("Error al subir el texto: " + error.message);
}
} else {
alert('Por favor complete todos los campos.');
}
}
</script>
</body>
</html>