mirror of
https://github.com/mempool/mempool.git
synced 2025-01-09 23:16:48 +01:00
22 lines
416 B
TypeScript
22 lines
416 B
TypeScript
|
import { Injectable } from '@angular/core';
|
||
|
|
||
|
@Injectable({
|
||
|
providedIn: 'root'
|
||
|
})
|
||
|
export class AudioService {
|
||
|
audio = new Audio();
|
||
|
|
||
|
constructor() { }
|
||
|
|
||
|
public playSound(name: 'magic' | 'chime' | 'cha-ching') {
|
||
|
try {
|
||
|
this.audio.src = '../../../assets/sounds/' + name + '.mp3';
|
||
|
this.audio.load();
|
||
|
this.audio.play();
|
||
|
} catch (e) {
|
||
|
console.log('Play sound failed', e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|