Add audible notifcation on broadcast error (#10654)
* Add audible notifcation on broadcast error * Add error audio file * Add error ogg * Catch play broadcast error * Await play error sound * Add promise error handling * Add comment about audio elements
This commit is contained in:
parent
9aade5a4d5
commit
0a6fe83a8c
4 changed files with 65 additions and 0 deletions
|
@ -46,6 +46,7 @@ import { ActionPayload } from "../../dispatcher/payloads";
|
|||
import { VoiceBroadcastChunkEvents } from "../utils/VoiceBroadcastChunkEvents";
|
||||
import { RelationsHelper, RelationsHelperEvent } from "../../events/RelationsHelper";
|
||||
import { createReconnectedListener } from "../../utils/connection";
|
||||
import { localNotificationsAreSilenced } from "../../utils/notifications";
|
||||
|
||||
export enum VoiceBroadcastRecordingEvent {
|
||||
StateChanged = "liveness_changed",
|
||||
|
@ -333,10 +334,29 @@ export class VoiceBroadcastRecording
|
|||
* It sets the connection error state and stops the recorder.
|
||||
*/
|
||||
private async onConnectionError(): Promise<void> {
|
||||
this.playConnectionErrorAudioNotification().catch(() => {
|
||||
// Error logged in playConnectionErrorAudioNotification().
|
||||
});
|
||||
await this.stopRecorder(false);
|
||||
this.setState("connection_error");
|
||||
}
|
||||
|
||||
private async playConnectionErrorAudioNotification(): Promise<void> {
|
||||
if (localNotificationsAreSilenced(this.client)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Audio files are added to the document in Element Web.
|
||||
// See <audio> elements in https://github.com/vector-im/element-web/blob/develop/src/vector/index.html
|
||||
const audioElement = document.querySelector<HTMLAudioElement>("audio#errorAudio");
|
||||
|
||||
try {
|
||||
await audioElement?.play();
|
||||
} catch (e) {
|
||||
logger.warn("error playing 'errorAudio'", e);
|
||||
}
|
||||
}
|
||||
|
||||
private async uploadFile(chunk: ChunkRecordedPayload): ReturnType<typeof uploadFile> {
|
||||
return uploadFile(
|
||||
this.client,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue