問題描述
我目前正在嘗試創建一個測試站點,允許用戶記錄語音筆記并將其保存到他們的帳戶中.使用 PHP 或 JavaScript 執行此操作的最佳方法是什么?
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) 用戶點擊錄制按鈕.2) 啟動記錄序列.3) 停止序列.4) 命名文件并將其發送到服務器.
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.
我的主要查詢集中在第二步,在這里我需要某種機制來與用戶的麥克風交互以錄制語音.我對網絡開發本身還是個新手,我不知道如何使用 JavaScript 調用錄音.
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.
在 Google 中搜索后,我在 StackOverflow 中找到了一些解決類似問題的鏈接,但答案沒有幫助.許多解決方案都指向 Flash,但我想盡可能避免這種情況.所以我的問題確實歸結為是否可以使用 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?"
提前致謝.
推薦答案
HTML5 音頻 API 在瀏覽器中并未得到廣泛支持,我認為它適用于 Chrome,而 Firefox 最近已將它添加到它的 nightlies ... 瀏覽器前綴是此階段需要,但通用 API 是...
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 */ });
那么對于 Chrome 來說就是 webkitGetUserMedia
,對于 Firefox 來說就是 mozGetUserMedia
.
So that would be webkitGetUserMedia
for Chrome and mozGetUserMedia
for Firefox.
您現在更一致的選擇是通過瀏覽器插件(例如 Flash 或 Java)或創建用戶需要安裝的桌面客戶端.
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.
有關 getUserMedia 的相關資源:
Resources of interest regarding getUserMedia:
- getUserMedia 簡介
- getUserMedia 添加到 Firefox nightlies
- Chromium 中 getUserMedia 的純音頻問題莉>
以下問題可能會進一步幫助您:
The following question may assist you further:
教程使用 flash 或 java servlet 將麥克風數據從瀏覽器上傳到服務器?
這篇關于如何使用 Javascript/PHP 錄制用戶的聲音?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!