Handle errors with the Wowza Flowplayer Android SDK

The Wowza Flowplayer Android SDK provides a long list of callbacks for monitoring the player's state. Error callbacks are part of this list, but in many cases they may require special handling.

Error event listeners

For a good user experience, you can listen to error events and examine error objects. You can then handle errors gracefully by implementing error-handling logic that makes your Android application more reliable and robust.

We provide two event listeners to consume player-emitted events directly with the API. For more, see the OnAdErrorListener and OnErrorListener reference documentation.

Exception types

Exceptions provided by the Android SDK fall within the categories listed in the following table.

Exception Description
AdError Emitted by the Google Interactive Media Ads SDK. Surfaces information when a failure occurs during ad loading or playback. For more, see AdError.
BuiltInControlException Caused by the built-in player controls. For example, emitted when there's an issue loading the player's web controls. If there's an error with the controls, they're hidden and playback stops.
FlowplayerConfigException Related to the Wowza Flowplayer configuration. For example, emitted when preparing the player and fetching a configuration using an invalid media ID.
InvalidAccessTokenException Indicates that a valid access token wasn't provided.
PlaybackException Related to the ExoPlayer. Thrown when a non locally recoverable playback failure occurs. For more, see PlaybackException.

See the full reference documentation for additional exception details.

Customize error text

The Android SDK provides localized error messages, plus the exception containing more information. You can use this localized message and display it in the user interface for users to report.

Some errors, such as ad-related errors, may not interrupt content playback. However, in some instances, the playback will stop. When this happens and you're using the built-in controls, the user sees a meaningful message along with a reload button.

You can change the built-in messages by mapping them to more user-friendly strings. To do so, override the following string keys in your project's app/res/values/strings.xml:

Copy
Copied
<!-- An error related to the playback has occurred. -->
<string name="flowplayer_error_playback">Failed to play media.</string>

<!-- The access token could not be validated and therefore the playback cannot start. -->
<string name="flowplayer_error_access_token">Failed to validate access token.</string>

<!-- Failed to load a Wowza Flowplayer configuration. -->
<string name="flowplayer_error_config">Failed to load media.</string>

<!-- Failed to load the built-in controls. This probably happened due to poor or no internet connection. -->
<string name="flowplayer_error_controls">Failed to load built-in controls.</string>

<!-- Not shown to the user since the playback is not interrupted. The message is included in the error callback though. -->
<string name="flowplayer_error_ad">Failed to load ad.</string>

<!-- Rarely encountered, but serves as a fallback in cases when an unexpected error has occurred. -->
<string name="flowplayer_error_unspecified">An unknown error has occurred.</string>
Info

If the playback is interrupted, you may want to reload the player without having to call prepare() again. This can be accomplished with the reload() method:

Copy
Copied
// Use a reference to your Wowza Flowplayer instance and reload() method
flowplayer.reload()

Translate errors to other languages

To provide error translations to languages other than English, you can create a new strings.xml file and add it to your specific language folder. For more information, see the Android Add and delete languages documentation.