如何使用Javascript / PHP记录用户的声音? [英] How can I record a user's voice using Javascript/PHP?

查看:153
本文介绍了如何使用Javascript / PHP记录用户的声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在设立一个测试网站,允许用户录制语音记录并将其保存到他们的帐户。什么是使用PHP或JavaScript做到这一点的最好方法?



我期待这个过程的步骤是:

1)用户点击录制按钮。
2)开始记录序列。
3)停止序列。
4)将文件命名并发送到服务器。



我的主要查询主要关注第二步,在那里我需要一些与用户的麦克风互动来记录声音的机制。我本身对web开发本身并不陌生,我不知道如何使用JavaScript调用语音录制。

在Google中搜索时,我发现StackOverflow中的一些链接解决了类似的问题,但答案没有帮助。许多解决方案都指向了Flash,但是我希望尽可能避免这种情况。所以我的问题归结为是否有可能使用JavaScript录制声音?如果是的话,怎么样?



感谢您提前。
HTML5 Audio API在浏览器中没有得到广泛的支持,我认为它可以在Chrome浏览器中运行,而且Firefox最近也加入了它的夜晚...浏览器前缀是({audio:true},function(stream)), { /* 做东西 */ });

因此,对于Chrome将是 webkitGetUserMedia 您可以通过浏览器插件(例如Flash或Java)创建更一致的选项,或者创建一个或多个浏览器插件

关于getUserMedia的资源:



以下问题可能会进一步帮助您:

>

I am currently trying to make a test site that allows users to record voice-notes and save it to their account. What is the best way to do this using either PHP or JavaScript?

The steps that I am looking to have for this process are:

1) User clicking the record button. 2) Initiation of the recording sequence. 3) Stopping the sequence. 4) Naming of the file and sending it over to the server.

My main query is focused on the 2nd step, where I'd need some mechanism that would interact with the user's mic to record the voice. I am still new to web dev per se and I do not know how I can invoke voice recording using JavaScript.

Upon searching in Google, I found some links in StackOverflow which addressed similar issues but the answers were not helpful. A lot of solutions pointed to Flash but I would like to avoid that as much as possible. So my question does boil down to "Is it possible to record voice using JavaScript? If yes, how?"

Thanks in advance.

解决方案

The HTML5 Audio API is not widely supported in browsers, I think it works in Chrome and Firefox has had it recently added to its nightlies... Browser prefixes are required at this stage but the general API is...

navigator.getUserMedia({audio: true}, function(stream) { /* do stuff */ });

So that would be webkitGetUserMedia for Chrome and mozGetUserMedia for Firefox.

Your more consistent options right now are via browser plugins such as Flash or Java or to create a desktop client that the user would need to install.

Resources of interest regarding getUserMedia:

The following question may assist you further:

tutorial on using flash or java servlet to upload microphone data from browser to server?

这篇关于如何使用Javascript / PHP记录用户的声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆