alert sounds

This commit is contained in:
BENEDEK László 2025-06-10 14:35:03 +02:00
parent 801003b101
commit e46c716547
3 changed files with 23 additions and 1 deletions

BIN
public/audio/pop.mp3 Normal file

Binary file not shown.

View File

@ -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();
}
}
}

View 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();
}
}