alert sounds
This commit is contained in:
parent
801003b101
commit
e46c716547
BIN
public/audio/pop.mp3
Normal file
BIN
public/audio/pop.mp3
Normal file
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { Channel } from '../../../../models/channel';
|
||||
import { AudioService } from '../../../../services/audio.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-channel-entry',
|
||||
@ -15,6 +16,8 @@ export class ChannelEntryComponent implements OnChanges {
|
||||
|
||||
public notifications: number = 0;
|
||||
|
||||
constructor(private audioService: AudioService) { }
|
||||
|
||||
ngOnChanges(_: SimpleChanges): void {
|
||||
if (this.selected) {
|
||||
this.notifications = 0;
|
||||
@ -22,6 +25,9 @@ export class ChannelEntryComponent implements OnChanges {
|
||||
}
|
||||
|
||||
public Notify() {
|
||||
if (!this.selected) this.notifications++;
|
||||
if (!this.selected) {
|
||||
this.notifications++;
|
||||
this.audioService.PlayNotification();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
16
src/app/services/audio.service.ts
Normal file
16
src/app/services/audio.service.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AudioService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
public PlayNotification(): void {
|
||||
let audio = new Audio();
|
||||
audio.src = 'audio/pop.mp3'
|
||||
audio.load();
|
||||
audio.play();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user