get

abstract suspend fun get(id: MediaId, scope: CoroutineScope): StateFlow<CgsStreamState<Media?>>

Observes a media by its identifier, reacting to changes in the active session.

The returned StateFlow emits CgsStreamState.Refreshing immediately, followed by CgsStreamState.Success or CgsStreamState.Failure once the request completes. Whenever the active profile or language changes, the flow automatically restarts against the new session and discards any previously loaded data — a failed refresh after such a change is surfaced as CgsStreamState.Failure with no stale data attached.

The subscription is bound to scope: it stops making requests once scope has no active collectors of the returned flow, and resumes on the next collection.

Return

A StateFlow of CgsStreamState wrapping the fetched Media, or null if not found.

Parameters

id

The identifier of the media to retrieve.

scope

The CoroutineScope used to bound the lifecycle of the returned StateFlow.