【问题标题】:Some streaming SoundCloud songs fail to stream on iOS with errors某些流式 SoundCloud 歌曲无法在 iOS 上流式传输并出现错误
【发布时间】:2015-12-04 20:52:29
【问题描述】:

我正在使用 AVPlayer 在我的应用程序中流式传输 SoundCloud 歌曲,但其中一些不起作用,尽管流式传输标志为真。 Kendrick Lamar 的“Black Friday”是一首无效歌曲的例子,带有流媒体 URL

https://api.soundcloud.com/tracks/234989572/stream?client_id={MY_CLIENT_ID} 

(当然,{MY_CLIENT_ID} 是实际 ID)

这是 AVPlayerItem 返回的错误(同样隐藏了真实的客户端 ID):

Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." 
UserInfo=0x7fe735752340 {NSUnderlyingError=0x7fe735751e30 "The operation couldn’t be completed. (OSStatus error -12938.)",
NSErrorFailingURLStringKey=https://api.soundcloud.com/tracks/234989572/stream?client_id={MY_CLIENT_ID},
NSErrorFailingURLKey=https://api.soundcloud.com/tracks/234989572/stream?client_id={MY_CLIENT_ID},
NSURL=https://api.soundcloud.com/tracks/234989572/stream?client_id={MY_CLIENT_ID},
NSLocalizedDescription=The requested URL was not found on this server.}

大多数歌曲都可以正常播放,例如 G-Eazy 的“Everything Will Be OK”。网址:

https://api.soundcloud.com/tracks/236005149/stream?client_id={MY_CLIENT_ID}

为什么有些歌曲,比如黑色星期五,失败了?

【问题讨论】:

    标签: ios soundcloud avplayer


    【解决方案1】:

    该曲目的发布者已选择不为其提供 mp3 流。不幸的是,由于一些非常复杂的原因,在您实际尝试获取流之前,无法判断会发生这种情况。这是一件非常令人沮丧的事情,但是当我说原因很复杂时,请相信我。

    也许在尝试播放之前向流端点发送 HEAD 请求会有所帮助?

    【讨论】:

    • 我不买这个答案。使用api-mobileweb.soundcloud.com 上的trending-tracks 端点,我得到一个http_mp3_128_url 返回值。必须为网络播放器和移动应用程序公开一个 mp3,但我认为这都是私有的。
    • 不建议使用 api.soundcloud.com 之外的 api-* 域。它们由内部 SC 应用程序使用,因此不会被公开记录,也不能保证它们将来会继续表现相同(甚至存在)。
    猜你喜欢
    • 2014-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多