Problem statement
Design the object model and transport state machine for a video queue player: the layer that decides what plays next as a user queues clips and controls playback.
Operating context. One player instance, single in-process service. The player holds an ordered play queue of video items and exposes transport states (idle, playing, paused, buffering, ended). Repeat mode is off, one, or all; shuffle is on or off. Users enqueue items, play a specific item now, and skip to the next or previous item; the player auto-advances when a clip finishes. A bounded history lets 'previous' walk back through recently played items. The media source signals buffering and end-of-media events, and the player reacts to them.
Out of scope. Video decoding and rendering, adaptive bitrate and network transport, casting to external devices, DRM, and any UI widgets.
What to produce. The class hierarchy (player, play queue, video item, repeat and shuffle strategies), the transport state machine, and the next-item selection rule. Be explicit about: the state machine's legal transitions and the events that trigger them, how repeat and shuffle compose to pick the next item, how 'previous' uses the bounded history, and how auto-advance on end-of-media is driven by an injected event rather than a real player.
Functional requirements
- Enqueue items, play a specific item now, and clear the queue.
- Advance to the next item automatically when the current item ends.
- Skip to the next or previous item on demand, honoring the current repeat and shuffle modes.
- Pause, resume, and stop, transitioning the transport state legally.
- Set repeat mode (off, one, all) and toggle shuffle without losing the current position.
- Expose the current item, the transport state, and the upcoming items.
Non-functional requirements
- Next-item selection is O(1) given the current position and the active modes.
- Every transport transition is validated; an illegal transition is rejected, not silently ignored.
- Repeat and shuffle are pluggable strategies composed independently of the state machine.
- History is bounded so 'previous' uses O(1) memory per step and cannot grow without limit.
- The object model is unit-testable by injecting end-of-media and buffering events, with no real player.
- Adding a new repeat mode must not require editing the transport state machine.
Topics
- System Design LLD
- Media Video
- Patterns State
- Patterns Strategy
- Oop Solid