libvlc Android:无法播放HTTP网络流

5

我目前遇到了一个问题,尝试使用VLC for Android播放网络流。

基本上我按照这个指南https://wiki.videolan.org/AndroidCompile/进行操作,克隆了repo并构建:一切都很好,我可以运行我的应用程序并播放视频(本地或来自网络)。

然后我拿了libvlc AAR并从头开始创建了一个新的Android项目:我能够播放本地视频,但是当我传入URL时,流就无法打开。

相关代码:

// Create LibVLC
ArrayList<String> options = new ArrayList<String>();
options.add("--aout=opensles");
options.add("--audio-time-stretch"); // time stretching
options.add("-vvv"); // verbosity
libvlc = new LibVLC(options);
holder.setKeepScreenOn(true);

// Create media player
mMediaPlayer = new MediaPlayer(libvlc);
mMediaPlayer.setEventListener(mPlayerListener);

// Set up video output
final IVLCVout vout = mMediaPlayer.getVLCVout();
vout.setVideoView(mSurface);
vout.addCallback(this);
vout.attachViews();

Media m = new Media(libvlc, Uri.parse(media));
mMediaPlayer.setMedia(m);
mMediaPlayer.play();

其中media是URL的String

我配置中是否缺少了某些内容(例如模块)?

这是我得到的日志:

D/LibVLCAndroidSample: Playing back http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv
D/Activity: performCreate Call Injection manager
I/InjectionManager: dispatchOnViewCreated > Target : com.compdigitec.libvlcandroidsample.VideoActivity isFragment :false
D/VLC: [ede46778/0] core libvlc: VLC media player - 3.0.0-git Vetinari
D/VLC: [ede46778/5f726f74] core libvlc: Copyright © 1996-2016 the VideoLAN team
D/VLC: [ede46778/190019] core libvlc: revision 2.2.0-git-7900-g640a891
D/VLC: [ede46778/190019] core libvlc: configured with ../configure  '--host=arm-linux-androideabi' '--build=x86_64-unknown-linux' '--enable-neon' '--disable-nls' '--enable-live555' '--enable-realrtsp' '--enable-avformat' '--enable-swscale' '--enable-avcodec' '--enable-opus' '--enable-opensles' '--enable-mkv' '--enable-taglib' '--enable-dvbpsi' '--disable-vlc' '--disable-shared' '--disable-update-check' '--disable-vlm' '--disable-dbus' '--enable-lua' '--disable-vcd' '--disable-v4l2' '--disable-gnomevfs' '--enable-dvdread' '--enable-dvdnav' '--disable-bluray' '--disable-linsys' '--disable-decklink' '--disable-libva' '--disable-dv1394' '--enable-mod' '--disable-sid' '--disable-gme' '--disable-tremor' '--enable-mad' '--disable-dca' '--disable-sdl-image' '--enable-zvbi' '--disable-fluidsynth' '--disable-jack' '--disable-pulse' '--disable-alsa' '--disable-samplerate' '--disable-sdl' '--disable-xcb' '--disable-atmo' '--disable-qt' '--disable-skins2' '--disable-mtp' '--disable-notify' '--enable-libass' '--disable-svg' '--d
D/VLC: [ede46778/eb81c760] core libvlc: plug-ins loaded: 275 modules
D/VLC: [ee93d168/eb81c760] core logger: looking for logger module matching "any": 4 candidates
D/VLC: [ee93d168/10001] core logger: using logger module "android_logger"
D/VLC: [ede46778/2a98] core libvlc: translation test: code is "C"
D/VLC: [ee93d1c8/2a98] core keystore: looking for keystore module matching "memory": 3 candidates
D/VLC: [ee93d1c8/2a98] core keystore: using keystore module "memory"
D/VLC: [ede46778/2a98] core libvlc: CPU has capabilities ARM_NEON FPU 
D/VLC: [ede472d8/2a98] core generic: creating audio output
D/VLC: [f4e4bda8/2a98] core audio output: looking for audio output module matching "opensles": 4 candidates
W/libOpenSLES: class OutputMix interface 0 requested but unavailable MPH=43
D/VLC: [f4e4bda8/2a98] core audio output: using audio output module "opensles_android"
D/VLC: [ede472d8/2a98] core generic: keeping audio output
D/SecWifiDisplayUtil: Metadata value : SecSettings2
D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{22a16c1 I.E...... R.....ID 0,0-0,0}
D/mali_winsys: new_window_surface returns 0x3000,  [1440x2560]-format:1
D/VLC: [ee923df8/2a98] core input: Creating an input for 'jellyfish-3-mbps-hd-h264.mkv'
D/VLC: [ee923df8/2dbb] core input: using timeshift granularity of 50 MiB
D/VLC: [ee923df8/2dbb] core input: using default timeshift path
D/VLC: [ee923df8/2dbb] core input: `http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv' gives access `http' demux `' path `jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv'
D/VLC: [f4ebbbc8/2dbb] core input source: specified demux: any
D/VLC: [f4ebbbc8/2dbb] core input source: creating demux: access='http' demux='any' location='jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv' file='(null)'
D/VLC: [ee93be28/2dbb] core demux: looking for access_demux module matching "http": 6 candidates
D/VLC: [ee93be28/2dbb] core demux: no access_demux modules matched
D/VLC: [ee93bea8/2dbb] core access: creating access: http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv
D/VLC: [ee93bea8/2dbb] core access: looking for access module matching "http": 22 candidates
D/VLC: [ee93bea8/2dbc] transport access: resolving jell.yfish.us ...
E/VLC: [ee93bea8/2dbc] transport access: cannot resolve jell.yfish.us port 80: No address associated with hostname
E/VLC: [ee93bea8/2dbb] access access: HTTP connection failure
D/VLC: [ee93bea8/2dbb] http access: querying proxy for http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv
D/VLC: [ee93bea8/2dbb] http access: no proxy
D/VLC: [ee93bea8/2dbb] http access: http: server='jell.yfish.us' port=80 file='/media/jellyfish-3-mbps-hd-h264.mkv'
D/VLC: [ee93bea8/2dbb] core access: net: connecting to jell.yfish.us port 80
E/VLC: [ee93bea8/2dbb] core access: cannot resolve jell.yfish.us port 80 : No address associated with hostname
E/VLC: [ee93bea8/2dbb] http access: cannot connect to jell.yfish.us:80
D/VLC: [ee93bea8/2dbb] core access: no access modules matched
E/VLC: [f4ebbbc8/2dbb] core input source: cannot access http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv
E/VLC: [ee923df8/2dbb] core input: Your input can't be opened
E/VLC: [ee923df8/2dbb] core input: VLC is unable to open the MRL 'http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv'. Check the log for details.
1个回答

7

在深入研究libvlc代码后,我意识到问题的原因非常简单,我真的不太高兴之前没有想到。

无论如何,我为那些遇到同样问题并开始深入研究libvlc之前没有检查最明显的事情的人发布答案。

基本上,我在清单中缺少了INTERNET权限:

<uses-permission android:name="android.permission.INTERNET" />

日志不够清晰,特别是在Android端,可能是因为渲染没有在UI线程中完成,因此您不会收到通常的NetworkOnMainThreadException异常。


太准确了!先生!我也遇到了同样的问题,然后看到了您的解决方案!感谢您的分享! - Ibanez1408

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接