mirror of
https://github.com/jambonz/webrtc-client.git
synced 2025-12-19 08:37:45 +00:00
-remote audio fix
This commit is contained in:
@@ -33,7 +33,9 @@ export default class SipAudioElements {
|
||||
}
|
||||
|
||||
pauseRinging(): void {
|
||||
this.#ringing.pause();
|
||||
if (!this.#ringing.paused) {
|
||||
this.#ringing.pause();
|
||||
}
|
||||
}
|
||||
|
||||
playFailed(volume: number | undefined): void {
|
||||
@@ -60,4 +62,9 @@ export default class SipAudioElements {
|
||||
this.#remote.srcObject = stream;
|
||||
this.#remote.play();
|
||||
}
|
||||
|
||||
isPLaying(audio: HTMLAudioElement) {
|
||||
return audio.currentTime > 0 && !audio.paused && !audio.ended
|
||||
&& audio.readyState > audio.HAVE_CURRENT_DATA;
|
||||
}
|
||||
}
|
||||
@@ -174,16 +174,16 @@ export default class SipSession extends events.EventEmitter {
|
||||
direction: this.#rtcSession.direction
|
||||
})
|
||||
});
|
||||
pc.addEventListener('track', (event: RTCPeerConnectionEventMap["track"]): void => {
|
||||
const stream: MediaStream = new MediaStream([event.track])
|
||||
if (this.#rtcSession.direction === 'outgoing') {
|
||||
this.#audio.pauseRinging();
|
||||
}
|
||||
this.#audio.playRemote(stream);
|
||||
this.emit(SipConstants.SESSION_TRACK, {
|
||||
direction: this.#rtcSession.direction
|
||||
});
|
||||
});
|
||||
// pc.addEventListener('track', (event: RTCPeerConnectionEventMap["track"]): void => {
|
||||
// const stream: MediaStream = new MediaStream([event.track])
|
||||
// if (this.#rtcSession.direction === 'outgoing') {
|
||||
// this.#audio.pauseRinging();
|
||||
// }
|
||||
// this.#audio.playRemote(stream, "track");
|
||||
// this.emit(SipConstants.SESSION_TRACK, {
|
||||
// direction: this.#rtcSession.direction
|
||||
// });
|
||||
// });
|
||||
};
|
||||
|
||||
get rtcSession() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as events from "events";
|
||||
import {UA, WebSocketInterface} from "jssip";
|
||||
import {UA, WebSocketInterface, debug} from "jssip";
|
||||
import {DisconnectEvent} from "jssip/lib/WebSocketInterface";
|
||||
import {RTCSession} from "jssip/lib/RTCSession";
|
||||
import {
|
||||
@@ -26,6 +26,7 @@ export default class SipUA extends events.EventEmitter {
|
||||
|
||||
constructor(client: SipModel.ClientAuth, settings: SipModel.ClientOptions) {
|
||||
super();
|
||||
debug.enable('JsSIP:*');
|
||||
this.#sessionManager = new SessionManager();
|
||||
this.#rtcConfig = settings.pcConfig;
|
||||
this.#ua = new UA({
|
||||
|
||||
Reference in New Issue
Block a user