3

I am developing an android application for android OS > 4.0 (including and post OS). I have a sample m3u8 file as follows :

#EXTM3U
#EXT-X-TARGETDURATION:56
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:28, no desc
ulr/audio/file.mp3
#EXTINF:28, no desc
ulr/audio/file.mp3
#EXT-X-ENDLIST

and I am trying to play that file, using the following code

mMediaPlayer = new MediaPlayer();
mMediaPlayer.setOnErrorListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try
{
    mMediaPlayer.setDataSource(uri);
} catch (IllegalArgumentException e)
{
    e.printStackTrace();
} catch (SecurityException e)
{
    e.printStackTrace();
} catch (IllegalStateException e)
{
    e.printStackTrace();
} catch (IOException e)
{
    e.printStackTrace();
}
mMediaPlayer.prepareAsync();

and my onPrepared() method is as follows :

public void onPrepared(MediaPlayer player)
    {
        player.start();
    }

But the code first comes to onPrepared() and then immediately goes to onError(), with the what=1 and the extra=-1010.

I know this question has been asked various times (here, here and here for instance) and I also know about Vitamio, but i want to find out what is wrong with my implementation. Is there something wrong with the m3u8 file that I created? I went through its documentation and everything seems correct.

Would be really glad if someone could throw some light in this matter.

smitop
  • 4,770
  • 2
  • 20
  • 53
Antrromet
  • 15,294
  • 10
  • 60
  • 75

1 Answers1

0

Error code -1010 matches up with MEDIA_ERROR_UNSUPPORTED which would imply that the device does not have the hardware or software codecs it needs to decode the MP3 files in your playlist.

Vitamio would work in this situation because it adds software decoding for the media. This is slower than hardware decoding and uses more battery. It can also increase your app size significantly.

This seems odd, though, since MP3 has been a supported media format for decoding in Android for a very long time.

Buns of Aluminum
  • 2,439
  • 3
  • 26
  • 44
  • Its been very long since I asked this question. Yet, as you said MP3 was definitely supported by the device as when they were played individually they used to play. – Antrromet Sep 10 '14 at 05:20
  • I've been having the same issue with an m3u8 stream containing AAC-LC format files. Google says AAC-LC decoding should be supported by all android devices, but I still get the -1010 error consistently on some of them. I'm currently just catching the error and then offering an option to the user to attempt to open the stream using another app on their phone (via intent). – Buns of Aluminum Sep 10 '14 at 12:40