0
我想從服務器流式傳輸音頻內容(AAC)。玩家啓動沒有任何問題,並在一段時間後拋出OutOfMemoryError。我想我需要緩衝音頻。任何人都請指導我實施(或擺脫此錯誤)緩衝。音頻流出OutOfMemoryError
這是我的代碼。
`HttpConnection c = null;
InputStream is = null;
try {
c = (HttpConnection) Connector.open(streamURL,
Connector.READ_WRITE);
int rc = c.getResponseCode();
System.out.println("Response Code " + rc);
if (rc != HttpConnection.HTTP_OK) {
showAlert("Server error returned");
} else {
playerForm.append("openInputStream");
is = c.openInputStream();
player = Manager.createPlayer(is, "audio/aac");
player.realize();
// get volume control for player and set volume to max
VolumeControl vc = (VolumeControl) player.getControl("VolumeControl");
if(vc != null)
{
vc.setLevel(100);
}
player.prefetch();
player.start();
}
} catch (Exception f) {
playerForm.append("Exception in player " + f.getMessage() + "\n");
} finally { // Aufräumarbeiten ausführen
if (is != null)
try {
is.close();
} catch (IOException e) {
}
if (c != null)
try {
c.close();
} catch (IOException e) {
}
}`
在此先感謝。
Regards Anish。