Skip to content

Parameter segmentTypeGetter

Description

The segmentTypeGetter parameter allows the Teleport SDK to identify the type of the loaded video segment (e.g., video, audio, subtitles). This is important for finer control over the peer-to-peer network and optimizing data exchange, as different segment types may have different priorities or processing rules.

Importance of Segment Type Determination

Determining the segment type helps the Teleport SDK more effectively manage data streams, for example, by prioritizing video segments or applying specific rules for audio or subtitles. This improves the quality of Teleport PDN operation.

When is it necessary?

It is recommended to specify the segmentTypeGetter function if your media server allows distinguishing segment types by their URL or other metadata. This improves the quality of Teleport PDN operation.

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 determine the segment type based on the URL
            segmentTypeGetter: url => {
                if (url.includes('video')) return teleport.SegmentType.Video;
                if (url.includes('audio')) return teleport.SegmentType.Audio;
                if (url.includes('caption')) return teleport.SegmentType.Caption;
                return teleport.SegmentType.Unknown;
            }
        }
    }
});

teleport.SegmentType Enum

Available values for the segment type are defined in the teleport.SegmentType enumeration. See the JavaScript API: Enums section for details.