Click button to start song on all connected clients

The need is simple…

A person clicks play, and all the connected clients start playing the audio file at the same time.

There’s a problem with autoplaying audio on mobile devices and though messages are realtime in Meteor that’s 'cause of Mongodb

There must be a way around this.

Could we use events and stream the audio to the client like a WebRTC app (which is of course of limited availability)…

We could have people press play and then prevent the action from starting until an update reactively lifts the block…

What other ideas does anyone have?

Why not have all clients subscribed to a database that has a variable whether or not audio is playing?

seems to me you need something like WAMP

not sure how to implement that in meteor though

Meteor already has all of the functionality of WAMP. @95shane has the right idea - you just subscribe to a document in the database that has a field which indicates whether to start playing or not.

Check this out:

Thanks for the suggestions -

So far I’d got as far as this…

  1. clients go to a route and triggers a download
  2. clients click play (can’t think of any way around the iOS and Android restrictions)
  3. click event starts play then pauses until
  4. other client with a specific role presses play and the click event changes the variable everyone is subscribed to -

I had thought of using ReactiveVars - but yes of course, a database subscription is the obvious and simplest.

For the preloading and play/pause I thought of using adej:meteor-sounds

I’m not sure if that package only works with Cordova however - due to time constraints I may need this to be web-based (browser) before it is an app.



Is there some source code to go with this?

Neat, thanks for sharing, I can learn from this.