HlsJsP2PEngine
Static method
injectMixin
Enhanced instances of ls.js
injectMixin: (hls: typeof Hls) => HlsJsP2PEngine;
Return Value
The HlsJsP2PEngine
instance
Constructor
constructor: (config?: PartialHlsJsP2PEngineConfig) => HlsJsP2PEngine;
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
config | PartialHlsJsP2PEngineConfig | undefined | configuration parameter |
PartialHlsJsP2PEngineConfig
Parameter | Type | Default value | Description |
---|---|---|---|
core | Partial<CoreConfig> | undefined | configuration parameter |
CoreConfig
Parameter | Type | Default value | Description |
---|---|---|---|
isP2PDisabled | boolean | false | P2P switch |
rtcConfig | RTCConfiguration | undefined | p2p rtc configuration |
useSSL | boolean | true | use HTTPS、WSS protocol |
appId | string | '' | appID |
token | string | '' | app Token (optional) |
trackerZone | string | cn | The country code of the server address,eg:'cn'、'cc'. |
gatewayUrl | string | '' | User-defined gateway address. |
Return Value
The HlsJsP2PEngine
instance
A way to enhance hls.js
After instantiation, the instance of ls.js is automatically enhanced by adding the following methods in addition to the basic methods of hls.
destroy
Release engine
destroy: () => void;
Return Value
void
addEventListener
Listen for p2pEngine events CoreEventMap
addEventListener: <K extends keyof CoreEventMap>(
eventName: K,
listener: CoreEventMap[K],
) => void;
Return Value
void
addEventListener
Cancel listening for p2pEngine events CoreEventMap
removeEventListener: <K extends keyof CoreEventMap>(
eventName: K,
listener: CoreEventMap[K],
) => void;
Return Value
void
getConfigForHlsJs
Get the hls configuration
getConfigForHlsJs: <F = unknown, P = unknown>() => { fLoader: F; pLoader: P };
Return Value
{ fLoader: F; pLoader: P }
getConfig
Get the configuration of p2pEngine
getConfig: () => HlsJsP2PEngineConfig;
Return Value
HlsJsP2PEngineConfig
applyDynamicConfig
Dynamically change the configuration of the p2pEngine
applyDynamicConfig: () => void;
Return Value
void
bindHls
Bind an hls instance
bindHls: <T = unknown>(hls: T | (() => T)) => void;
Return Value
void
HlsJsP2PEngine Callback
onSegmentLoaded
Called when a fragment is fully downloaded and ready for use
onSegmentLoaded: (params: SegmentLoadDetails) => void;
Return Value
void
onSegmentError
Triggered when a fragment download error occurs
onSegmentError: (params: SegmentErrorDetails) => void;
Return Value
void
onSegmentAbort
Triggered when the fragment download stops
onSegmentAbort: (params: SegmentAbortDetails) => void;
Return Value
void
onSegmentStart
Triggered at the beginning of the fragment download process
onSegmentStart: (params: SegmentStartDetails) => void;
Return Value
void
onPeerConnect
Occurs when a new point-to-point connection is established
onPeerConnect: (params: PeerDetails) => void;
Return Value
void
onPeerClose
Triggered when an existing point-to-point connection is closed
onPeerClose: (params: PeerDetails) => void;
Return Value
void
onPeerError
Triggered when an error occurs during a point-to-point connection
onPeerError: (params: PeerErrorDetails) => void;
Return Value
void
onChunkDownloaded
Called after the data block in the segment has been successfully downloaded
onChunkDownloaded: (
bytesLength: number,
downloadSource: DownloadSource,
peerId?: string,
) => void;
Return Value
void
onChunkUploaded
Called when the data block is successfully uploaded to the peer node
onChunkUploaded: (bytesLength: number, peerId: string) => void;
Return Value
void
onTrackerError
Called when an error occurs during a tracker request
onTrackerError: (params: TrackerErrorDetails) => void;
Return Value
void
onTrackerWarning
Called when a warning occurs during a tracker request
onTrackerWarning: (params: TrackerWarningDetails) => void;
Return Value
void