Stats for HLS Player

Stats Information

Statistics for an on-going stream can be viewed by user for debugging purposes. It can also be used as a standalone dependency if required and has no dependency on 100ms SDK.

Add dependency

  • Adding the Player-Stats plugin and SDK dependency to your app-level build.gradle.

dependencies { // See the version in the badge above. // There are separate libraries for the sdk, virtual background and hls-player-stats. // add just the ones you need.
def hmsVersion = "x.x.x"
implementation "live.100ms:android-sdk:$hmsVersion"
implementation "live.100ms:hls-player-stats:$hmsVersion"


This Plugin supports Exoplayer versions 2.15.0 and above.

Instantiate PlayerEventsCollector

An Existing exoplayer instance can be directly attached to PlayerEventsCollector as follows :

// an existing exoplayer instance val exoplayer : Exoplayer // this is an optional configuration provided while instantiated while creating the object, where // @param `eventRate` is the rate in milliseconds at which client wants to recieve the events.(default set to 2000 i.e 2 seconds) val initConfig = InitConfig(eventRate = 2000) playerEventsCollector = PlayerEventsCollector(exoplayer : exoplayer)

Listening to updates from PlayerEventsCollector

To start listeneing updates from the plugin , listener can be attached as follows :

playerEventsCollector.addListener(object : PlayerEventsListener { override fun onEventUpdate(playerStats: PlayerStats) { // playerStats object contains information for all the stats provided by the plugin. // more information for this object is mentioned at the end of the document. } })

To stop listeneing updates from the plugin , listener can be removed as follows :



removeListener() must be called when view listening to it is destroyed

Interpretting the values :

bandwidthEstimateThe current bandwidth, as estimated by the playerbytes per secondUse this to show the current network speed of the user
bytesDownloadedThe total bytes downloaded within the given poll durationBytesUse this to calculate the total Bytes downloaded in a session or to show the network activity
bitratebitrate of the current layer being playedbytes per secondUse to show a bitrate chart to the user
bufferedDurationAn estimate of the total buffered duration from the current positionmsThis can be used to show how much data is already buffered
video widthThe width of the videopixelsUsed to know the resolution being played
video heightThe height of the videopixelsUsed to know the resolution being played
video frameRateThe frame rateframes per secondUsed to know the FPS
droppedFramesThe number of dropped frames since the last call to this methodIntUsed to calculate the total number of dropped frames
distanceFromLiveEdgeDistance of current playing position from live edgeIntUsed to calculate how far current player position is from live edge of content.

Have a suggestion? Recommend changes ->

Was this helpful?