By default browsers like google chrome does not allow media play before user interaction with the page, use can fake an interaction using fireEvent or userEvent librarires (which I failed to do) or get access to users mediaDevices (you can also get access to video but that was not required)
AudioContext class is used to genrate audio
document.visibility tells that wahether user is on the page or not