I'm trying to stream audio from a URL. The code works fine with other URLs, but in one of those it fails in the OnPrepared
method, returning this error code: (1, -2147483648). I've read some people saying it's because of permissions, but it's a remote file, so I can't set permissions. I've tried the URL with other apps like VLC and iTunes, and it's working fine. My code is here:
private void prepareradio() {
player = new MediaPlayer();
player.setAudioStreamType(MODE_WORLD_READABLE);
try {
player.setDataSource(url);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
player.setOnErrorListener(new OnErrorListener(){
public boolean onError(MediaPlayer arg0, int arg1, int arg2) {
Toast.makeText(getApplicationContext(),"An error happened while preparing radio",Toast.LENGTH_LONG).show();
prepareradio();
playe.setEnabled(true);
hidenot();
return false;
}
});