Parameter segmentAcceptor
Description
The segmentAcceptor parameter is used by the Teleport SDK to determine whether a specific HTTP request is a request to download a video segment. This is necessary for the Teleport PDN (Peer-to-Peer Delivery Network) to intercept and process these requests, optimizing content delivery.
Default Behavior
By default, the Teleport SDK identifies video segments by their extensions: .ts, .mp4, .m4s, .m4v, .m4a, .vtt.
When is it necessary?
If your media server uses specific or non-standard URL addresses for video segments that do not match standard extensions, you need to define your own segmentAcceptor function. This function will allow the Teleport SDK to correctly identify segments for peer-to-peer transfer.
Example Usage
let tlprt = await teleport.initialize({
apiKey: "YOUR_API_KEY", // Your API key
loader: {
type: "PLUGIN_ID", // Identifier of the player plugin used
params: {
// Custom function to identify the video segment
segmentAcceptor: url => url.indexOf(".mp4") > -1 || url.indexOf("my-custom-segment-path") > -1
}
}
});In this example, the segmentAcceptor function will consider any URL containing .mp4 or the string "my-custom-segment-path" as a segment.