Design an iPod-Style Music Player
Model a portable player with library management, playback controls, and deterministic shuffle.
Design the low-level object model and interfaces for an iPod-Style Music Player.
For this exercise, assume tracks have immutable identities and metadata. The player supports add, delete, play the current selection, pause, next, previous, and shuffle.
One candidate-chosen aggregate or coordinator must own transitions across available tracks, current order/history, playback state, shuffle policy, and audio output so a failure cannot leave partial state. Deleting the current track advances safely and preserves coherent history.
For invalid states, return explicit outcomes for: unknown TrackId; empty playback queue; audio output failure.
Preserve this invariant: The chosen coordinator commits a current TrackId only when that ID exists in both available-track state and the active traversal order; history never references a deleted track, and output failure leaves the prior playback state intact.