Clear ApplicationMusicPlayer queue after station queued

After an Album, Playlist, or collection of songs have been added to the ApplicationMusicPlayer queue, clearing the queue can be easily accomplished with:

ApplicationMusicPlayer.shared.queue.entries = []

This transitions the player to a paused state with an empty queue.

After queueing a Station, the same code cannot be used to clear the queue. Instead, it causes the queue to be refilled with a current and next MusicItem from the Station.

What's the correct way to detect that the ApplicationMusicPlayer is in the state where it's being refilled by a Station and clear it? I've tried the following approaches with no luck:

# Reinitialize queue
ApplicationMusicPlayer.shared.queue = ApplicationMusicPlayer.Queue()

# Create empty Queue
let songs: [Song] = []
let emptyQueue = ApplicationMusicPlayer.Queue(for: songs)
ApplicationMusicPlayer.shared.queue = emptyQueue
extension ApplicationMusicPlayer {
  // This approach seems to work for all cases, but downstream consumers of
  // the player need to hide the churn in ApplicationMusicPlayer properties
  // from users of the player.
  @MainActor
  public func replaceQueueWithSingleSongQueueThenClear() async throws {
    // replace the queue with itself
    self.queue = ApplicationMusicPlayer.Queue(for: self.queue.entries.compactMap { $0.item }, startingAt: self.queue.currentEntry?.item)

    // tell the queue to delete its hidden Station container
    try await self.prepareToPlay()
    
    // now the queue can be cleared without refilling
    self.queue.entries = []
  }

}
Clear ApplicationMusicPlayer queue after station queued
 
 
Q