0

I am new to ConverseJS Development. ConverseJS initialize() will set DEFAULT settings just once...I want to achieve the following : Play a sound only when browser window is not in focus and a new message arrives. Is there an option where I can ADD attributes like play_sounds to true when some event is triggered like we have in jQuery as follows :

$('#datePickerId').datepicker('option', 'minDate', '3');

For now my current code is as follows :

converse.listen.on('message', function (messageXML) {   

            if(false === document.hasFocus()){
                console.log("Window is NOT in FOCUS");
                converse.initialize({
                    play_sounds: true
                });

            } 
        });

But this is as good as setting play_sounds for all my messages...Is there a way I can TOGGLE play sounds to ON and OFF based on Window focus...

Any help would be great. Thanks !

Gauri Padbidri
  • 371
  • 4
  • 15

1 Answers1

0

Take a look at below link Converse js provide such a feature out of the box.

https://conversejs.org/docs/html/configuration.html#play-sounds

Sorry for posting it here rather than comment because i was not allowed to put comments on question.