MediaPlayer,仅视频m3u8 HTML流有效 [英] MediaPlayer, only video m3u8 HTML streams work
问题描述
我正在将MediaPlayer与m3u8音频流一起使用.这将导致出现日志错误消息:Error(1, -1010)
I'm using the MediaPlayer with a m3u8 audio stream. This results in a log error message: Error(1, -1010)
The first argument seems ok when I look at the error codes: https://github.com/android/platform_external_opencore/blob/master/pvmi/pvmf/include/pvmf_return_codes.h
只有-1010
很奇怪.
当我使用苹果视频m3u8
网址时,效果很好!这是网址:
http://devimages.apple.com/iphone/samples/bipbop/gear1 /prog_index.m3u8
When I use the apple video m3u8
url it's working great! This is the url:
http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8
我使用的代码很简单:
MediaPlayer mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource("http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8");
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.prepare();
mediaPlayer.setOnPreparedListener(this);
mediaPlayer.setOnErrorListener(this);
mediaPlayer.setOnCompletionListener(this);
mediaPlayer.start();
} catch (IllegalArgumentException e1) {
e1.printStackTrace();
} catch (IllegalStateException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
有人知道纯音频流是否有限制吗?我使用了多种格式和不同的扩展名.
Does anyone know if there is a limitation for audio only streams? I used multiple formats and different extensions.
其他问题:有人有m3u8音频流的URL,所以我可以测试其他流吗?
Other question: does anyone have an URL of an m3u8 audio stream, so I can test other streams?
推荐答案
我目前隶属于解决这个问题的项目. 现在,我知道这并不能真正回答您的问题,只是出于洞察力,即使在Android 4.0+ M3U8上,支持充其量也充其量,而最糟的情况也很糟糕.
I'm currently attached to a project tackling this very subject. Now I know this doesn't really answer your question, but just for insight, even on Android 4.0+ M3U8 support is spotty at best, awful at worst.
例如:
- Nexus 7在Akmai上失败,可以在UStream上运行
- Droid RAZR在Akmai和UStream上均可使用.
现在缺少通过类扩展来修补库的功能(并且每个其他android次要版本都具有.so),我们发现没有仅SDK/NDK的解决方案;经过一个月的反复试验,我们放弃了该项目(费用太高).
Now short of patching the libraries via class extension (and having .so's for every other android minor version) we found no SDK/NDK-only solution; we gave up after a month of trial and error on our project (too costly).
我们实现的解决方案是:尝试SDK MediaPlayer.如果失败了,请使用基于FFMPEG的播放器(内部开发,以危险,ffplay,android-fplayer和dolphin-player为灵感).
The solution we implemented was: Try the SDK MediaPlayer. If that fails use a FFMPEG based player (developed in-house, using dranger, ffplay, android-fplayer and dolphin-player as inspiration).
这篇关于MediaPlayer,仅视频m3u8 HTML流有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!