Skip to content

Commit 2f12e0a

Browse files
authored
Merge pull request #165 from NINE78/release-audio-resources
Release-audio-resources
2 parents 8b80210 + cf23675 commit 2f12e0a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/sip-core.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ export class SIPCore {
9090
public user!: User;
9191
public config!: SIPCoreConfig;
9292

93-
private heartBeatHandle: number | null = null;
93+
private heartBeatHandle: ReturnType<typeof setInterval> | null = null;
9494
private heartBeatIntervalMs: number = 30000;
9595

96-
private callTimerHandle: number | null = null;
96+
private callTimerHandle: ReturnType<typeof setInterval> | null = null;
9797

9898
private wssUrl!: string;
99-
private iceCandidateTimeout: number | null = null;
99+
private iceCandidateTimeout: ReturnType<typeof setTimeout> | null = null;
100100

101101
public remoteAudioStream: MediaStream | null = null;
102102
public remoteVideoStream: MediaStream | null = null;
@@ -351,6 +351,7 @@ export class SIPCore {
351351

352352
playIncomingRingtone(): void {
353353
if (this.incomingAudio) {
354+
this.incomingAudio.src = this.config.incomingRingtoneUrl;
354355
this.incomingAudio.play().catch((error) => {
355356
console.error("Incoming ringtone failed:", error);
356357
});
@@ -361,13 +362,16 @@ export class SIPCore {
361362
if (this.incomingAudio) {
362363
this.incomingAudio.pause();
363364
this.incomingAudio.currentTime = 0;
365+
this.incomingAudio.src = "";
366+
this.incomingAudio.load();
364367
}
365368
}
366369

367370
playOutgoingTone(): void {
368371
if (this.outgoingAudio) {
372+
this.outgoingAudio.src = this.config.outgoingRingtoneUrl;
369373
this.outgoingAudio.play().catch((error) => {
370-
console.error("Incoming ringtone failed:", error);
374+
console.error("Outgoing ringtone failed:", error);
371375
});
372376
}
373377
}
@@ -376,6 +380,8 @@ export class SIPCore {
376380
if (this.outgoingAudio) {
377381
this.outgoingAudio.pause();
378382
this.outgoingAudio.currentTime = 0;
383+
this.outgoingAudio.src = "";
384+
this.outgoingAudio.load();
379385
}
380386
}
381387

0 commit comments

Comments
 (0)