Skip to main content
Version: 11.8.0

How to do error handling on Android

As a developer, you could be interested in error handling for any of the following reasons:

  • You want to render human-friendly error messages inside the video player. Reading this error message,
    • the user can either remediate the issue by themselves (e.g. by refreshing the page, by checking again in some time, ...),
    • or contact a support service with this error code.
  • You want to send error-data to an analytics service. (And this service helps you to identify frequent issues.)
  • You want to self-remediate the issue. For example, if a stream is unavailable, you want to retry to load the stream, or load a different stream.
  • ...

THEOplayer exposes different types of errors, and you can interact with them in two ways:

  1. Through an event listener, and attaching an event handler to this listener.
  2. Through a getter, which holds data when an error has occurred.

The sections below describe the "top-level", "generic", "player" error event. This event is fatal and prevents playback. There are also other error events, for example the one dispatched by the Chromecast API. You handle those error events in the same fashion.

Event listener

Subscribe to the ERROR event of the player, and attach a listener which implements the error handling. The THEOplayerException causing the error is available through getErrorObject().

theoPlayerView.player.addEventListener(PlayerEventTypes.ERROR) { event ->
println(event.errorObject)
}

Getter

You can query the last error that occurred for the current source through player.error.

println(theoPlayerView.player.error)

Types of errors

"Which error related events does the player expose" lists which types of errors there are. Note that generally speaking only the "generic error event" is fatal. Other events, like the "Chromecast error event" and the "ad error event", are considered non-fatal because some type of playback can still continue.

"Error codes" lists which error codes are available for the "generic error event".