0

When I try to play an audio mar form url I receive the error: E/MediaPlayerNative: error (1, -2147483648)

Here is my code:

public void playAudio(final String url){
    try {
        Uri uri = Uri.parse(url);
        MediaPlayer player = new MediaPlayer();
        player.setAudioStreamType(AudioManager.STREAM_MUSIC);
        player.setDataSource(MainActivity.this, uri);
        player.prepare();
        player.start();
    } catch(Exception e) {
        System.out.println(e.toString());
    }

}

What is wrong?

Paolo Colombo
  • 219
  • 5
  • 24
  • This error most probably related to incorrect URL or is not a supported format. I suggest you looking at https://stackoverflow.com/questions/11540076/android-mediaplayer-error-1-2147483648 – Emin Guliev Jan 19 '20 at 11:33
  • I tried with .mp3 format and .m4a but neither work – Paolo Colombo Jan 19 '20 at 23:38

0 Answers0