问题
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,
回答1:
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.
来源:https://stackoverflow.com/questions/15507398/android-mediaplayer-play-m3u8-only-audio-streamming