Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS & tvOS] Add Playlist Views & Clean Up Collections #1428

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

JPKribs
Copy link
Member

@JPKribs JPKribs commented Feb 9, 2025

Summary

This PR adds Playlists to Swiftfin. This PR does not allow editing Playlists or adding items to Playlists. I intend to add that functionality to a later PR. This starts #609 but I wouldn't consider #609 resolved until I can add the ability to add/remove items from a playlist.

I found that Playlists and Collections are both fairly similar. When I created the ViewModel for Playlists, it was almost identical to Collections. So, I renamed Collections to Lists since this applies to Collections and Lists now, and I added in a single check to ensure we're not allowing media types that are not supported by Swiftfin. This should have been the case prior since Collections can have Audio, Books, Photos, etc. I've added a check so only Movies, Episodes, Series, and Collections can be in Collections/Playlists. This is a bit of a lie since Collections can have Series/Collections but Playlists cannot but a Playlist handles this by turning the Series/Season/Collections into it's component Movies/Episodes instead. This shouldn't impact us since this is on the Server but it is the only real "quirk" of using a single ViewModel for both Playlists and Collections. It just means a Playlist is more permissive for items that don't exist in Playlists.

I added a check on Playlists/Collections so the PlayButton should be functional instead of being hidden/grayed out. The logic I can using it to find the first item that is NOT played as use that as the play button. If there are no items that are not played, instead just use the first item found. I think it could be argued maybe it should be:

  1. Resumable Items
  2. Unplayed Items
  3. First Item

Because the PlayButton works on Collections (and Playlists) I moved both Collections & Playlists to use the CinematicScrollView instead of a custom, just the image.

        ItemView.CinematicScrollView(viewModel: viewModel) {
            ContentView(viewModel: viewModel)
        }

Finally, for the ItemEditorView, I found that on 10.10 metadata, images, etc. can only be edited by administrators so I have the locked in the same way as standard items. Users with the canDelete are administrators with access to the Playlist and the owner of the Playlist. So, Playlists are deletable from Swiftfin by the qualified parties but there is no ability to edit them except by an Admin. This mirrors web with the exception of a new API for making a Playlist public which we do not have access to on 10.8.

Please find screenshots below. Let me know if there are any questions! In terms of real changes, this can be boiled down to:

  1. Collections, add logic for assigning the PlayButtonItem.
  2. Enable the Playlist ItemType for MediaViewModel
  3. Have the Switch Case for which ItemView to use, use CollectionItemView for items of the type 'Playlist'
  4. Change Collections (and now Playlists) to use the standard ItemView since the PlayButton is now functional (See 1.)
  5. Lock Collections (and now Playlists) to only show child types that Swiftfin can utilize
  6. Rename Collection items to be List... items since they are used for Collections and Playlists.

Screenshots

The Media View - User Has Playlists vs Does not Have Playlists Playlists vs No Playlist
Playlist PagingLibraryView

Playlist - PagingView

Scrolling a Playlist

Note the multiple ItemTypes of Episodes & Movies:

Scrolling.a.Playlist.mp4
Deleting a Playlist

iOS:

Deleting.a.Playlist.mp4

tvOS:

Simulator Screenshot - Apple TV 4K (3rd generation) - 2025-02-09 at 12 57 47

New Resume/Play Button for Collections

iOS:

Collection - Resume

tvOS:

Simulator Screenshot - Apple TV 4K (3rd generation) - 2025-02-09 at 12 37 55

@JPKribs JPKribs added the enhancement New feature or request label Feb 9, 2025
@JPKribs
Copy link
Member Author

JPKribs commented Feb 9, 2025

Some QA type info:

  • Marking a playlist as played mirrors web and marks playlist items as played.
  • Favoriting a playlist only favorites that playlist object. All playlist items do no have their favorite status updated from a playlist. This mirrors web as well.
  • Favorited playlists appear in the Favorites library.
  • At this time, playlists use whatever poster type is dictated from the settings (Poster/Landscape) It looks like Jellyfin wants playlists to use Square so they are stretched. I'm up for resolving this but that seems like a larger item than this PR and I wanted to keep this PR from ballooning too much.
  • Mirroring web, non-adminstrators can create/delete playlists but cannot update their metadata/images. Very weird IMO but that appears to be how it's set up on a Jellyfin side so that would need to be resolved there first.

@JPKribs
Copy link
Member Author

JPKribs commented Feb 14, 2025

This was an idea I had for a revision. Instead of grouping everything together, collections/playlists can have various item types in them. on Web, these items are split out by group and IMO that looks better than grouping it. This is how this revision looks:

tvOS:

Simulator.Screen.Recording.-.Apple.TV.4K.3rd.generation.-.2025-02-14.at.13.05.42.mp4

iOS:

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-02-14.at.13.12.51.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low-priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant