Help! How to Play Mp3 sound When new data is added to database?

So here’s a scenario for all wappler geniuses, I have this admin application that uses action scheduler to check for a new addition to my database by users. When new data is added by a user, I want to play a sound to alert the admin on the admin page.

So can anyone please advise me how I can play an mp3 file when new data is added to my database?

Thanks in advance and I wish you all safety these trying times.

@Teodor @George @alexey @Freddy_Blockchain @Hyperbytes

You’ll first need to declare the audio in the body of the page (use .ogg for file size):

<audio id="NewUserAlert">
	<source src="../assets/audio/newuser/newBeep.ogg" type="audio/ogg">
</audio>

Add the following Javascript to the base of your page:

<script>
	var x = document.getElementById("NewUserAlert"); 

function playSuccess() { 
  x.play(); 
} 
</script>

Then based upon an event you’ll call a Static Event:

playSuccess(); 

We do this on most of our forms just so the User knows the data has been saved with success. Its a feature a lot of the Users requested so we implemented it for them a few months back. We use various sounds based upon the various event types. Works really well. Audio is often forgotten about in web applications. Its nice others are considering the same!

:slight_smile:

12 Likes

Hi Dave. Thank you. I have just seen this. This works pretty file as a global means to reference the audio file on x action. I will find a way to work around it for data increment. Thanks so much for this.

1 Like

Thanks @Dave. I hadn’t thought of adding UI sounds like this before. In case it’s of interest to anybody experimenting with this, here’s a nice selection of sound files.

2 Likes

Just a little additional info after banging my head on this problem for too many hours: this method works, however iOS devices will not play .ogg files in browser, but they play .mp3 files just fine with this method. ... and of course they only play after a previous user interaction with the page so put a toggle switch or something users turn on to enable the sounds.

1 Like