Parameter setBufferSizeGetter
Description
The setBufferSizeGetter method in TeleportConfiguration.Builder allows you to provide the Teleport SDK with a function to determine the current buffer size of the player being used.
Importance of Buffer Size
Accurate knowledge of the player's buffer size is critically important for the Teleport SDK. This information is used to make decisions about the content loading strategy, allowing the SDK to more effectively manage requests to the peer-to-peer network or CDN, preventing excessive loading (which saves traffic) and insufficient loading (which prevents buffering).
Function Requirements
- The function must return the current buffer fill size of the player in milliseconds (
Long). - Called on the main thread (Main-thread).
Example Usage
TeleportConfiguration.Builder("YOUR_API_KEY")
.setBufferSizeGetter {
// Example for ExoPlayer: returns total buffered duration in milliseconds
exoPlayer?.totalBufferedDuration ?: -1L
}
.build()In this example, setBufferSizeGetter returns totalBufferedDuration from the exoPlayer instance, which is the recommended way to get the buffer size. If the player is unavailable, -1L is returned.