Omit 'signal', clarify docs for reading ranged resources (#387)

This commit is contained in:
Vanilagy
2026-06-01 22:00:39 +02:00
parent 5799cdf630
commit c6c768d93e
2 changed files with 11 additions and 4 deletions
+5 -1
View File
@@ -643,7 +643,11 @@ const source = new UrlSource('https://example.com/bigbuckbunny.mp4', {
});
```
All `requestInit` fields are respected except for `signal` and `headers.Range`, which are overridden by Mediabunny. The same applies to the `signal` and `headers.Range` values of a `Request` passed as the first constructor argument. To cancel ongoing requests, [dispose of the input](#disposing-inputs).
::: info
All `requestInit` fields are respected except for `signal` and `headers.Range`, which are overridden by Mediabunny. The same applies to the `signal` and `headers.Range` values of a `Request` passed as the first constructor argument.
To cancel ongoing requests, [dispose of the input](#disposing-inputs). To load a specific range of the resource, create the `UrlSource` first and then call [`.slice()`](../api/Source#slice).
:::
`getRetryDelay` can be used to control the retry logic used should a request fail. When a request fails, `getRetryDelay` should return the time to wait in seconds before the request will be retried. Returning `null` prevents further retries.
```ts
+6 -3
View File
@@ -675,10 +675,13 @@ export type UrlSourceOptions = {
* The [`RequestInit`](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit) used by the Fetch API. Can be
* used to further control the requests, such as setting custom headers.
*
* All fields will work except for `signal` and `headers.Range`; these will be overridden by Mediabunny. If you want
* to cancel ongoing requests, use {@link Input.dispose}.
* The `signal` field is not available, as Mediabunny controls request cancellation internally. If you want to
* cancel ongoing requests, use {@link Input.dispose}.
*
* The `headers.Range` field will also be overridden by Mediabunny. For loading a ranged remote resource, create the
* source, then call {@link Source.slice}.
*/
requestInit?: RequestInit;
requestInit?: Omit<RequestInit, 'signal'>;
/**
* A function that returns the delay (in seconds) before retrying a failed request. The function is called