|
@@ -103,9 +103,18 @@ export function useRoom(props: LiveKitRoomProps) {
|
|
|
|
|
|
watch(
|
|
|
props.refConfig,
|
|
|
- (newConfig) => {
|
|
|
- console.log('2. props.refConfig', newConfig)
|
|
|
- room.value = passedRoom ?? new Room(options)
|
|
|
+ async (newConfig) => {
|
|
|
+ console.log('options',options)
|
|
|
+ room.value = passedRoom ?? new Room({
|
|
|
+ // automatically manage subscribed video quality
|
|
|
+ adaptiveStream: true,
|
|
|
+ // optimize publishing bandwidth and CPU for published tracks
|
|
|
+ dynacast: true,
|
|
|
+ // default capture settings
|
|
|
+ // videoCaptureDefaults: {
|
|
|
+ // resolution: VideoPresets.h720.resolution,
|
|
|
+ // },
|
|
|
+ })
|
|
|
|
|
|
const { className } = setupLiveKitRoom()
|
|
|
htmlProps.value = { className }
|
|
@@ -117,6 +126,18 @@ export function useRoom(props: LiveKitRoomProps) {
|
|
|
.on(RoomEvent.MediaDevicesError, handleMediaDeviceError)
|
|
|
.on(RoomEvent.EncryptionError, handleEncryptionError)
|
|
|
.on(RoomEvent.ConnectionStateChanged, connectionStateChangeListener)
|
|
|
+ .on('trackSubscribed', (track, participant, publication) => {
|
|
|
+ if (track.kind === 'audio') {
|
|
|
+ console.log('Audio track subscribed');
|
|
|
+ } else if (track.kind === 'video') {
|
|
|
+ console.log('Video track subscribed');
|
|
|
+ const element = track.attach();
|
|
|
+ document.body.appendChild(element);
|
|
|
+ element.play().catch(e => {
|
|
|
+ console.log('自动播放被阻止,需要用户交互:', e);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
if (simulateParticipants) {
|
|
|
room.value.simulateParticipants({
|
|
@@ -141,15 +162,32 @@ export function useRoom(props: LiveKitRoomProps) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ console.log('2. props.refConfig', newConfig)
|
|
|
+ // console.log('connectOptions', connectOptions)
|
|
|
if (newConfig.connect) {
|
|
|
log.debug('connecting')
|
|
|
+ // await room.value.prepareConnection(newConfig.serverUrl, newConfig.token);
|
|
|
+ let realConnectOptions = {
|
|
|
+ audio: true,
|
|
|
+ audioCaptureDefaults: {
|
|
|
+ autoGainControl: false,
|
|
|
+ echoCancellation: true,
|
|
|
+ noiseSuppression: true
|
|
|
+ },
|
|
|
+ }
|
|
|
+ if (connectOptions) {
|
|
|
+ realConnectOptions = { ...realConnectOptions, ...connectOptions }
|
|
|
+ }
|
|
|
+ console.log('realConnectOptions', realConnectOptions)
|
|
|
room.value
|
|
|
- .connect(newConfig.serverUrl, newConfig.token, connectOptions)
|
|
|
+ .connect(newConfig.serverUrl, newConfig.token, realConnectOptions)
|
|
|
.catch((e: Error) => {
|
|
|
log.warn(e)
|
|
|
console.log('3. error', e)
|
|
|
onError?.(e)
|
|
|
})
|
|
|
+ await room.value.localParticipant.enableCameraAndMicrophone();
|
|
|
+ room.value.localParticipant.setMicrophoneEnabled(true);
|
|
|
} else {
|
|
|
log.debug('disconnecting because connect is false')
|
|
|
room.value.disconnect()
|