Function: restorePersisted()
function restorePersisted(storage: MediaSessionStorage, options?: PersistenceOptions): Promise<RestoreResult>;
Defined in: packages/media-session/src/persistence.ts:778
Read back whatever withPersistence last wrote.
Returns a typed result, so every outcome is on the app's happy path:
empty on a first launch, unsupportedVersion after a schema change,
corrupt for anything that does not parse or does not validate. Only a
failing storage engine rejects.
The restored anchor is re-stamped { ..., at: now(), rate: 0 } — the record
was already frozen paused at write time (see withPersistence), and
re-stamping at is what keeps it honest across an arbitrary gap. Broadcast
it as-is; do not resume playback off the back of it without a user gesture.
const restored = await restorePersisted(AsyncStorage)
if (restored.status === 'restored') applyPersisted(service, restored.session)
Parameters
| Parameter | Type |
|---|---|
storage | MediaSessionStorage |
options | PersistenceOptions |
Returns
Promise<RestoreResult>