Audio iOS:在静音模式下播放Spotify音频

Audio iOS:在静音模式下播放Spotify音频,audio,swift3,ios10,spotify,Audio,Swift3,Ios10,Spotify,我正在使用spotify iOS SDK开发应用程序,我已经成功地将我的应用程序连接到spotify,并且我的音频正在播放,但问题是:当我激活静音模式时,即使spotify音乐仍在播放,我的应用程序也没有声音。我已经使用Spotify iOS SDK(演示项目,MusixMatch)检查了其他应用程序,它们都可以释放声音 这是我的密码: self.spotifyPlayer = SPTAudioStreamingController.sharedInstance()

我正在使用spotify iOS SDK开发应用程序,我已经成功地将我的应用程序连接到spotify,并且我的音频正在播放,但问题是:当我激活静音模式时,即使spotify音乐仍在播放,我的应用程序也没有声音。我已经使用Spotify iOS SDK(演示项目,MusixMatch)检查了其他应用程序,它们都可以释放声音

这是我的密码:

        self.spotifyPlayer = SPTAudioStreamingController.sharedInstance()
        self.spotifyPlayer!.playbackDelegate = self
        self.spotifyPlayer!.delegate = self

        try! spotifyPlayer?.start(withClientId: auth.clientID)            
        self.spotifyPlayer!.login(withAccessToken: authSession.accessToken)
然后,将调用此函数:

func audioStreamingDidLogin(_ audioStreaming: SPTAudioStreamingController!) {
    let uri = "spotify:track:" + trackId
    self.spotifyPlayer?.playSpotifyURI(uri, startingWith: 0, startingWithPosition: 0, callback: { (error) in
           if (error != nil) {
                print("error: \(error) ")
           }
    })
}

我已经找到了我缺少的东西

func audioStreaming(_ audioStreaming: SPTAudioStreamingController!, didChangePlaybackStatus isPlaying: Bool) {
    print("isPlaying: \(isPlaying)")
    if (isPlaying) {
        try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
        try! AVAudioSession.sharedInstance().setActive(true)
    } else {
        try! AVAudioSession.sharedInstance().setActive(false)
    }

}

didStartPlayingTrack
代理是否被击中?您可能想看看
audioStreamingDidBecomeInactivePlaybackDevice
didReceiveError
委托方法。
didStartPlayingTrack
运行平稳,我还在播放曲目后调用了一些函数,
audioStreamingDidBecomeInactivePlaybackDevice
将在我的PlaySongViewController关闭后调用,这不是因为我使手机静音,而且对于
didReceiveError
,不会在任何地方调用