diff --git a/.changeset/long-trees-rule.md b/.changeset/long-trees-rule.md new file mode 100644 index 0000000000..3d1dfab451 --- /dev/null +++ b/.changeset/long-trees-rule.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Add check for getSynchronizationSources support diff --git a/src/room/track/RemoteTrack.ts b/src/room/track/RemoteTrack.ts index d307e68503..9961c2d545 100644 --- a/src/room/track/RemoteTrack.ts +++ b/src/room/track/RemoteTrack.ts @@ -2,6 +2,7 @@ import { TrackEvent } from '../events'; import { monitorFrequency } from '../stats'; import type { LoggerOptions } from '../types'; import { Track } from './Track'; +import { supportsSynchronizationSources } from './utils'; export default abstract class RemoteTrack< TrackKind extends Track.Kind = Track.Kind, @@ -77,7 +78,9 @@ export default abstract class RemoteTrack< if (!this.monitorInterval) { this.monitorInterval = setInterval(() => this.monitorReceiver(), monitorFrequency); } - this.registerTimeSyncUpdate(); + if (supportsSynchronizationSources()) { + this.registerTimeSyncUpdate(); + } } protected abstract monitorReceiver(): void; diff --git a/src/room/track/utils.ts b/src/room/track/utils.ts index 2a4f576840..0353c24932 100644 --- a/src/room/track/utils.ts +++ b/src/room/track/utils.ts @@ -239,3 +239,7 @@ export function getLogContextFromTrack(track: Track | TrackPublication): Record< }; } } + +export function supportsSynchronizationSources(): boolean { + return typeof RTCRtpReceiver !== 'undefined' && 'getSynchronizationSources' in RTCRtpReceiver; +}