Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS Spotify流媒体SDK-错误:上下文失败1006_Ios_Swift_Spotify - Fatal编程技术网

iOS Spotify流媒体SDK-错误:上下文失败1006

iOS Spotify流媒体SDK-错误:上下文失败1006,ios,swift,spotify,Ios,Swift,Spotify,我正在使用“旧”流媒体SDK,因为新的SDK不能满足我的需要。我的工作很好,但是对于一些曲目我不能开始播放。我正在将消息打印到控制台,这是我得到的输出: 这是真的吗 didReceivePlaybackEvent:SPPPlaybackNotifyPlay didReceivePlaybackEvent:SPPPlaybackNotifyAudioFlush didReceivePlaybackEvent:SPPPlaybackNotifyMetadataChanged didReceivePl

我正在使用“旧”流媒体SDK,因为新的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的repo官方示例应用程序:

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桌面应用程序中变灰