Address tracking and notification sounds.
This commit is contained in:
21
frontend/src/app/services/audio.service.ts
Normal file
21
frontend/src/app/services/audio.service.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user