2012-02-25 74 views
0

我有一個非常簡單的使用MediaRecorder錄製音頻的活動。基本起動/停止功能爲什麼MediaRecorder輸出文件被切斷

// start 
recorder.prepare(); 
recorder.start(); 

// stop 
recorder.stop(); 
recorder.release(); 
recorder = null; 

我在BLOB數據存儲通過org.apache.http.client.methods.HttpPost通過輸出文件到谷歌應用程序引擎。

// AsyncTask doInBackground 
HttpClient httpclient = new DefaultHttpClient(); 
HttpPost httppost = new HttpPost(DEV_SERVER); 
ByteArrayOutputStream outstream = new ByteArrayOutputStream(); 
MultipartEntity reqEntity = new MultipartEntity(
    HttpMultipartMode.BROWSER_COMPATIBLE); 
ContentResolver cr = getContentResolver(); 

InputStream audio_is = cr.openInputStream(working_uri); 
int nRead; 
byte[] data = new byte[16384]; 
while ((nRead = audio_is.read(data, 0, data.length)) != -1) { 
    outstream.write(data, 0, nRead); 
} 
outstream.flush(); 
ByteArrayBody body = new ByteArrayBody(outstream.toByteArray(), 
    POST_TEMP_FILENAME); 
reqEntity.addPart("uploaded", body); 
httppost.setEntity(reqEntity); 
httpclient.execute(httppost); 

結果是SD卡上的完整文件,但是當文件存儲在服務器上時,它已損壞。

是否有可能我沒有正確讀取字節?或者更多的是Google App Engine沒有正確存儲Blob的問題?

這裏是接收Python代碼:

def post(self): 
    entry = models.Entry() 
    entry.content = db.Blob(self.request.get("uploaded")) 
    entry.put(); 

回答

0

原來一切工作就好了。這是我的桌面播放器VLC沒有正確解碼文件。 AMR/3GP音頻太可怕了。

相關問題