mempool/frontend/src/app/services/audio.service.ts
softsimon 4dacf292c2
Adding logger wrapper.
Log backend messages to syslog.
fixes #135
2020-10-13 15:27:52 +07:00

25 lines
565 B
TypeScript

import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class AudioService {
audio = new Audio();
isPlaying = false;
constructor() { }
public playSound(name: 'magic' | 'chime' | 'cha-ching' | 'bright-harmony') {
if (this.isPlaying) {
return;
}
this.isPlaying = true;
this.audio.src = '../../../resources/sounds/' + name + '.mp3';
this.audio.load();
this.audio.play().catch((e) => {
console.log('Play sound failed' + e);
});
setTimeout(() => this.isPlaying = false, 100);
}
}