-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
192 lines (151 loc) · 6.83 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
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
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- Material Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Customs CSS -->
<link rel="stylesheet" type="text/css" href="styles.css">
<!-- Recoder -->
<script src="recorder.min.js"></script>
<title>Entrainement EAF</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-8 offset-md-2">
<h1 class="text-center">ENTRAINEMENT EAF</h1>
<h3 class="text-center">Test audio</h1>
<div id="enregistrement" class="text-center">
<div id="start_label" style="width:70%;margin:30px auto 10px auto">
Cliquez sur le bouton ci-dessous pour faire un test d'enregistrement de quelques secondes.
</div>
<button type="button" class="btn btn-success btn-lg" id="start"><i class="material-icons">keyboard_voice</i></button>
<div id="stop_label" style="display:none;width:70%;margin:30px auto 10px auto">
Cliquez sur le bouton ci-dessous pour arrêter l'enregistrement.<br /><b>L'arrêt est définitif!</b>
</div>
<button type="button" class="btn btn-secondary btn-lg" id="stopButton" style="display:none"><i class="material-icons">stop</i></button>
<ul id="recordingslist" style="width:380px;margin:40px auto 0px auto"></ul>
<br />
<div class="alert alert-secondary" role="alert" id="log_frame"><pre id="log"></pre></div>
<div id="next" style="display:none">
Si aucun lecteur audio ne s'affiche, vérifiez votre micro et <a href="index.html">réessayez</a>. Faites des tests avec différents navigateurs.<br />
<br />
Si votre enregitrement se lit correctement, le test est positif. Vous pouvez <a href="epreuve.html">débuter l'épreuve</a>.
</div>
</div>
</div>
</div>
</div>
<button id="pause" style="display:none">pause</button>
<button id="resume" style="display:none">resume</button>
<script>
function __log(e, data) {
log.innerHTML += "\n" + e + " " + (data || '');
}
if (!Recorder.isRecordingSupported()) {
__log('<span style="color:red;font-weight:bold">Recording features are not supported in your browser.</span>');
} else {
var recorder = new Recorder({
monitorGain: parseInt(0, 10),
numberOfChannels: parseInt(1, 10),
encoderBitRate: parseInt(64000,10),
encoderSampleRate: parseInt(48000,10),
encoderPath: "encoderWorker.min.js"
});
pause.addEventListener( "click", function(){ recorder.pause(); });
resume.addEventListener( "click", function(){ recorder.resume(); });
stopButton.addEventListener( "click", function(){ recorder.stop(); });
start.addEventListener( "click", function(){
recorder.start().catch(function(e){
__log('Error encountered: ' + e.message );
});
});
recorder.onstart = function(e){
//__log('Recorder is started');
start.disabled = resume.disabled = true;
pause.disabled = stopButton.disabled = false;
$('#start_label').css('display', 'none');
$('#start').css('display', 'none');
$('#stop_label').css('display', 'block');
$('#stopButton').css('display', 'inline');
$('#log_frame').css('display', 'none');
};
recorder.onstop = function(e){
__log('Recorder is stopped');
start.disabled = false;
pause.disabled = resume.disabled = stopButton.disabled = true;
$('#stop_label').css('display', 'none');
$('#stopButton').css('display', 'none');
$('#next').css('display', 'block');
};
recorder.onpause = function(e){
__log('Recorder is paused');
pause.disabled = start.disabled = true;
resume.disabled = stopButton.disabled = false;
};
recorder.onresume = function(e){
__log('Recorder is resuming');
start.disabled = resume.disabled = true;
pause.disabled = stopButton.disabled = false;
};
recorder.ondataavailable = function( typedArray ){
var dataBlob = new Blob( [typedArray], { type: 'audio/ogg' } );
var fileName = "enregistrement.opus";
var url = URL.createObjectURL( dataBlob );
var audio = document.createElement('audio');
audio.controls = true;
audio.src = url;
var link = document.createElement('a');
link.href = url;
link.download = fileName;
link.innerHTML = link.download;
var li = document.createElement('li');
li.appendChild(link);
li.appendChild(audio);
recordingslist.appendChild(li);
};
}
var audio_context = new AudioContext;
var recorder;
function startUserMedia(stream) {
//var input = audio_context.createMediaStreamSource(stream);
__log('<span style="color:green;font-weight:bold">Media stream created.</span>');
// Uncomment if you want the audio to feedback directly
//input.connect(audio_context.destination);
//__log('<span style="color:green;font-weight:bold">Input connected to audio context destination.</span>');
//recorder = new Recorder(input);
__log('<span style="color:green;font-weight:bold">Recorder initialised.</span>');
}
window.onload = function init() {
try {
// webkit shim
window.AudioContext = window.AudioContext || window.webkitAudioContext;
navigator.getUserMedia = ( navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
window.URL = window.URL || window.webkitURL;
audio_context = new AudioContext;
__log('Audio context set up.');
__log('Navigator User Media ' + (navigator.getUserMedia ? '<span style="color:green;font-weight:bold">available.</span>' : '<span style="color:red;font-weight:bold">not present!</span>'));
} catch (e) {
alert('<span style="color:red;font-weight:bold">No web audio support in this browser!</span>');
}
navigator.getUserMedia({audio: true}, startUserMedia, function(e) {
//__log('No live audio input: ' + e);
__log('<span style="color:red;font-weight:bold">No live audio input.</span>');
});
};
</script>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>