Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is SoundCloud Auto Playing the next song on their mobile site?

Okay, so I know that iOS doesn't allow auto-play, but how is SoundCloud auto-playing the next song on their mobile site?

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

I have tried many workarounds, even if I call the 'sc.play()' method when the next track is ready I still can't get it to auto-play. The big orange button on the iframe changes to the pause button, but it just won't play. I have to hit the button again to get playback to start.

Having the user initiate the first play is fine, but how is SC auto-playing the next track?

like image 377
Elliott McNary Avatar asked Dec 17 '15 09:12

Elliott McNary


People also ask

How do I stop SoundCloud from playing automatically?

You can disable or enable app playback through the track's edit page in the 'Permissions' tab. You can access this edit page at any time through the pencil icon under it's waveform.

How do I make SoundCloud autoplay?

Customize your player You also have the option to turn on autoplay by clicking the box next to 'Enable automatic play'. By doing this, your embedded player will play as soon as your website or blog's page is loaded.

What is SoundCloud widget?

With our new SoundCloud widget, you'll get an option to implement any kind of content on your website: tracks, artists, albums, playlists, podcasts. You are free to add any kind of player's elements: like button, download button or share button.


2 Answers

take a look at Controlling Media with JavaScript at Apple's website, in the Listing 4-4 Replacing media sequentially, you will find the following sample code:

<!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 does not work, but i think you can easily change it to what you want.

like image 96
Allen Avatar answered Oct 23 '22 03:10

Allen


i have worked on soundcloud API , so i know this. When you search for particular song then in response it gives many song url (buffering URL), so simply they are putting all the url in the queue. So as soon as one song completes next starts.

like image 26
Indrajit Chavda Avatar answered Oct 23 '22 04:10

Indrajit Chavda