100ms Logo

100ms

Docs

Search docs
/

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. Latest Version
build.gradle
dependencies { // See the latest version in the jitpack badge above.
implementation 'com.github.100mslive.android-sdk:lib:x.x.x'
implementation 'com.github.100mslive.android-sdk:stats:x.x.x'
}

Note

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 :

playerEventsCollector.removeListener()

Note

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

Interpretting the values :

NameDescriptionUnitUsage
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.