Marcin S.
Marcin S.

Reputation: 11191

MediaPlayer error when attempt to play from a stream

Does anybody know what does the second argument mean from this error (1, -2147483648) in MediaPlayer? I constantly receive it when attempting to play an audio from a url stream. I try to play it from a class that extends BaseExpandableListAdapter if that matter. I have already reviewed this post Android MediaPlayer error: MediaPlayer error(1, -2147483648) on Stream from internet however all the answers refers to the stream support issues. It's not a stream support issue in my case since I am able to play an audio from the same stream but just using a different class. This is a method that I'm using for playing:

private void startPlaying(String fileName) {
    mediaPlayer = new MediaPlayer();

    try {
        if (fileInputStream != null) {  // Read a file from a fileInputStream from a filesystem (EXTERNAL OR INTERNAL storage)
            mediaPlayer.setDataSource(fileInputStream.getFD());
            Log.d("MediaPlayer is playing", "from device");

        } else {
    //      mediaPlayer = new MediaPlayer();
            mediaPlayer.setDataSource(getFilePath());   // Read a file from a url
            Log.d("MediaPlayer is playing", "from stream");             
        }
        mediaPlayer.prepare();
        mediaPlayer.start();
        mediaPlayer.setOnCompletionListener(new CompletionListener());


    } catch (IOException e) {
        Log.e(LOG_TAG, "prepare() failed");
    }
}

Upvotes: 0

Views: 3535

Answers (1)

Anup Cowkur
Anup Cowkur

Reputation: 20563

The error is usually one of these in this case:

  1. File path is in error. Incorrect directory or Url or Uri found.
  2. Media file is in error, incompatible format.
  3. Missing permissions

Here's a good blog that outlines these situations and how to fix them:

http://www.weston-fl.com/blog/?p=2988

Also see this thread:

Android mediaplayer MediaPlayer(658): error (1, -2147483648)

Upvotes: 2

Related Questions