feat(Offline): Allow no timeout when opening IndexedDB database (#8372)

This is the followup to the previous PR #8366 , to allow to disable the
timeout, as per @avelad
[suggestion](https://github.com/shaka-project/shaka-player/pull/8366#issuecomment-2766660785)
to add this in another PR...

---------

Co-authored-by: Loïc Raux <loicraux@gmail.com>
Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
Co-authored-by: Wojciech Tyczyński <tykus160@gmail.com>
This commit is contained in:
loicraux
2025-04-01 16:01:24 +02:00
committed by GitHub
parent 60c6b19d61
commit 8cd2c019b8
2 changed files with 31 additions and 7 deletions
+21 -3
View File
@@ -685,11 +685,29 @@ setting or set it explicitly with:
usePersistentLicense: true
```
## Configure opening IndexedDB timeout
## Configure the timeout for opening IndexedDB-based storage
This configuration must be done before doing any other operation:
There is a default timeout of 5 seconds for opening IndexedDB-based storage.
This is useful to ensure that your application does not block indefinitely
while waiting for the IndexedDB database to open.
If you want to change the value of this timeout, you can do so by setting
accordingly the value of the `shaka.offline.indexeddb.StorageMechanismOpenTimeout`
variable. For example, to set the timeout to 10 seconds, you can do the following:
```js
// In seconds
shaka.offline.indexeddb.StorageMechanismOpenTimeout = 5;
shaka.offline.indexeddb.StorageMechanismOpenTimeout = 10;
```
You can also disable this timeout and consequently wait indefinitely for the
IndexedDB database to open successfully or fail to open. To do this, set the
`shaka.offline.indexeddb.StorageMechanismOpenTimeout` variable to `false`:
```js
shaka.offline.indexeddb.StorageMechanismOpenTimeout = false;
```
Note that this configuration must be done before doing any other offline
storage related operation (download and store content, list content,
remove content, playback of content).