Network on Web
THEOplayer makes a number of network requests, and receives responses, while it is loading and playing a stream. The Network API allows you to intercept those requests and responses, so you can inspect them, modify them, redirect them, or respond with your own data.
Common use cases are adding authentication headers or query parameters to segment requests, redirecting requests to another CDN, or rewriting a manifest before the player parses it.
The Web SDK exposes this API through player.network.
On iOS and iPadOS browsers, the Network API can only be used to intercept and alter DRM-related requests and responses.
Detecting a lost connection
To detect that the player lost its connection, listen for the
manifesterror
and segmenterror events,
which are dispatched when the player fails to load the manifest or a segment.
The manifestupdate
event indicates that the player successfully loaded the manifest again, so the connection is back:
player.addEventListener('manifesterror', handleConnectionLost);
player.addEventListener('segmenterror', handleConnectionLost);
player.addEventListener('manifestupdate', handleConnectionRestored);
Event listeners can be removed similarly:
player.removeEventListener('manifesterror', handleConnectionLost);