When playing an RTSP stream with exoplayer, an IllegalStateException exception occurs

When using exoplayer to play an RTSP stream, and then disconnecting the network or interrupting the RTSP stream, the checkStateNotNull exception will be randomly reported; Version: media3-exoplayer:1.1.1; The details are as follows:

E/AndroidRuntime: FATAL EXCEPTION: ExoPlayer:Playback
Process: com.join.driving, PID: 28548
java.lang.IllegalStateException
    at androidx.media3.common.util.Assertions.checkStateNotNull(Assertions.java:117)
    at androidx.media3.exoplayer.rtsp.RtspMessageChannel.send(RtspMessageChannel.java:190)
    at androidx.media3.exoplayer.rtsp.RtspClient$MessageSender.sendRequest(RtspClient.java:481)
    at androidx.media3.exoplayer.rtsp.RtspClient$MessageSender.sendSetupRequest(RtspClient.java:380)
    at androidx.media3.exoplayer.rtsp.RtspClient.continueSetupRtspTrack(RtspClient.java:296)
    at androidx.media3.exoplayer.rtsp.RtspClient.setupSelectedTracks(RtspClient.java:221)
    at androidx.media3.exoplayer.rtsp.RtspMediaPeriod.maybeSetupTracks(RtspMediaPeriod.java:478)
    at androidx.media3.exoplayer.rtsp.RtspMediaPeriod.access$2600(RtspMediaPeriod.java:66)
    at androidx.media3.exoplayer.rtsp.RtspMediaPeriod$RtpLoadInfo.lambda$new$0$androidx-media3-exoplayer-rtsp-RtspMediaPeriod$RtpLoadInfo(RtspMediaPeriod.java:893)
    at androidx.media3.exoplayer.rtsp.RtspMediaPeriod$RtpLoadInfo$$ExternalSyntheticLambda0.onTransportReady(Unknown Source:2)
    at androidx.media3.exoplayer.rtsp.RtpDataLoadable.lambda$load$0$androidx-media3-exoplayer-rtsp-RtpDataLoadable(RtpDataLoadable.java:158)
    at androidx.media3.exoplayer.rtsp.RtpDataLoadable$$ExternalSyntheticLambda0.run(Unknown Source:6)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.os.HandlerThread.run(HandlerThread.java:67)

Can this exception be caught with a try catch, or how can it be avoided?

  • As you can see from the stack trace none of your app code is involved, thus catching is not possible. BTW: you forgot to mention the used exoplayer version.

    – 

Leave a Comment