D
D
DARKENN2020-05-21 17:06:07
Java
DARKENN, 2020-05-21 17:06:07

How to solve ExoPlayer error?

Mistake:

E/ExoPlayerImplInternal: Source error.
    net.butterflytv.rtmp_client.RtmpClient$RtmpIOException: RTMP error: -3
        at net.butterflytv.rtmp_client.RtmpClient.open(RtmpClient.java:222)
        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.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:961)
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:818)


Manifesto:
implementation 'net.butterflytv.utils:rtmp-client:3.1.0'
    implementation 'com.google.android.exoplayer:exoplayer:2.11.0'
    implementation 'com.google.android.exoplayer:extension-rtmp:2.9.6'

The code:
//initiate Player
//Create a default TrackSelector
        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

//Create the player
        SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector);
        PlayerView playerView = inflate.findViewById(R.id.simple_player);
        playerView.setPlayer(player);

        RtmpDataSourceFactory rtmpDataSourceFactory = new RtmpDataSourceFactory();
// This is the MediaSource representing the media to be played.
        MediaSource videoSource = new ExtractorMediaSource.Factory(rtmpDataSourceFactory)
                .createMediaSource(Uri.parse("rtmp://************"));

// Prepare the player with the source.
        player.prepare(videoSource);
//auto start playing
        player.setPlayWhenReady(true);
        return inflate;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question