4

This is the link from which I'm trying to play audio with no luck.

My code is:

MediaPlayer player = new MediaPlayer();
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
    player.setDataSource("http://www.nomadicsmart.com/co-notes/files/testsong_20_sec.mp3");
    //   player .prepare();
    player.prepareAsync();
    player.setOnPreparedListener(new OnPreparedListener() { 
        public void onPrepared(MediaPlayer mp) {
            Log.d("f","media3");
            mp.seekTo(0);
            mp.start();
        }
    });
    //  player .seekTo(0);
    } catch (IllegalArgumentException e1) {
        e1.printStackTrace();
    } catch (SecurityException e1) {
        e1.printStackTrace();
    } catch (IllegalStateException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }
Onik
  • 19,396
  • 14
  • 68
  • 91
Hussnain Azam
  • 358
  • 1
  • 5
  • 14
  • The error seems to suggest some integer is out of bound, since 2147483647 is the max value of an integer. – Menno May 02 '13 at 12:06
  • whats an integer doing in audio file – Hussnain Azam May 02 '13 at 12:14
  • No idea. I have no experience with audio related applications. All i know this exact value is one more than the max (or min in this case) of an integer. Doesn't seem like a coincidence to me. – Menno May 02 '13 at 12:19
  • Check out sturrockad's answer here: http://stackoverflow.com/a/18084143/680488 Where he says: "When looking at the error value (1, -2147483648), the '1' value corresponds to the constant in MediaPlayer.MEDIA_ERROR_UNKNOWN. -2147483648 corresponds to hexadecimal 0x80000000 which is defined as UNKNOWN_ERROR in frameworks/native/include/utils/Errors.h" – jpm Sep 05 '13 at 10:50
  • set minimum api to 11. and then test – shehzy Jul 01 '15 at 11:50
  • In my case, I had Gzip Compression on the web address where the url info is. Compressed media files may not be decoded on android. – İlker Elçora Jun 23 '21 at 08:38

0 Answers0