1

Hi all and thanks in advance,

After all day looking, searching and trying i do not know if it is even possible, or if the problem is in the code, or if the problem is in the server....

First of all, can MediaPlayer play a m3u8 file?

In case Yes...it is only in versions greater than 3.0 or 4.0?

if i just try to play the url in a real device 4.0.4 i get error (1,-1010) or error 100 or -214.... The code is simple:

MediaPlayer mp = new MediaPlayer();
fich="http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"; //e.g.
mp.setDataSource(localContext, Uri.parse(fich));
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
mp.setVolume(((float)volumenAudio / 100), ((float)volumenAudio / 100));
mp.prepare();

Is there a base error in my way of doing this? something i do not know?

Best regards and thanks,

Rako
  • 249
  • 1
  • 4
  • 15
  • maybe this could be useful for you http://stackoverflow.com/questions/6198995/how-to-play-m3u8-on-android – mihail Mar 19 '13 at 18:20

1 Answers1

7

To your first question, can MediaPlayer play a m3u8 file?, the answer is Yes. MediaPlayer does support the playback of MP3 playlist files.

To your next question, it is only in versions greater than 3.0 or 4.0?, we need to carefully consider the answer. Android 3.0 a.k.a. HoneyComb is not an open distribution and hence, I am not sure about the answer to your question. It may be supported, but just a guess. The playback of m3u8 files is supported from Android 4.0 / ICS onwards. Please find the link to the source, where the player is created for m3u8 file as http://androidxref.com/4.0.4/xref/frameworks/base/media/libmediaplayerservice/MediaPlayerService.cpp#583

If you are getting an error as error(1, -1010), it means somewhere in your player, the engine is returning with a ERROR_UNSUPPORTED return code. For reference, you could look into the sources here.

You would have to debug further and localize the problem.

Ganesh
  • 5,880
  • 2
  • 36
  • 54
  • Thanks ganesh...i am getting all time several kind of errors. I do not need this necessarily...so by now i will live without this feature and i will continue connecting with the .mp3 source :) – Rako Mar 25 '13 at 09:39
  • 1
    http://developer.android.com/about/versions/android-3.0-highlights.html suggests it was added in 3.0 _"Applications can now pass an M3U playlist URL to the media framework to begin an HTTP Live streaming session. The media framework supports most of the HTTP Live streaming specification, including adaptive bit rate."_ – Dori Jul 18 '14 at 16:13
  • @Dori.. Thanks for the link. Earlier, `HoneyComb` i.e. Android 3.0 wasn't publicly quoted and hence, I avoided the same. For those who would have signed the NDA, they would have been able to observe the code much earlier. – Ganesh Jul 19 '14 at 13:30