我使用以下代码运行基于Soundcloud的URL音频文件。
https://api.soundcloud.com/tracks/<Track Name>/stream?client_id=<my Client id>
var podcastPlayer = STKAudioPlayer.init()
podcastPlayer.delegate = self
podcastPlayer.play(urlString)
它没有超过缓冲状态
func audioPlayer(_ audioPlayer: STKAudioPlayer, stateChanged state: STKAudioPlayerState, previousState: STKAudioPlayerState) {
if( state == .playing){
JDStatusBarNotification.dismiss()
updateRemoteNotificationDisplay()
}else if(state == .buffering) {
JDStatusBarNotification.show(withStatus: "Buffering!..Please Wait!", styleName: JDStatusBarStyleRed)
JDStatusBarNotification.showActivityIndicator(true, indicatorStyle: .gray)
}else if(state == .stopped) {
JDStatusBarNotification.dismiss()
}
NotificationCenter.default.post(name: Notification.Name(rawValue: NLConstants.NOTIF_PODCAST_UPDATE_UI), object: nil)
}