Skip to content

Instantly share code, notes, and snippets.

@desmondmc
Created June 22, 2018 10:56
Show Gist options
  • Save desmondmc/1dc49bb2bd53058ad04e9eb6402f3e57 to your computer and use it in GitHub Desktop.
Save desmondmc/1dc49bb2bd53058ad04e9eb6402f3e57 to your computer and use it in GitHub Desktop.
requestStations fails if initialize was called without a connection
func initialize(_ token: String, secret: String) {
FMAudioPlayer.setClientToken(token, secret: secret)
}
func requestStations(stationsCallback: (Stations) -> ()) {
FMAudioPlayer.shared().whenAvailable({
guard let stations = FMAudioPlayer.shared().getAllStations(options: [:]) else {
// throw error
return
}
let stationInfo = stations.map {
["name": $0.name,
"identifier": $0.identifier]
}
stationsCallback(stationInfo)
}) {
// throw error
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment