iOS Spotify Streaming SDK - Error: Context Failed 1006
iOS Spotify Streaming SDK - Error: Context Failed 1006
我正在使用'old' Streaming SDK,因为新的SDK不能满足我的需求。我让它工作得很好但是对于某些曲目我无法开始播放。我正在将消息打印到控制台,这是我得到的输出:
is playing: true
didReceivePlaybackEvent: SPPPlaybackNotifyPlay
didReceivePlaybackEvent: SPPPlaybackNotifyAudioFlush
didReceivePlaybackEvent: SPPPlaybackNotifyMetadataChanged
didReceivePlaybackEvent: SPPPlaybackNotifyAudioFlush
didReceivePlaybackEvent: SPPPlaybackNotifyAudioDeliveryDone
is playing: false
didReceivePlaybackEvent: SPPPlaybackNotifyPause
*** Received error: (1006)Context failed
didReceivePlaybackEvent: SPPPlaybackNotifyMetadataChanged
这些消息来自委托方法:
func audioStreaming(_ audioStreaming: SPTAudioStreamingController, didReceiveError error: Error) {
let nsError = error as NSError
print("*** Received error: (\(nsError.code))\(nsError.localizedDescription)")
}
func audioStreaming(_ audioStreaming: SPTAudioStreamingController, didChangePlaybackStatus isPlaying: Bool) {
print("is playing: \(isPlaying)")
}
func audioStreaming(_ audioStreaming: SPTAudioStreamingController, didReceive event: SpPlaybackEvent) {
print("didReceivePlaybackEvent: \(event)")
}
我相信我正确地初始化了我的播放器,它取自 Spotify 存储库中的官方示例应用程序:
do {
try player.start(withClientId: clientID, audioController: nil, allowCaching: true)
player.delegate = self
player.playbackDelegate = self
player.diskCache = SPTDiskCache(capacity: 1024 * 1024 * 64)
player.login(withAccessToken: session.accessToken)
setBitrate(preferredBitrate)
} catch let error {
delegate?.didReceiveError(self, error: error, priority: .test)
closeSession()
}
我查看了错误的文档,但代码 1006 或名称 SPTErrorContextFailed
没有错误
for err in [
SPTErrorCodeFailed,
SPTErrorCodeNoError,
SPTErrorCodeInitFailed,
SPTErrorCodeUnsupported,
SPTErrorCodeNeedsPremium,
SPTErrorCodeNullArgument,
SPTErrorCodeUninitialized,
SPTErrorCodeFailed,
SPTErrorCodeBadCredentials,
SPTErrorCodeInvalidArgument,
SPTErrorCodeNotActiveDevice,
SPTErrorCodeWrongAPIVersion,
SPTErrorCodeTrackUnavailable,
SPTErrorCodeApplicationBanned,
SPTErrorCodeGeneralLoginError,
SPTErrorCodeTravelRestriction,
SPTErrorCodePlaybackRateLimited,
SPTErrorCodeGeneralPlaybackError
] {
if nsError.code == err {
print(err) // It is not printed because there is no error
// 1006 declared
}
}
正如我所说,所有这些在大多数情况下都有效,但对于某些曲目,我遇到了错误,无法播放。我还用所有可用的比特率测试了曲目,但这并没有改变任何事情。
这可能是什么问题?
我明白了。有些曲目在我的地区不可用,但我的后端没有正确识别这些曲目。我修复了这个问题,现在只有可播放的曲目被传递给播放器,问题不再发生。
如果无法播放曲目,它将在 Spotify 桌面应用程序中显示为灰色
我正在使用'old' Streaming SDK,因为新的SDK不能满足我的需求。我让它工作得很好但是对于某些曲目我无法开始播放。我正在将消息打印到控制台,这是我得到的输出:
is playing: true
didReceivePlaybackEvent: SPPPlaybackNotifyPlay
didReceivePlaybackEvent: SPPPlaybackNotifyAudioFlush
didReceivePlaybackEvent: SPPPlaybackNotifyMetadataChanged
didReceivePlaybackEvent: SPPPlaybackNotifyAudioFlush
didReceivePlaybackEvent: SPPPlaybackNotifyAudioDeliveryDone
is playing: false
didReceivePlaybackEvent: SPPPlaybackNotifyPause
*** Received error: (1006)Context failed
didReceivePlaybackEvent: SPPPlaybackNotifyMetadataChanged
这些消息来自委托方法:
func audioStreaming(_ audioStreaming: SPTAudioStreamingController, didReceiveError error: Error) {
let nsError = error as NSError
print("*** Received error: (\(nsError.code))\(nsError.localizedDescription)")
}
func audioStreaming(_ audioStreaming: SPTAudioStreamingController, didChangePlaybackStatus isPlaying: Bool) {
print("is playing: \(isPlaying)")
}
func audioStreaming(_ audioStreaming: SPTAudioStreamingController, didReceive event: SpPlaybackEvent) {
print("didReceivePlaybackEvent: \(event)")
}
我相信我正确地初始化了我的播放器,它取自 Spotify 存储库中的官方示例应用程序:
do {
try player.start(withClientId: clientID, audioController: nil, allowCaching: true)
player.delegate = self
player.playbackDelegate = self
player.diskCache = SPTDiskCache(capacity: 1024 * 1024 * 64)
player.login(withAccessToken: session.accessToken)
setBitrate(preferredBitrate)
} catch let error {
delegate?.didReceiveError(self, error: error, priority: .test)
closeSession()
}
我查看了错误的文档,但代码 1006 或名称 SPTErrorContextFailed
for err in [
SPTErrorCodeFailed,
SPTErrorCodeNoError,
SPTErrorCodeInitFailed,
SPTErrorCodeUnsupported,
SPTErrorCodeNeedsPremium,
SPTErrorCodeNullArgument,
SPTErrorCodeUninitialized,
SPTErrorCodeFailed,
SPTErrorCodeBadCredentials,
SPTErrorCodeInvalidArgument,
SPTErrorCodeNotActiveDevice,
SPTErrorCodeWrongAPIVersion,
SPTErrorCodeTrackUnavailable,
SPTErrorCodeApplicationBanned,
SPTErrorCodeGeneralLoginError,
SPTErrorCodeTravelRestriction,
SPTErrorCodePlaybackRateLimited,
SPTErrorCodeGeneralPlaybackError
] {
if nsError.code == err {
print(err) // It is not printed because there is no error
// 1006 declared
}
}
正如我所说,所有这些在大多数情况下都有效,但对于某些曲目,我遇到了错误,无法播放。我还用所有可用的比特率测试了曲目,但这并没有改变任何事情。
这可能是什么问题?
我明白了。有些曲目在我的地区不可用,但我的后端没有正确识别这些曲目。我修复了这个问题,现在只有可播放的曲目被传递给播放器,问题不再发生。
如果无法播放曲目,它将在 Spotify 桌面应用程序中显示为灰色