diff --git a/public/audio/pop.mp3 b/public/audio/pop.mp3 new file mode 100644 index 0000000..769f6f0 Binary files /dev/null and b/public/audio/pop.mp3 differ diff --git a/src/app/chat/chat/channel-list/channel-entry/channel-entry.component.ts b/src/app/chat/chat/channel-list/channel-entry/channel-entry.component.ts index 434ad5e..374f607 100644 --- a/src/app/chat/chat/channel-list/channel-entry/channel-entry.component.ts +++ b/src/app/chat/chat/channel-list/channel-entry/channel-entry.component.ts @@ -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(); + } } } diff --git a/src/app/services/audio.service.ts b/src/app/services/audio.service.ts new file mode 100644 index 0000000..31052ff --- /dev/null +++ b/src/app/services/audio.service.ts @@ -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(); + } +}