html5中音频文件位置,HTML5记录音频到文件(HTML5 record audio to file)

HTML5记录音频到文件(HTML5 record audio to file)

我最终想做的是从用户的麦克风记录,并在文件完成后将文件上传到服务器。 到目前为止,我已经设法使用以下代码对一个元素进行流:

var audio = document.getElementById("audio_preview");

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;

navigator.getUserMedia({video: false, audio: true}, function(stream) {

audio.src = window.URL.createObjectURL(stream);

}, onRecordFail);

var onRecordFail = function (e) {

console.log(e);

}

我该怎么做,记录到文件?

What I ultimately want to do is record from the user's microphone, and upload the file to the server when they're done. So far, I've managed to make a stream to an element with the following code:

var audio = document.getElementById("audio_preview");

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;

navigator.getUserMedia({video: false, audio: true}, function(stream) {

audio.src = window.URL.createObjectURL(stream);

}, onRecordFail);

var onRecordFail = function (e) {

console.log(e);

}

How do I go from that, to recording to a file?

原文:https://stackoverflow.com/questions/16413063

更新时间:2019-11-22 00:36

最满意答案

有一个相当完整的录音演示可在以下网址 : http : //webaudiodemos.appspot.com/AudioRecorder/index.html

它允许您在浏览器中录制音频,然后可以选择导出和下载您录制的内容。

您可以查看该页面的源代码以查找到javascript的链接,但总而言之,有一个Recorder对象包含一个exportWAV方法和一个forceDownload方法。

It allows you to record audio in the browser, then gives you the option to export and download what you've recorded.

You can view the source of that page to find links to the javascript, but to summarize, there's a Recorder object that contains an exportWAV method, and a forceDownload method.

相关问答

回到解决方案。 在文件cordova-plugin-media / blob / master / src / ios / CDVSound.m中,应用以下补丁: // get the audioSession and set the category to allow recording when device is locked or ring/silent switch engaged

if ([self hasAudioSession]) {

i

...

我有完全相同的问题。 我的解决方案:我为audiofile源添加了完整的URL。 不知道为什么,但它有所作为。 这是我的完整代码。 CSS修改只是为了隐藏下载按钮。 但是当我把它拿出来的时候,我没有看到时间表。 很奇怪,但这个代码恰恰适合我。

html5 audio player on iPhone

DownloadButton

If you're just going to download the file,

...

我们现在可以在Chrome for Android Beta(31.0.1650.11)中使用Web Audio输入。 We now have Web Audio input working in Chrome for Android Beta (31.0.1650.11).

这是我最终如何做到这一点,如果这有助于其他任何人: function uploadForm() {

var form = new FormData(document.getElementById("my_form"));

form.append("user_audio_blob", audioBlob);

var request = new XMLHttpRequest();

var async = true;

request.open("POST", "/

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值