Merge pull request #3363 from element-hq/toger5/fix-initial-device-selection-in-controlled-devices-mode
Fix initial selection when using controlled media
This commit is contained in:
@@ -50,7 +50,7 @@ export const setPipEnabled$ = new Subject<boolean>();
|
|||||||
|
|
||||||
export const availableOutputDevices$ = new Subject<OutputDevice[]>();
|
export const availableOutputDevices$ = new Subject<OutputDevice[]>();
|
||||||
|
|
||||||
export const outputDevice$ = new Subject<string | undefined>();
|
export const outputDevice$ = new Subject<string>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This allows the os to mute the call if the user
|
* This allows the os to mute the call if the user
|
||||||
|
|||||||
@@ -269,18 +269,21 @@ class ControlledAudioOutput
|
|||||||
this.deviceSelection$.next(id);
|
this.deviceSelection$.next(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly selected$ = merge(
|
public readonly selected$ = combineLatest(
|
||||||
this.deviceSelection$,
|
[
|
||||||
controlledOutputSelection$,
|
this.available$,
|
||||||
).pipe(
|
merge(
|
||||||
startWith<string | undefined>(undefined),
|
controlledOutputSelection$.pipe(startWith(undefined)),
|
||||||
map((id) =>
|
this.deviceSelection$,
|
||||||
id === undefined
|
),
|
||||||
|
],
|
||||||
|
(available, preferredId) => {
|
||||||
|
const id = preferredId ?? available.keys().next().value;
|
||||||
|
return id === undefined
|
||||||
? undefined
|
? undefined
|
||||||
: { id, virtualEarpiece: id === EARPIECE_CONFIG_ID },
|
: { id, virtualEarpiece: id === EARPIECE_CONFIG_ID };
|
||||||
),
|
},
|
||||||
this.scope.state(),
|
).pipe(this.scope.state());
|
||||||
);
|
|
||||||
|
|
||||||
public constructor(private readonly scope: ObservableScope) {
|
public constructor(private readonly scope: ObservableScope) {
|
||||||
this.selected$.subscribe((device) => {
|
this.selected$.subscribe((device) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user