Repository navigation
FRadioPlayer 0.5.0 adds opt-in seams for apps that own playback: who recovers a stall, why playback failed, a fresh item on demand, a hook on every new item, and the resume decision after an interruption. Additive: with the defaults the player behaves exactly as in 0.4.0.
Migration
None. No public symbol is removed or changed. New observer methods have default empty implementations, so existing observers compile unchanged. Platform minimums and toolchain requirements are unchanged.
Added
recoveryPolicy(.automaticby default, the 0.4.0 ladder)..hostManagednever schedules a reload; switching to it cancels a pending one.radioPlayerDidDetectStall(_:reason:)withStallReason.bufferEmpty,.networkReconnectedand.playbackStalledNotification, reported under both policies while playback is wanted..networkReconnectedmeans a path restored after an unsatisfied one; the path monitor's first snapshot is not reported. The player now also observesAVPlayerItemPlaybackStalled, for reporting only.radioPlayer(_:bufferingDidChange:), deduplicated, fromtimeControlStatuswaiting and buffer-empty signals; ends ontimeControlStatusplaying or paused, pause, stop and failure.isPlaybackLikelyToKeepUpis intentionally not a source: it is a prediction that can flip while audio plays, and it keeps driving only the legacystate.radioPlayer(_:didObserveProgress:)every 0.5 s while time advances. Every new item gets a progress-only time observer when it is attached (a file swaps it for the file observer once its duration is known), so a live stream whose duration stays indefinite still ticks;currentTimeandplayTimeDidChangebehave as before. Extra ticks on start, stop and time jumps come from AVPlayer.Failure(kind,domain,code,httpStatus,message),lastFailureandradioPlayer(_:didFail:), called after playback stops and before.erroris published. Kinds:.notFound,.forbidden,.unauthorized,.network,.timeout,.decode,.stalledExhausted,.unknown. HTTP statuses come from the item's error log or the error text; other kinds from the error and its underlying errors.stop(discardingItem:).falseisstop().truealso drops the item, metadata, artwork, duration and time, so the nextplay()for the same URL builds a fresh item. A stop, discard orradioURLchange made from that rebuild's.loadingcallback or from the configurator wins over the rebuild. Plainstop()still keeps the item, and the nextplay()reattaches it.playerItemConfigurator, called on the main actor with every newAVPlayerItembefore it is attached (for anaudioMix), anditemGeneration, incremented per new item.resumesAfterInterruption(trueby default) andradioPlayer(_:interruptionEnded:), which reports whether resuming is warranted.
Behaviour notes
- Each item now gets its own metadata output. Timed metadata that was already queued for an item when it was discarded or replaced (including by a
radioURLchange) is dropped instead of being reported against what came next, and it starts no artwork lookup.
Known behaviour kept as is
- The 0.4.0 network-reconnect path never starts the built-in ladder: the check runs before connectivity is recorded. It is unchanged under
.automatic;.hostManagedhosts get.networkReconnectedreports instead.
Validation
macOS swift test covers the defaults (characterisation tests for the ladder, stop() keeping the item, interruption auto-resume) and every seam. The iOS simulator suite adds the interruption notification path with auto-resume off.
HTTP failure classification is validated against synthetic error-log entries only, not against real CoreMedia events from a live server. It recognises a numeric status from 400 to 599 in the item's error log, or "HTTP nnn" in the error log comment or the error text. Any other shape of an HTTP failure yields .unknown (with httpStatus nil), so a host should treat .unknown as retryable.