I'm working to add a bell notification when any new data row inserted in the attached table this will give sound bell. (very similarly when we receive new message we get notification sound bell on Facebook)
I'm able to make the function of the bell this below
function ding() {
var bell = new Audio("/public/sounds/Notification%201.mp3");
bell.play();
}
now the problem I'm facing the bell not working when new data row inserted i have tried many codes like below
$("#theTable").on("change", function() {
function ding() {
var bell = new Audio("/public/sounds/Notification%201.mp3");
bell.play();
}
});
I'm working to add a bell notification when any new data row inserted in the attached table this will give sound bell. (very similarly when we receive new message we get notification sound bell on Facebook)
I'm able to make the function of the bell this below
function ding() {
var bell = new Audio("https://facebook.design/public/sounds/Notification%201.mp3");
bell.play();
}
now the problem I'm facing the bell not working when new data row inserted i have tried many codes like below
$("#theTable").on("change", function() {
function ding() {
var bell = new Audio("https://facebook.design/public/sounds/Notification%201.mp3");
bell.play();
}
});
Share
Improve this question
asked Jan 19, 2020 at 17:14
Aadii MughalAadii Mughal
1711 gold badge1 silver badge9 bronze badges
3
- 1 I doubt it that the 'change' event is a valid one for your situation. You should try to add a function that reads the total amount of rows and when that changes it will ring the bell. – Cornel Raiu Commented Jan 19, 2020 at 18:34
- total quantity of tables row? can u advice me further how i can check total row in table – Aadii Mughal Commented Jan 20, 2020 at 8:14
- 1 Please post the HTML that is used to build the table so that I can write the JS for doing that. – Cornel Raiu Commented Jan 20, 2020 at 8:21
1 Answer
Reset to default -1There may be browser restrictions preventing autoplaying audio, see this answer https://stackoverflow/questions/53058421/local-variable-audio-in-object-method-not-playing
You can see this in your browser developer tools console, there will be error like this NotAllowedError: The play method is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
If this sound notification is needed only for some specific users, you can change their browser policy to allow autoplay.