When segments or manifests requests return HTTP error status (eg. 404 or 403 errors), the player will return an error after a few retries. This error indicates to the end user why playback failed and allows developers to catch it in an error event and implement some custom logic around it if needed.
However when the the device / browser is offline (eg. internet connection is lost), the player detects that no response was returned for the requested segments or manifest and retries the same segments constantly without ever returning any error. This allows playback to recover as soon as the device comes back online and therefore enables the robust experience for the end user, given the circumstances.
(player retrying the same segments indefinitely)
The Bitmovin player exposes a Network API, which allows developer to fully customize the retry behaviour. For some use case, it might be helpful to avoid infinite retries and implement a different logic in case the device goes offline.
Example
var player;
var retryCount = 0;
var conf = {
key: 'YOUR KEY HERE',
events: {
error: console.log
},
network: {
retryHttpRequest: function(type, response, retries) {
return new Promise(function(resolve, reject) {
if (retryCount >= 4) {
// after the 3rd retry, the promise is rejected and the player should return an error (+ error screen)
// You can implement your custom logic here.
reject();
} else {
setTimeout(function() {
resolve(response.request);
retryCount++;
console.log("retryCount = " + retryCount);
// retries are performed every 1000ms
}, 1000);
}
});
}
}
};
(result : the player now returns an error after 3 retries.)
Feel free to check out our website to read more about use cases enabled by the Network API
For testing purpose, you can use the Chrome developer tools (Network console) to simulate an offline scenario