は、私は正常に楽しんでるに私のアプリを接続していると音声が再生されているが、問題がある:私は私のPlaySongViewControllerを閉じると、私のアプリがクラッシュになりますiOS: "SPAudioStreamingControllerのインスタンスが既に使用されています。"
"An instance of SPAudioStreamingController is already in use."
私は
var spotifyPlayer: SPTAudioStreamingController?
@IBAction func closeView(_ sender: UIButton) {
print("close view")
self.dismiss(animated: true, completion: nil)
self.spotifyPlayer?.logout()
invalidateTimers()
}
func audioStreamingDidLogout(_ audioStreaming: SPTAudioStreamingController!) {
print("after logout")
try! self.spotifyPlayer?.stop()
}
をログアウトした後、私はこのコードで私のspotifyPlayerを停止しない限り、問題は、このコードが正しく
self.spotifyPlayer = SPTAudioStreamingController.sharedInstance()
self.spotifyPlayer!.playbackDelegate = self
self.spotifyPlayer!.delegate = self
try! spotifyPlayer?.start(withClientId: auth.clientID)
self.spotifyPlayer!.login(withAccessToken: authSession.accessToken)
012を作業する前に、私は直接私のViewControllerを閉じると続けています私は再び私PlaySongViewControllerを開くために別の曲を選ぶとき
は、私がPlaySongViewControllerを開いたとき、それは「楽しんでるが表示されます、私は非プレミアムアカウントでログインしようとすると、別の問題がある
"An instance of SPAudioStreamingController is already in use."
でクラッシュしますPlaySongViewControllerを閉じて他のPlaySongViewControllerを開いて別の曲を再生すると、「既に使用中です」というエラーが表示されて再びクラッシュします。
私のspotifyPlayerを起動したらこのコードを無視できますか?
try! spotifyPlayer?.start(withClientId: auth.clientID)
または解決策はありますか?
私はまだMusixmatchのようなアプリを作っていますが、PlaySongViewControllerで歌詞を処理する必要がある場合は、私のMusicPlayerクラスで歌詞を処理できますか?とにかく、私がMusicPlayerにプレーヤーデリゲートを置く場合、私は、audioLinkingdidLogin funcなどを、私のView ControllerではなくMusicPlayerクラスに置く必要がありますか? –
したくない場合は、シングルトンを使用する必要はありません。 doブロックとcatchブロックはそれだけで十分なはずです。しかし、はい、あなたの質問に代理人のメソッドは、音楽プレーヤーになるだろう。あなたのコーヒーが現在どのように構成されていて、歌詞がどのように表示されるかを詳細に調べることができません。 –
はい、doとcatch lyricはうまく動く、私は試してみることを試みる?それはnullを与えることができるので、それは正常に動作し、2番目の、私は今シングルトンを使用しないと思う。本当に助けていただきありがとうございます。 –