我想改进我的 App FM-Pod与 Siri 意图快捷方式的集成。我已经完成了这个应用程序来收听 HomePod 上的广播,到目前为止,我已经能够开始播放、更改电台等,但我遇到了一个奇怪的问题,导致音频播放停止大约1分钟后独自...
有谁知道原因?怎么了?
下面是使用 AVAudioPlayer 开始播放的 Swift 代码:
open func handle(intent: StartFMPodIntent, completion: @escaping (StartFMPodIntentResponse) -> Void) {
DataManager.getStationDataWithSuccess(filename: "favorites") { (data) in
if debug { print("Stations JSON Found") }
guard let data = data, let jsonDictionary = try? JSONDecoder().decode([String: [RadioStation]].self, from: data), let stationsArray = jsonDictionary["station"]
else {
if debug { print("JSON Station Loading Error") }
return
}
HPRIntentHandler.stations = stationsArray
if !FRadioPlayer.shared.isPlaying {
FRadioPlayer.shared.radioURL = URL(string: HPRIntentHandler.stations![0].streamURL0!)
let response = StartFMPodIntentResponse(code: .success, userActivity: nil)
response.stationName = stationsArray[0].name
completion(response)
}
}
}