【问题标题】:Cannot Disable Autoplay with Spotify iOS App Remote SDK无法使用 Spotify iOS App Remote SDK 禁用自动播放
【发布时间】:2019-07-01 01:50:36
【问题描述】:

我正在尝试使用以下 Swift 函数禁用后台 Spotify 自动播放(通过 App Remote SDK)。

private static func configureAppRemote() {
    if let player_api = SpotifySDK.shared.app_remote.playerAPI {
        player_api.setRepeatMode(.off, callback: SpotifySDK.debug_callback)
        player_api.setShuffle(false, callback: SpotifySDK.debug_callback)
        is_configured = true
    } else {
        is_configured = false
    }
}

我的 SpotifySDK.debug_callback 打印出这两个调用的闭包参数并返回 (result, error) = (nil, nil),尽管 Objective-C Spotify SDK 源代码声称这种状态是不可能的:

@param callback On success `result` will be `YES`.
                On error `result` will be `nil` and `error` will be set.

有人知道如何使用 App Remote 正确禁用自动播放吗?

【问题讨论】:

    标签: ios swift sdk spotify


    【解决方案1】:

    您的会话管理器是什么样的?我遇到了同样的问题,并从我的会话管理器声明自动播放停止中注释掉以下内容:

    lazy var sessionManager: SPTSessionManager = {
        if let tokenSwapUrl = URL(string: "https://conservative-media.herokuapp.com/api/token"),
            let tokenRefreshUrl = URL(string: "https://conservative-media.herokuapp.com/api/refresh_token") {
            self.configuration.tokenSwapURL = tokenSwapUrl
            self.configuration.tokenRefreshURL = tokenRefreshUrl
    //            self.configuration.playURI = ""
        }
        let manager = SPTSessionManager(configuration: self.configuration, delegate: self)
        return manager
    }()
    

    playURL 的空白字符串将自动播放用户上次播放的音频,您也可以输入有效的 Spotify URI 来播放该自动播放。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-11
      • 2018-06-05
      • 2016-09-17
      • 2017-02-09
      • 1970-01-01
      • 2016-07-13
      • 2020-11-22
      • 2014-08-16
      相关资源
      最近更新 更多