lukejacksonn / react-slack-clone

Complete chat application, built with Chatkit | by @lukejacksonn
https://pusher.com/chatkit
MIT License
1.35k stars 262 forks source link

Play sound new notif #65

Open alexey13 opened 6 years ago

alexey13 commented 6 years ago

var audio = new Audio(); audio.preload = 'auto'; audio.src = '/path'; audio.play(); const notification = new Notification(...

I used this one https://freesound.org/people/Thoribass/sounds/253595/ Convert to mp3

lukejacksonn commented 6 years ago

Nice one @alexey13 and good idea.. what happens if you receive a lot of messages at once? Do you debounce this call or something?

alexey13 commented 6 years ago

You mean user send to another user messages one by one? No, not debounce. Interesting scenario, need to test it in real life. When I use chat on a desktop and hear the sound (whatsapp desktop using sound) I focus on the chat window, if I do not want to hear the sound I just turn it off in that window of a browser.

alexey13 commented 6 years ago

But I think debounce nice idea. For example 1 sound in 3 seconds

alexey13 commented 6 years ago

I think this one we can use https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events If playing not play

lukejacksonn commented 6 years ago

Nice.. well maybe with a slightly shorter sound and checking to see if we are already playing a sound we could make this work.