Recording html5 audio
html5-audio, javascript
Solution
Here you can find my example, but it's not working (partly). Because AUDIO recording is not yet implemented to chrome. Thats why you'll get a 404 error, which is says can not find BLOB.
Also there is a form below it is because my aim was sending that BLOB to a php file, but since not working, i can't try. Save it, you may use later.
<audio></audio>
<input onclick="startRecording()" type="button" value="start recording" />
<input onclick="stopRecording()" type="button" value="stop recording and play" />
<div></div>
<!--
<form enctype="multipart/form-data">
<input name="file" type="file" />
<input type="button" value="Upload" />
</form>
-->
<script>
var onFailed = function(e) {
console.log('sorry :(', e);
};
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia ||
var localStream
var audio = document.querySelector('audio');
var stop = document.getElementById('stop');
function startRecording(){
if (navigator.getUserMedia) {
navigator.getUserMedia({audio: true, video: false, toString : function() {return "video,audio";}}, function(stream) {
audio.src = window.URL.createObjectURL(stream);
document.getElementsByTagName('div')[0].innerHTML = audio.src;
localStream = stream;
}, onFailed);
} else {
alert('Unsupported');
//audio.src = 'someaudio.ogg'; // fallback.
}
}
function stopRecording(){
localStream.stop();
audio.play();
}
function sendAudio(){
}
</script>
note: some information and howto for firefox: https://hacks.mozilla.org/2012/07/getusermedia-is-ready-to-roll/
Problem
Is it possible to record sound with html5 yet? I have downloaded the latest canary version of chrome and use the following code: navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.getUserMedia; navigator.getUserMedia({audio: true}, gotAudio, noStream); This then prompts the user to allow audio recording, and if you say "yes" a message appears saying that chrome is recording. However is it possible to access the audio buffer with the raw data in it? I don't seem to be able to find out how. There are suggested specs that havn't been implemented yet does anyone know if it can actually be done on any browser now, and provide instructions?