Add playback rewrite queue system #2209
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There we go, the first real code for the playback rewrite! This code was relatively stable (didn't see much changes in my occasional refactoring) so it's good enough to PR upstream.
Changes
playback.core
Add Queue interface
A queue contains the items to play, simple as that. Queues are always lazy loaded to allow for big queues or changing future items on demand.
Add EmptyQueue implementation
It's a queue that is empty.
Add PagedQueue implementation
This one is kinda cool, it loads (sequential) pages of items and cache them. So when the player wants to know the next queue item it might have (pre-)loaded already so no network request is needed. Most of the Jellyfin specific queue implementations use this one as base.
Add SequenceQueue implementation
Like PagedQueue but with a sequence, I used this before creating the PagedQueue. Currently unused but might still have some use cases in the future.
Add initial QueueManager
It's a helper to work with queues, this one will probably change a bunch in upcoming PR's.
Add QueueEntry
It's an item in the Queue. This interface contains properties that are used by all playback components. Including the QueueEntryMetadata which is a container for all kinds of properties used for mediasessions, media notifications, player metadata, logging etc. etc.
playback.jellyfin
Add BaseItemDtoUserQueueEntry
Implementation for QueueEntry that contains Jellyfin specific data (like BaseItemDto). It contains a builder function that is used by the Jellyfin specific queue implementations.
Add AudioAlbumQueue, AudioInstantMixQueue, AudioTrackQueue
Music specific implementations for the player. As I said before, focus is currently on getting music to work perfect before working on video. These three queues should be sufficient for most music playing scenarios. There might still be some more like an ArtistQueue later.
Add EpisodeQueue
Focus is on music but video playback already works.. locally. This one is to play episodes in a season.
Issues
Part of #1057