@@ -63,6 +63,13 @@ export type InitialProps = {
6363 */
6464 backoffMax : number ;
6565
66+ /**
67+ * A function that calculates the delay for the backoff.
68+ *
69+ * This is used to calculate the delay for the backoff.
70+ */
71+ calculateDelay : ( attempt : number ) => number ;
72+
6673 /**
6774 * The length of the clip. This is usually used alongside `ClipTrigger`. Specifies the duration of the media clip, in seconds.
6875 *
@@ -653,7 +660,20 @@ export const createControllerStore = ({
653660 aspectRatio : initialProps ?. aspectRatio ?? null ,
654661 autoPlay : initialProps . autoPlay ?? false ,
655662 backoff : Math . max ( initialProps . backoff ?? 500 , 100 ) ,
656- backoffMax : Math . max ( initialProps . backoffMax ?? 30000 , 1000 ) ,
663+ backoffMax : Math . max ( initialProps . backoffMax ?? 30000 , 10000 ) ,
664+ calculateDelay :
665+ initialProps . calculateDelay ??
666+ ( ( count ) => {
667+ if ( count === 0 ) {
668+ return 0 ;
669+ }
670+
671+ const delayTime = Math . min (
672+ Math . max ( initialProps . backoff ?? 500 , 100 ) * 2 ** ( count - 1 ) ,
673+ Math . max ( initialProps . backoffMax ?? 30000 , 10000 ) ,
674+ ) ;
675+ return delayTime ;
676+ } ) ,
657677 clipLength : initialProps . clipLength ?? null ,
658678 cacheWebRTCFailureMs : initialProps . cacheWebRTCFailureMs ?? null ,
659679 hotkeys : initialProps ?. hotkeys ?? true ,
0 commit comments