Calling support

This commit is contained in:
Peter Thatcher 2020-06-04 11:16:19 -07:00 committed by Scott Nonnenberg
parent 83574eb067
commit d3a27a6442
72 changed files with 3864 additions and 191 deletions

44
ts/util/callingTones.ts Normal file
View file

@ -0,0 +1,44 @@
import { Sound, SoundOpts } from './Sound';
async function playSound(howlProps: SoundOpts): Promise<Sound | undefined> {
const canPlayTone = await window.getCallRingtoneNotification();
if (!canPlayTone) {
return;
}
const tone = new Sound(howlProps);
await tone.play();
return tone;
}
class CallingTones {
private ringtone?: Sound;
async playEndCall() {
await playSound({
src: 'sounds/navigation-cancel.ogg',
});
}
async playRingtone() {
if (this.ringtone) {
this.stopRingtone();
}
this.ringtone = await playSound({
loop: true,
src: 'sounds/ringtone_minimal.ogg',
});
}
stopRingtone() {
if (this.ringtone) {
this.ringtone.stop();
this.ringtone = undefined;
}
}
}
export const callingTones = new CallingTones();