[object Object] Icon

Encoding
Learn how to create, start, manage and modify Encodings

[object Object] Icon

Player
Learn how to create, start, manage and modify Players

[object Object] Icon

Analytics
Learn how to create, start, manage and modify Analyticss

Docs Home
User shortcuts for search
Focus by pressing f
Hide results by pressing Esc
Navigate via   keys

Mon Dec 19 2022

How to enable logging in the Bitmovin Android Player

OverviewLink Icon

Troubleshooting streams on mobile devices can be challenging, especially if issues occur rarely and only in specific circumstances. A common approach in such a scenario is to add log statements to the code in order to observe configurations and states at the time of the failure.

Using events for logsLink Icon

All state updates of the Android Player are published through the EventEmitter interface which is implemented by all main components of the Player: The Player and the Source for playback as well as the OfflineContentManager for downloading content for offline playback.

Apart from the events that indicate a specific state change in the respective component, there are three more general events that are especially useful for logging:

  • The Error event signals a fatal error that can not automatically be recovered from.

  • The Warning event is emitted if something unexpected happens but core functionality is expected to continue.

  • The Info event which contains additional neutral information.

ExampleLink Icon

In the following code snippet, error, warning and info events from the player and source are logged to the console.

1player.on<PlayerEvent.Error> { Log.e("Player Error", it.toString()) }
2player.on<PlayerEvent.Warning> { Log.w("Player Warning", it.toString()) }
3player.on<PlayerEvent.Info> { Log.i("Player Info", it.toString()) }
4
5source.on<SourceEvent.Error> { Log.e("Source Error", it.toString()) }
6source.on<SourceEvent.Warning> { Log.w("Source Warning", it.toString()) }
7source.on<SourceEvent.Info> { Log.i("Source Info", it.toString()) }

The events also enable more complex logging scenario such as e.g. logging only failed downloads:

1source.on<SourceEvent.DownloadFinished> {
2 if (!it.isSuccess){
3 Log.e(
4 "Download Error",
5 "Unable to download ${it.url}, response code was ${it.httpStatus} after ${it.downloadTime} seconds."
6 )
7 }
8}

A more in-depth logging implementation can be found in the sample projects.

Give us feedback