AudioId -> AudioID

This commit is contained in:
David Baker 2020-10-12 09:55:21 +01:00
parent 55f77b04ae
commit 94802036d9

View file

@ -79,7 +79,7 @@ import { WidgetMessagingStore } from "./stores/widgets/WidgetMessagingStore";
import { ElementWidgetActions } from "./stores/widgets/ElementWidgetActions"; import { ElementWidgetActions } from "./stores/widgets/ElementWidgetActions";
import { MatrixCall, CallErrorCode, CallState, CallType } from "matrix-js-sdk/lib/webrtc/call"; import { MatrixCall, CallErrorCode, CallState, CallType } from "matrix-js-sdk/lib/webrtc/call";
enum AudioId { enum AudioID {
Ring = 'ringAudio', Ring = 'ringAudio',
Ringback = 'ringbackAudio', Ringback = 'ringbackAudio',
CallEnd = 'callendAudio', CallEnd = 'callendAudio',
@ -88,7 +88,7 @@ enum AudioId {
export default class CallHandler { export default class CallHandler {
private calls = new Map<string, MatrixCall>(); private calls = new Map<string, MatrixCall>();
private audioPromises = new Map<AudioId, Promise<void>>(); private audioPromises = new Map<AudioID, Promise<void>>();
static sharedInstance() { static sharedInstance() {
if (!window.mxCallHandler) { if (!window.mxCallHandler) {
@ -126,7 +126,7 @@ export default class CallHandler {
return null; return null;
} }
play(audioId: AudioId) { play(audioId: AudioID) {
// 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;
@ -155,7 +155,7 @@ export default class CallHandler {
} }
} }
pause(audioId: AudioId) { pause(audioId: AudioID) {
// 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;
@ -195,19 +195,19 @@ export default class CallHandler {
switch (oldState) { switch (oldState) {
case CallState.Ringing: case CallState.Ringing:
this.pause(AudioId.Ring); this.pause(AudioID.Ring);
break; break;
case CallState.InviteSent: case CallState.InviteSent:
this.pause(AudioId.Ringback); this.pause(AudioID.Ringback);
break; break;
} }
switch (newState) { switch (newState) {
case CallState.Ringing: case CallState.Ringing:
this.play(AudioId.Ring); this.play(AudioID.Ring);
break; break;
case CallState.InviteSent: case CallState.InviteSent:
this.play(AudioId.Ringback); this.play(AudioID.Ringback);
break; break;
case CallState.Ended: case CallState.Ended:
this.removeCallForRoom(call.roomId); this.removeCallForRoom(call.roomId);
@ -215,13 +215,13 @@ export default class CallHandler {
call.hangupParty === "remote" || call.hangupParty === "remote" ||
(call.hangupParty === "local" && call.hangupReason === "invite_timeout") (call.hangupParty === "local" && call.hangupReason === "invite_timeout")
)) { )) {
this.play(AudioId.Busy); this.play(AudioID.Busy);
Modal.createTrackedDialog('Call Handler', 'Call Timeout', ErrorDialog, { Modal.createTrackedDialog('Call Handler', 'Call Timeout', ErrorDialog, {
title: _t('Call Timeout'), title: _t('Call Timeout'),
description: _t('The remote side failed to pick up') + '.', description: _t('The remote side failed to pick up') + '.',
}); });
} else { } else {
this.play(AudioId.CallEnd); this.play(AudioID.CallEnd);
} }
} }
}); });