05-19 11:52:51.622: ERROR/MediaPlayer(1291): prepareAsync called in state 8
05-19 11:52:51.622: WARN/System.err(1291): java.lang.IllegalStateException
try {
mp = MediaPlayer.create(
Main.this,
Uri.parse("http://codejanitor.us/good.mp3"));
mp.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
try {
mp.prepareAsync();
} catch (IllegalStateException e) {
e.printStackTrace();
}
} finally {
if (mp != null) {
mp.release();
mp = null;
}
}
交替
如果我做:
try {
mp = MediaPlayer.create(
AmazonClipActivity.this,
Uri.parse("http://codejanitor.us/good.mp3"));
mp.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
} finally {
if (mp != null) {
mp.release();
mp = null;
}
}
我得到:
05-19 12:22:57.472: DEBUG/MediaPlayer(1635): Couldn't open file on client side, trying server side
05-19 12:22:57.472: INFO/StagefrightPlayer(68): setDataSource('http://codejanitor.us/good.mp3')
05-19 12:22:57.482: INFO/NuHTTPDataSource(68): connect to codejanitor.us:80/good.mp3 @0
05-19 12:23:00.632: INFO/NuCachedSource2(68): ERROR_END_OF_STREAM