1
我想紛至沓來的Android的音頻文件,但每次我得到這個例外如何流音頻文件的Android
產生java.io.IOException:準備失敗:狀態=爲0x1
爲我的歌曲鏈接存儲在服務器上。例如(http://Touchstoneesol.com/listen/ML1 (Section 2).mp3);
但是相同的碼流正確鏈接(http://android.programmerguru.com/wp-content/uploads/2013/04/hosannatelugu.mp3);
現在我陷入了介於代碼中的問題還是我的歌曲鏈接已損壞。
buttonPlay = (Button) findViewById(R.id.play);
buttonPlay.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mPlayer = new MediaPlayer();
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mPlayer.setDataSource(url);
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (SecurityException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IllegalStateException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
try {
mPlayer.prepare();
} catch (IllegalStateException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
}
mPlayer.start();
}
});
你可以在這裏測試:http://demo.jwplayer.com/stream-tester/如果你的流鏈接正在工作。 – WannaBeGeek
謝謝,刪除了問題,請務必刪除url中的空白空間。謝謝。 –