feat(camera): use cameraDeviceId from voiceStore on camera enable
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import type { VideoCaptureOptions } from 'livekit-client';
|
||||||
import { useVoiceStore } from '../stores/voiceStore';
|
import { useVoiceStore } from '../stores/voiceStore';
|
||||||
import { useUIStore } from '../stores/uiStore';
|
import { useUIStore } from '../stores/uiStore';
|
||||||
import { getActiveRoom } from '../hooks/useLiveKit';
|
import { getActiveRoom } from '../hooks/useLiveKit';
|
||||||
@@ -60,9 +61,15 @@ export async function handleCameraAction(): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
const willEnable = !isCameraOn;
|
const willEnable = !isCameraOn;
|
||||||
if (willEnable) {
|
if (willEnable) {
|
||||||
|
const cameraDeviceId = useVoiceStore.getState().cameraDeviceId;
|
||||||
|
const captureOpts: VideoCaptureOptions = {
|
||||||
|
resolution: CAMERA_PRESET.resolution,
|
||||||
|
frameRate: CAMERA_PRESET.encoding.maxFramerate,
|
||||||
|
};
|
||||||
|
if (cameraDeviceId) captureOpts.deviceId = cameraDeviceId;
|
||||||
await room.localParticipant.setCameraEnabled(
|
await room.localParticipant.setCameraEnabled(
|
||||||
true,
|
true,
|
||||||
{ resolution: CAMERA_PRESET.resolution, frameRate: CAMERA_PRESET.encoding.maxFramerate },
|
captureOpts,
|
||||||
{
|
{
|
||||||
videoCodec: CAMERA_PRESET.codec,
|
videoCodec: CAMERA_PRESET.codec,
|
||||||
videoEncoding: CAMERA_PRESET.encoding,
|
videoEncoding: CAMERA_PRESET.encoding,
|
||||||
|
|||||||
Reference in New Issue
Block a user