private func incomingNowPlayingInfo(info: NowPlayingInfo) {
// only proceed if there is a current station
guard let station = station else { return }
// ignore stale data
guard info.stationTag == station.tag else { return }
// make sure this info is current
guard !info.expired() else { return }
nowPlayingInfo = info
// invalidate info if it's still around after expiry!
guard info.expires() else { return }
info.onExpiry().then { _ -> Void in
// if there's no currentInfo, there's no point in doing anything else
guard let currentInfo = self.nowPlayingInfo else { return }
if currentInfo == info {
// then it's time to say goodbye
self.nowPlayingInfo = nil
}
}.catch { _ in
print("tried to listen for expiry on a value that doesn't expire")
}
}
We now handle this in the playback manager:
https://github.com/ojo/ios/blob/master/ojo/PlaybackManager.swift#L192
@ojo/android