How does SoundCloud Auto play the next song on a mobile site?

Okay, so I know that iOS doesn't let you play automatically, but how does SoundCloud automatically play the next song on your mobile site?

I can get the next song that the iframe src I want to fill, and the widget reloads to display this track.

I tried many workarounds, even if I call the sc.play () method when the next track is ready, I still can’t play it automatically. The big orange button on the iframe changes to the pause button, but it just won’t play. I need to press the button again to start playback.

When the user starts the first game, this is good, but how does SC automatically play the next track?

+6
source share
2 answers

take a look at Managing Media with JavaScript on the Apple website in Listing 4-4. Replacing the media in series, you will find the following code example:

<!doctype html> <html> <head> <title>Sequential Movies</title> <script type="text/javascript"> // listener function changes src function myNewSrc() { var myVideo = document.getElementsByTagName('video')[0]; myVideo.src = "http://homepage.mac.com/qt4web/myMovie.m4v"; myVideo.load(); myVideo.play(); } // add a listener function to the ended event function myAddListener(){ var myVideo = document.getElementsByTagName('video')[0]; myVideo.addEventListener('ended', myNewSrc, false); } </script> </head> <body onload="myAddListener()"> <video controls src="http://homepage.mac.com/qt4web/A-chord.m4v"> </video> </body> </html> 

the video doesn't work, but I think you can easily change it to what you want.

+3
source

I worked on the soundcloud API, so I know this. When you are looking for a specific song, then in response it gives a lot of song URLs (buffer URL), so they just put the entire URL in the queue. So, as soon as one song completes the next launches.

+2
source

All Articles