Android ExoPlayer-无法打开获取RtmpClient $ RtmpIOException的RTMPS链接

时间:2019-01-09 09:46:02

标签: android rtmp exoplayer rtmps

ExoPlayer Gradle实现

implementation 'com.google.android.exoplayer:exoplayer:2.7.3'
implementation 'com.google.android.exoplayer:extension-rtmp:2.7.3'

获得以下例外情况

  

E / ExoPlayerImplInternal:源错误。 net.butterflytv.rtmp_client.RtmpClient.open(RtmpClient.java:56)在com.google.android.exoplayer2.ext.rtmp.RtmpDataSource.open(RtmpDataSource.java:57)的net.butterflytv.rtmp_client.RtmpClient.open(RtmpClient.java:56)处的net.butterflytv.rtmp_client.RtmpClient $ RtmpIOException位于com.google.android.exoplayer2.upstream.Loader $ LoadTask.run(Loader.java:308)的com.google.android.exoplayer2.source.ExtractorMediaPeriod $ ExtractingLoadable.load(ExtractorMediaPeriod.java:841)。在java.lang.Thread.run(Thread.java:760)上并发.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:607)在

ExoPlayer中播放rtmps链接的Android源代码

BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory =
        new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector =
        new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
PlayerView playerView = findViewById(R.id.simple_player);
playerView.setPlayer(player);
RtmpDataSourceFactory rtmpDataSourceFactory = new RtmpDataSourceFactory();

  path = "rtmps:///hostname.net/..../64174.mp4";

MediaSource videoSource = new ExtractorMediaSource.Factory(rtmpDataSourceFactory)
        .createMediaSource(Uri.parse(path));

player.prepare(videoSource);

player.setPlayWhenReady(true);

0 个答案:

没有答案