ios - iOS Spotify Streaming SDK - 错误:上下文失败 1006
问题描述
我正在使用“旧”的 Streaming SDK,因为新的不能满足我的需求。我让它工作得很好,但是对于某些曲目我无法开始播放。我正在将消息打印到控制台,这是我得到的输出:
正在播放:真实
didReceivePlaybackEvent: SPPPlaybackNotifyPlay
didReceivePlaybackEvent: SPPPlaybackNotifyAudioFlush
didReceivePlaybackEvent: SPPPlaybackNotifyMetadataChanged
didReceivePlaybackEvent: SPPPlaybackNotifyAudioFlush
didReceivePlaybackEvent: SPPPlaybackNotifyAudioDeliveryDone
正在播放:假
didReceivePlaybackEvent: SPPPlaybackNotifyPause
*** 收到错误:(1006)上下文失败
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 桌面应用程序中显示为灰色
推荐阅读
- excel - 如何在查找表 EXCEL 中获取特定字母和数字组合(例如 M9)的最大值
- ionic-framework - 离子,--offset-top 问题
- python - 为什么以下用于将扁平字典转换为嵌套字典的代码有效?
- r - 我怎样才能让每个数字都在雷达图的一侧?
- r - 将范围函数的输出与R中的字符串连接并打印
- php - 如何向多对多数据透视表添加额外的列
- node.js - 我是使用 node.js 制作不和谐机器人的新手,我遇到了错误,它说第 14 行和第 18 行中没有定义消息
- django - Django 命令 - django-admin 命令不起作用
- r - 计算另一列中两列的平均值
- django - Django Form - 设置数据