🐛(frontend) use feature detection for adaptiveStream and dynacast
Replace hardcoded true values with supportsAdaptiveStream() and supportsDynacast() checks. LiveKit SDK supports broad browser range but requires specific APIs - modern features need explicit compatibility checks. Prevents enabling unsupported WebRTC features on incompatible browsers, which could led to a poor user experience. One alternative solution could be to install polyfills.
This commit is contained in:
committed by
aleb_the_flash
parent
bdaf4245da
commit
1b26dea178
@@ -7,6 +7,8 @@ import {
|
|||||||
MediaDeviceFailure,
|
MediaDeviceFailure,
|
||||||
Room,
|
Room,
|
||||||
RoomOptions,
|
RoomOptions,
|
||||||
|
supportsAdaptiveStream,
|
||||||
|
supportsDynacast,
|
||||||
} from 'livekit-client'
|
} from 'livekit-client'
|
||||||
import { keys } from '@/api/queryKeys'
|
import { keys } from '@/api/queryKeys'
|
||||||
import { queryClient } from '@/api/queryClient'
|
import { queryClient } from '@/api/queryClient'
|
||||||
@@ -79,10 +81,13 @@ export const Conference = ({
|
|||||||
retry: false,
|
retry: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isAdaptiveStreamSupported = supportsAdaptiveStream()
|
||||||
|
const isDynacastSupported = supportsDynacast()
|
||||||
|
|
||||||
const roomOptions = useMemo((): RoomOptions => {
|
const roomOptions = useMemo((): RoomOptions => {
|
||||||
return {
|
return {
|
||||||
adaptiveStream: true,
|
adaptiveStream: isAdaptiveStreamSupported,
|
||||||
dynacast: true,
|
dynacast: isDynacastSupported,
|
||||||
publishDefaults: {
|
publishDefaults: {
|
||||||
videoCodec: 'vp9',
|
videoCodec: 'vp9',
|
||||||
},
|
},
|
||||||
@@ -94,7 +99,12 @@ export const Conference = ({
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
// do not rely on the userConfig object directly as its reference may change on every render
|
// do not rely on the userConfig object directly as its reference may change on every render
|
||||||
}, [userConfig.videoDeviceId, userConfig.audioDeviceId])
|
}, [
|
||||||
|
userConfig.videoDeviceId,
|
||||||
|
userConfig.audioDeviceId,
|
||||||
|
isAdaptiveStreamSupported,
|
||||||
|
isDynacastSupported,
|
||||||
|
])
|
||||||
|
|
||||||
const room = useMemo(() => new Room(roomOptions), [roomOptions])
|
const room = useMemo(() => new Room(roomOptions), [roomOptions])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user