flatten media api (no MemberMedia wrapper object

This commit is contained in:
Timo K.
2026-10-08 13:53:57 +02:00
parent 6ffab92f0f
commit 4790af08a4
13 changed files with 214 additions and 232 deletions
+3 -3
View File
@@ -24,17 +24,17 @@ export type TrackOfSource<S extends MediaSource> = S extends
? VideoMediaTrack
: AudioMediaTrack | VideoMediaTrack;
/** The member's first track of a source; undefined while there is none. */
/** The member's first track of a source; undefined while there is none, or no media yet. */
export function trackBySource$<S extends MediaSource>(
scope: ObservableScope,
tracks$: Behavior<MediaTrack[]>,
tracks$: Behavior<MediaTrack[] | null>,
source: S,
): Behavior<TrackOfSource<S> | undefined> {
return scope.behavior(
tracks$.pipe(
map(
(tracks) =>
tracks.find((t) => t.source === source) as
tracks?.find((t) => t.source === source) as
| TrackOfSource<S>
| undefined,
),