Is there a way to check new updates in the database without using setInterval? The problem is that I want to update the video source in the video tag but if I check for update every second, then my video will keep refreshing. I just want the video to refresh if the database is updated. For example, If I have a cat video in the current_video column in database, then the cat video should play. Otherwise, if I update the video to dog video, only then will the video element change to dog video.
$.get("/musicmania/playing/getCurrentSongDir", function(data, status){
setInterval(function(){
$("#video").html("<source src='/musicmania/app/resources/"
+ data + "' type='video/mp4'></source>");
}, 500);
});