Easy way to prevent autoplay when clicking on song or using next/prev

Hi there,

Is there any easy way to prevent songs from starting to play automatically when clicking on them or pressing next?

I’m hoping to use Amplitude in an event production setting where the standard practice is to queue up the next track, make sure the performer is ready, then press play.

Using callbacks, I have accomplished this by toggling a flag whenever there is a “song_change” and then testing for the flag whenever I see “playing” and then if it’s set, I immediately stop playback and change the appearance of the play-pause button. This is kind of a hack and does result in the play-pause button flickering.

I’ve gone as far as to look into the source code and I think I could accomplish this by testing for a flag before calling Core.play() in four places within utilities/audioNavigation (setNext, setNextPlaylist, setPrevious, setPreviousPlaylist) and then a few places within events/play and events/playPause (handlePlaylistPlay/PlayPause, handleSongPlay/PlayPause, handleSongInPlaylistPlay/PlayPause) but I don’t want to hack on your code if I don’t have to.

Thanks in advance!

Hi @kmo12345 ,

That’s a very interesting use case! Just so I understand correctly, you want to:

  1. Play through an entire song.
  2. Go to the next song, but don’t start playing.

We do have a flag in the config called continue_next which is set to true. You could turn this to false and that will stop a playlist from going to the next song. However, it will stop the active song and you’d have to click next to go to the next song in the playlist, which I don’t think you want to do.

What would you call this feature? queue_up_next_song? If you know how to implement it, I’d definitely be open to a PR on github GitHub - serversideup/amplitudejs: AmplitudeJS: Open Source HTML5 Web Audio Library. Design your web audio player, the way you want. No dependencies required.. Otherwise, I can implement it as well, I’d just need a hand with some use-cases on what you want to accomplish with it.