Add NotificationSound component and associated Blade view for audio notifications

This commit is contained in:
dhanabalan
2025-09-16 15:04:20 +05:30
parent 40ef91a60b
commit 93b1138752
2 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
{{-- <div>
{{-- Do your work, then step back.
</div> --}}
<div>
@push('scripts')
<script>
window.addEventListener('play-notification-sound', () => {
const audio = new Audio('/sounds/click.mp3');
audio.play().catch(() => {
console.log("Sound blocked until user interacts with the page");
});
});
window.addEventListener('play-warn-sound', () => {
const audio = new Audio('/sounds/warning.mp3');
audio.play().catch(() => {
console.log("Sound blocked until user interacts with the page");
});
});
window.addEventListener('play-beep-sound', () => {
const audio = new Audio('/sounds/scanner-beep.mp3');
audio.play().catch(() => {
console.log("Sound blocked until user interacts with the page");
});
});
</script>
@endpush
</div>