SoundCloud API 流 ios / iphone

SoundCloud API stream on ios / iphone

通过 SC API / Javascript SDK 2.0.0 的流操作是否可以在 iOS/Safari 上运行? 我发现它不适用于下面的简单示例。

似乎 SoundManager 能够知道如何以及何时使用 html5。我错了吗?

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<h1>Sound Cloud iOS test</h1>
<script src="//connect.soundcloud.com/sdk-2.0.0.js"></script>
<script type="text/javascript">
    SC.initialize({
        client_id: "YOUR_CLIENT_ID"
    });

    SC.stream(
            '/tracks/293',
            function(sound) {
                sound.play()
            }
    );
</script>
</body>
</html>

未经用户启动,您不能在 iOS 设备上的 Safari 中强制播放或下载任何 audio/video 文件。

In Safari on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and autoplay are disabled. No data is loaded until the user initiates it. This means the JavaScript play() and load() methods are also inactive until the user initiates playback, unless the play() or load() method is triggered by user action. In other words, a user-initiated Play button works, but an onLoad="play()" event does not.

This plays the movie: <input type="button" value="Play" onclick="document.myMovie.play()">

This does nothing on iOS: <body onload="document.myMovie.play()">

您需要将播放操作包装到一个按钮中,以便选择加入音频流而不是自动播放。

查看 Safari 文档中的 this article 以供参考。