Background throttling can cause playback delays that will recover once the document becomes visible again, so it makes sense to handle foreground and background timeouts separately. This PR adds support for a backgroundTimeout option:
// Note: these are the default values for each timeout
player.errors({
timeout: 45 * 1000,
// 5 minutes. Pretty arbitrary so we can discuss alternative default values
backgroundTimeout: 300 * 1000
});
// or after the plugin has been initialized:
player.errors.backgroundTimeout(Infinity);
Setting the value to Infinity disables background timeouts altogether.
I looked into the throttled values for timers and there are a few things to note:
most timers will be throttled to take 1s
Timers can be throttled to take 1 minute if the video is muted and the page has been in the background for more than 5 minutes.
With that in mind we probably want to:
Disable timers entirely if a video is muted and in a background tab. We will always time out when timers start to take 1 minute.
I think five minutes is a good value as I think it's likely at least a 10x slowdown for timers to take 1s, but I don't think that 450 seconds is a reasonable value.
Description
This is a different approach to #197.
Background throttling can cause playback delays that will recover once the document becomes visible again, so it makes sense to handle foreground and background timeouts separately. This PR adds support for a
backgroundTimeout
option:Setting the value to
Infinity
disables background timeouts altogether.