Skip to content

Parameter durationGetter

Description

The durationGetter parameter provides the Teleport SDK with a function to identify the duration of a video segment. This information can be used by the SDK for more precise planning of downloads and optimization of data exchange strategy in the peer-to-peer network, especially in scenarios with variable segment durations.

Importance of Segment Duration

Accurate knowledge of segment duration helps the Teleport SDK make more informed decisions about when to request the next segment and how to manage the buffer, which contributes to smoother playback and reduced buffering.

When is it necessary?

It is recommended to specify the durationGetter function if your player or manifest provides information about segment durations. If segment durations are fixed, you can simply return that value.

Example Usage

js
let tlprt = await teleport.initialize({
    apiKey: "YOUR_API_KEY", // Your API key
    loader: {
        type: "PLUGIN_ID", // Identifier of the player plugin used
        params: {
            // Function to get the segment duration (e.g., 5 seconds)
            durationGetter: () => 5
        }
    }
});

In this example, durationGetter always returns 5 seconds, which is suitable for content with fixed segment durations. If segment durations can vary, the function should dynamically determine and return the actual value.