ha bizde o şekilde istiyoruz hocam zaten ekliym konuya sağolasın
e tamam mantığı bu işte. teoride aşağıdaki örnek çalışmalı. test eder misin?
socket.addEventListener('message', (event) => {
const data = JSON.parse(event.data);
if (data.event === 'notificationSent') {
const notificationList = document.getElementById('bildirim-alani');
const newNotification = document.createElement('bildirim-elementi');
newNotification.textContent = data.message;
notificationList.appendChild(newNotification);
// Bildirim sonrası 500ms bekleyip ses çalma
setTimeout(() => {
// Ses dosyasını yükleyip çalıyoruz
const audio = new Audio('alert.mp3'); // Burada ses dosyasının yolu belirtilmeli
audio.play();
}, 500); // 500ms sonra ses çalması
}
});