1
我按照Voice recording method from phonegap的步驟創建了一個語音記錄應用程序。用特定的名稱和格式上傳語音,用戶名爲phonegap
一旦我錄製語音併發送到服務器(http:// {server}/{application}/myservice/register /),其中一些用戶標識和音頻文件名稱爲「talk」,並將其發送爲wav格式。我怎樣才能做到這一點?
我按照Voice recording method from phonegap的步驟創建了一個語音記錄應用程序。用特定的名稱和格式上傳語音,用戶名爲phonegap
一旦我錄製語音併發送到服務器(http:// {server}/{application}/myservice/register /),其中一些用戶標識和音頻文件名稱爲「talk」,並將其發送爲wav格式。我怎樣才能做到這一點?
嗨,你可以使用phonegap FileTransfer方法。 FileTransfer對象允許您上傳或下載文件到服務器和從服務器下載文件。 如:
// !! Assumes variable fileURI contains a valid URI to a text file on the device
var win = function (r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
}
var fail = function (error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
options.mimeType = "text/plain";
var params = {};
params.value1 = "test";
params.value2 = "param";
options.params = params;
var ft = new FileTransfer();
ft.upload(fileURI, encodeURI("http://some.server.com/upload.php"), win, fail, options);
我認爲這可以幫助你更多信息檢查link
感謝您reply..In這個方法我在哪裏可以轉換爲WAV格式的.. – Ben10
在IOS?或android ?,並檢查音頻的默認格式,我thnk的默認格式是.amr?我th轉換音頻文件爲wav你需要編寫本地插件。沒有默認的方法在phonegap @ SKM17 –
在android之前上傳我轉換音頻爲wav格式 – Ben10