Skip to content

Commit 98c58cf

Browse files
briankeaneclaude
andcommitted
Guard against stop() during loadAndPlaySpin await
After awaiting player.load(), check that stationId is still set before proceeding to playback. If stop() ran during the suspension, clean up the player instead of overwriting the .idle state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5284796 commit 98c58cf

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Sources/PlayolaPlayer/Player/Streaming/StreamingStationPlayer.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ final public class StreamingStationPlayer: ObservableObject {
174174
let player = getOrCreateSpinPlayer(for: spin)
175175

176176
let result = await player.load(spin)
177+
178+
// Guard against stop() called during the await
179+
guard stationId != nil else {
180+
player.clear()
181+
spinPlayers.removeValue(forKey: spin.id)
182+
return
183+
}
184+
177185
switch result {
178186
case .success:
179187
let timing = spin.playbackTiming

0 commit comments

Comments
 (0)