admin管理员组文章数量:1313925
I know that getUserMedia() wont be supported in a few browsers so I have to use more or less a flash based audio recorder. Its very important for me to upload the captured audio to a server via POST even if I could get access to the clientside captured audio would be pretty awesome. So do you guys know a libary/plugin/extension to do this?
I found some scripts as well like:
.js/
But the upload doesnt work. I dont know how I could continue.
I know that getUserMedia() wont be supported in a few browsers so I have to use more or less a flash based audio recorder. Its very important for me to upload the captured audio to a server via POST even if I could get access to the clientside captured audio would be pretty awesome. So do you guys know a libary/plugin/extension to do this?
I found some scripts as well like:
https://github./mattdiamond/Recorderjs
https://github./jwagener/recorder.js/
But the upload doesnt work. I dont know how I could continue.
Share Improve this question asked Jan 26, 2014 at 16:41 spyfxspyfx 1,3514 gold badges16 silver badges25 bronze badges 5- Since you are using flash, why not program the flash app to upload it using Actionscript – Patrick Evans Commented Jan 26, 2014 at 16:43
- Isnt worth, I need to do it clientside because I need to show a progressbar as well. Cant start do develop a plete flash app to finish this... – spyfx Commented Jan 26, 2014 at 16:49
- well flash is clientside, but ok, you said you used the two libs listed what errors did you get when trying to upload. – Patrick Evans Commented Jan 26, 2014 at 16:52
- Wrong explanation on my side, yea flash is clientside, but I would prefer to make use of javascript/html5 – spyfx Commented Jan 26, 2014 at 16:57
- im still getting an - uncaught exception: Error in Actionscript. Use a try/catch block to find error. Its kinda weird. It works at home, but not at the university – spyfx Commented Jan 28, 2014 at 12:46
1 Answer
Reset to default 5You can save the recorded data as a blob and then use a FileReader to upload the data via POST with AJAX.
Something similar along these lines:
function uploadAudio(mp3Data){
var reader = new FileReader();
reader.onload = function(event){
var fd = new FormData();
var mp3Name = encodeURIComponent('audio_recording_' + new Date().getTime() + '.mp3');
console.log("mp3name = " + mp3Name);
fd.append('fname', mp3Name);
fd.append('data', event.target.result);
$.ajax({
type: 'POST',
url: 'upload.php',
data: fd,
processData: false,
contentType: false
}).done(function(data) {
//console.log(data);
log.innerHTML += "\n" + data;
});
};
reader.readAsDataURL(mp3Data);
}
This code is taken directly from the gitHub project Recordmp3js available here: https://github./nusofthq/Recordmp3js
It records audio and saves it MP3 format using just HTML5 and JS and then uploads the data on the webserver.
It only works on Chrome and Firefox though.
本文标签: javascriptRecord and upload (to server) audio with HTML5FlashStack Overflow
版权声明:本文标题:javascript - Record and upload (to server) audio with HTML5Flash - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741922206a2405070.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论