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

£可爱£侵袭症+ 提交于 2019-12-05 06:36:20

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!