Add a button to switch the camera on mobile

This commit is contained in:
Robin
2024-10-28 17:29:26 -04:00
parent 90681b16e0
commit 8c0280954c
8 changed files with 219 additions and 63 deletions

View File

@@ -13,8 +13,10 @@ import {
import {
Room as LivekitRoom,
LocalParticipant,
LocalVideoTrack,
ParticipantEvent,
RemoteParticipant,
Track,
} from "livekit-client";
import {
Room as MatrixRoom,
@@ -58,6 +60,7 @@ import {
import {
LocalUserMediaViewModel,
MediaViewModel,
observeTrackReference,
RemoteUserMediaViewModel,
ScreenShareViewModel,
UserMediaViewModel,
@@ -259,6 +262,17 @@ function findMatrixMember(
// TODO: Move wayyyy more business logic from the call and lobby views into here
export class CallViewModel extends ViewModel {
public readonly localVideo: Observable<LocalVideoTrack | null> =
observeTrackReference(
this.livekitRoom.localParticipant,
Track.Source.Camera,
).pipe(
map((trackRef) => {
const track = trackRef.publication?.track;
return track instanceof LocalVideoTrack ? track : null;
}),
);
private readonly rawRemoteParticipants = connectedParticipantsObserver(
this.livekitRoom,
).pipe(this.scope.state());

View File

@@ -65,7 +65,7 @@ export function useDisplayName(vm: MediaViewModel): string {
return displayName;
}
function observeTrackReference(
export function observeTrackReference(
participant: Participant,
source: Track.Source,
): Observable<TrackReferenceOrPlaceholder> {