mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-07 15:08:24 +00:00
Add more debug logging to try and find out why ring and ringback sounds aren't playing (#8772)
To better investigate https://github.com/vector-im/element-web/issues/20832
This commit is contained in:
+18
-4
@@ -375,6 +375,8 @@ export default class CallHandler extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public play(audioId: AudioID): void {
|
public play(audioId: AudioID): void {
|
||||||
|
const logPrefix = `CallHandler.play(${audioId}):`;
|
||||||
|
logger.debug(`${logPrefix} beginning of function`);
|
||||||
// TODO: Attach an invisible element for this instead
|
// TODO: Attach an invisible element for this instead
|
||||||
// which listens?
|
// which listens?
|
||||||
const audio = document.getElementById(audioId) as HTMLMediaElement;
|
const audio = document.getElementById(audioId) as HTMLMediaElement;
|
||||||
@@ -383,13 +385,15 @@ export default class CallHandler extends EventEmitter {
|
|||||||
try {
|
try {
|
||||||
// This still causes the chrome debugger to break on promise rejection if
|
// This still causes the chrome debugger to break on promise rejection if
|
||||||
// the promise is rejected, even though we're catching the exception.
|
// the promise is rejected, even though we're catching the exception.
|
||||||
|
logger.debug(`${logPrefix} attempting to play audio`);
|
||||||
await audio.play();
|
await audio.play();
|
||||||
|
logger.debug(`${logPrefix} playing audio successfully`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// This is usually because the user hasn't interacted with the document,
|
// This is usually because the user hasn't interacted with the document,
|
||||||
// or chrome doesn't think so and is denying the request. Not sure what
|
// or chrome doesn't think so and is denying the request. Not sure what
|
||||||
// we can really do here...
|
// we can really do here...
|
||||||
// https://github.com/vector-im/element-web/issues/7657
|
// https://github.com/vector-im/element-web/issues/7657
|
||||||
logger.log("Unable to play audio clip", e);
|
logger.warn(`${logPrefix} unable to play audio clip`, e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (this.audioPromises.has(audioId)) {
|
if (this.audioPromises.has(audioId)) {
|
||||||
@@ -400,20 +404,30 @@ export default class CallHandler extends EventEmitter {
|
|||||||
} else {
|
} else {
|
||||||
this.audioPromises.set(audioId, playAudio());
|
this.audioPromises.set(audioId, playAudio());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn(`${logPrefix} unable to find <audio> element for ${audioId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public pause(audioId: AudioID): void {
|
public pause(audioId: AudioID): void {
|
||||||
|
const logPrefix = `CallHandler.pause(${audioId}):`;
|
||||||
|
logger.debug(`${logPrefix} beginning of function`);
|
||||||
// TODO: Attach an invisible element for this instead
|
// TODO: Attach an invisible element for this instead
|
||||||
// which listens?
|
// which listens?
|
||||||
const audio = document.getElementById(audioId) as HTMLMediaElement;
|
const audio = document.getElementById(audioId) as HTMLMediaElement;
|
||||||
|
const pauseAudio = () => {
|
||||||
|
logger.debug(`${logPrefix} pausing audio`);
|
||||||
|
// pause doesn't return a promise, so just do it
|
||||||
|
audio.pause();
|
||||||
|
};
|
||||||
if (audio) {
|
if (audio) {
|
||||||
if (this.audioPromises.has(audioId)) {
|
if (this.audioPromises.has(audioId)) {
|
||||||
this.audioPromises.set(audioId, this.audioPromises.get(audioId).then(() => audio.pause()));
|
this.audioPromises.set(audioId, this.audioPromises.get(audioId).then(pauseAudio));
|
||||||
} else {
|
} else {
|
||||||
// pause doesn't return a promise, so just do it
|
pauseAudio();
|
||||||
audio.pause();
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn(`${logPrefix} unable to find <audio> element for ${audioId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user