Skip to content

Commit

Permalink
Fix: Safari tracker announcement issue (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaDemchenko authored Jul 19, 2024
1 parent 6549f70 commit 363038f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/p2p-media-loader-core/src/p2p/tracker-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ type P2PTrackerClientEventHandlers = {
onSegmentsAnnouncement: () => void;
};

function isSafariBrowser() {
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
}

export class P2PTrackerClient {
private readonly streamShortId: string;
private readonly client: TrackerClient;
Expand All @@ -47,7 +51,9 @@ export class P2PTrackerClient {
this.client = new TrackerClient({
infoHash: utf8ToUintArray(streamHash),
peerId: utf8ToUintArray(peerId),
announce: this.config.announceTrackers,
announce: isSafariBrowser()
? config.announceTrackers.slice(0, 1) // Safari has issues with multiple trackers
: config.announceTrackers,
rtcConfig: this.config.rtcConfig,
});
this.client.on("peer", this.onReceivePeerConnection);
Expand Down

0 comments on commit 363038f

Please sign in to comment.