SoundCloud Auto如何在他们的移动网站上播放下一首歌? [英] How is SoundCloud Auto Playing the next song on their mobile site?

查看:107
本文介绍了SoundCloud Auto如何在他们的移动网站上播放下一首歌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我知道iOS不允许自动播放,但SoundCloud如何在他们的移动网站上自动播放下一首歌?

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

我可以得到我要填写iframe src的下一首歌曲,并重新加载小部件以显示该曲目。

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

我尝试了很多变通方法,即使我在下一首曲目准备就绪时调用'sc.play()'方法,我仍然无法将其变为自动玩。 iframe上的橙色大按钮变为暂停按钮,但它不会播放。我必须再次按下按钮才能开始播放。

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.

让用户启动第一次播放很好,但SC如何自动播放下一首曲目?

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

推荐答案

看看用JavaScript控制媒体,清单4-4按顺序替换媒体,您将找到以下示例代码:

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.

这篇关于SoundCloud Auto如何在他们的移动网站上播放下一首歌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆