-
Notifications
You must be signed in to change notification settings - Fork 108
Home
Michał Stocki edited this page Aug 30, 2014
·
1 revision
Welcome to the FlashWavRecorder wiki!
One of the most frequent questions is about uploading recording to server without user interaction. For many reasons present solution (forcing user to click Flash button) is inconvenient. In modern browsers we can send recorded audio using JavaScript.
var blob = FWRecorder.getBlob("recording_name"); // 1
var fd = new FormData();
fd.append("format", "json"); // 2
fd.append("field_name", blob, "recording_name.wav"); // 3
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost/FlashWavRecorder/html/upload.php"); // 4
xhr.send(fd);
- First of all we have to convert data, recorded by Flash to Blob object. We use a name of the recording - the same we've used to start recording (
FWRecorder.record("recording_name")
). - We specify the format of response we expect from server.
-
"field_name"
is the field of virtual form, we send to server. This is the same name we have to provide, when we set up FlashWavRecorder for saving file with traditional method. To make it work withhtml/upload.php
script - use"upload_file"
. We can also putrecording_name.wav
(optionally) - this is the name under which recording will appear on the server. - The request url.
Note that for using this solution, your browser has to support File API, XMLHttpRequest2 and Blob constructing.
Supported browsers: IE 10+, Firefox 13+, Chrome 20+, Safari 6+, iOS Safari 6.1+, Android browser 3+ (support uncertain).