我正在使用Adobe Live Stream Encoder
在服务器端传输RTMP
实时音频。在我的Android客户端应用程序中,带有RTMP扩展名的ExoPlayer
无法播放它并导致RtmpIOException
,但我可以使用VLC或MPC播放。
我使用其他一些RTMP
链接测试了我的Android应用程序,还可以。
我还在手机(MXPlayer,vlc)中安装的其他视频播放器中使用了此URL,还可以。
这是播放视频的Android中的代码:
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
//Create the player
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
playerView.setPlayer(player);
MediaSource videoSource = null;
Uri uri = Uri.parse("rtmp://172.18.49.6/live/11");
dataSourceFactory = new RtmpDataSourceFactory();
videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
.createMediaSource(uri);
player.prepare(videoSource);
player.setPlayWhenReady(true);
这是例外:
E/ExoPlayerImplInternal: Source error.
net.butterflytv.rtmp_client.RtmpClient$RtmpIOException
at net.butterflytv.rtmp_client.RtmpClient.open(RtmpClient.java:56)
at com.google.android.exoplayer2.ext.rtmp.RtmpDataSource.open(RtmpDataSource.java:60)
at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:885)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
我也有类似的问题,请尝试在RTMP URL上修改它:
Before:
Uri uri = Uri.parse("rtmp://172.18.49.6/live/11");
After:
Uri uri = Uri.parse("rtmp://172.18.49.6/live/11 live=1");