Getting data to front end

Hello all, I am new to full-stack development and am not sure how to go about what im imagining.
Here is the situation:
I have a program that has a “dj” that can control music (play, pause, next) and “viewers” that listen to the music. All of the playback is going through using each viewers own music accounts, so there is no streaming element to this. Essentially I need to tell the viewers front end to play/pause/next whenever the dj does an action.

My thoughts:
I currently think that I will send a call to my backend from my dj account telling it what the action was. The viewer accounts would be pinging the backend every 1 or 2 seconds to see if an action was made and if it was, then it would complete the action.

My Question:
Is there a way to send the action request from my backend to the viewers front end. *Essentially: Is there another method of getting information to the front end from the backend that doesn’t require all the front ends to ping the server?

I think web sockets are what you want. It hooks up a connection where each client can send information to the server and the server can send info (events) back to all the clients.

Ill look into that. Thanks Kevin!

If you’re using Node.js look up socket.io

You can emit a signal + some data from the backend on some condition, which is received by the client. On receipt, the client can do something with that data. Client can also send to the backend in the same way. The transfer is basically instantaneous. If you wanted to write a setTimeout() or setInterval() function you could emit after a certain amount of time like you say, instead of on some other condition.