Playlist impl - #212
Merged
Merged
Conversation
This commit introduces comprehensive support for playlists containing both audio and video items. It updates the data models, repository layers, and UI components to handle mixed-media content, enabling users to browse, manage, and play video entries within the music playlist interface and the video player.
### Key Changes:
* **Data Models & Extensions**:
* **`AfinityVideoPlaylist`**: Introduced a new model to represent video-based playlists.
* **`PlaylistEntry`**: Created a sealed interface to represent mixed content, with specific `Audio` and `Video` implementations.
* **Mapping**: Updated `JellyfinModelExtensions` to handle the `PLAYLIST` item kind and map it to either audio or video playlist models.
* **Playlist UI & Components**:
* **`PlaylistVideoRow`**: Added a new component to display video items within playlist screens, including support for watched indicators and duration formatting.
* **Unified Playlist Screen**: Refactored the music playlist screen to render both `MusicTrackRow` and `PlaylistVideoRow`. Added a playback choice dialog for mixed-media playlists.
* **Visual Enhancements**: Updated `MediaItemCard` and `MediaItemGridCard` to use square aspect ratios for playlists and added item count badges.
* **Empty States**: Implemented descriptive empty states that account for hidden video items when viewing playlists in audio-only mode.
* **Video Player Integration**:
* **`PlaylistManager`**: Implemented `initializeJellyfinPlaylistQueue` to support loading and navigating video playlists directly within the video player.
* **`PlayerLauncher`**: Updated to pass `playlistId` to the player activity, ensuring the playback queue is correctly initialized for playlist items.
* **Repository & State Management**:
* **Repository Layers**: Updated `MediaRepository` and `MusicRepository` to fetch unified `PlaylistEntry` objects.
* **`MusicPlaylistViewModel`**: Refactored to manage mixed content, handle entry removal, and emit specialized video playback requests.
* **`ItemDetailViewModel`**: Added support for the `PLAYLIST` kind and optimized runtime fetching for associated items.
* **Navigation & Infrastructure**:
* **Consolidated Navigation**: Introduced `navigateToItem` in `MainNavigation` to unify routing logic, specifically directing video playlists to the updated playlist screen.
* **`CollectionType`**: Added `Playlists` as a supported collection type for library browsing and paging.
This commit generalizes the playlist system to support both audio and video media types. It introduces a unified `PlaylistScreen` and `PlaylistViewModel`, replacing the previous music-specific implementations. Additionally, it implements server-side item reordering via drag-and-drop and enables adding video items to playlists from the item detail screen.
### Key Changes:
* **Unified Playlist System**:
* **Generic Playlists**: Renamed `MusicPlaylistScreen` and `MusicPlaylistViewModel` to `PlaylistScreen` and `PlaylistViewModel`, moving them to a shared package.
* **Route Refactoring**: Updated `Destination` and `MainNavigation` to use a unified `PLAYLIST_ROUTE`, supporting both audio and video contexts via an `audioOnly` flag.
* **Media Support**: Updated `MusicRepository` and `AddToPlaylistDialog` to support different `MediaType` values, allowing the creation of video-based playlists.
* **Playlist Reordering**:
* **Drag-and-Drop**: Integrated `sh.calvin.reorderable` to allow users to reorder items within a playlist using long-press gestures.
* **API Integration**: Implemented `movePlaylistItem` in `JellyfinMediaRepository` to sync the new item order with the Jellyfin server.
* **State Management**: Added `moveEntry` and `commitEntryMove` to `PlaylistViewModel` to handle optimistic UI updates and server synchronization.
* **Item Detail Improvements**:
* **Add to Playlist**: Integrated `AddToPlaylistDialog` into `ItemDetailScreen` for movies, shows, seasons, and episodes.
* **Action Menu**: Updated `ActionButtonsRow` to include an "Add to Playlist" option in the overflow menu for supported video types.
* **Library & Synchronization**:
* **Dynamic Refreshing**: Updated `LibraryContentViewModel` to invalidate the `PagingSource` when library content changes occur (e.g., playlist creation or deletion), ensuring the UI stays in sync with the server.
* **Change Notifications**: Added `mediaChangeManager` notifications to the repository layer for playlist modifications.
* **Download Support**: Updated `JellyfinDownloadRepository` to handle mixed-media playlist downloads, supporting both audio tracks and video items.
* **Repository & Paging**:
* **Paging Hooks**: Modified `MediaRepository` and its implementation to provide an `onSourceCreated` callback, allowing ViewModels to track and invalidate active paging sources.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Mixed Playlist Support Implementation