Skip to content

feat: configurable media bar content source (collections/playlists)#43

Open
enyineer wants to merge 6 commits intoMoonfin-Client:masterfrom
enyineer:feature/custom-mediabar
Open

feat: configurable media bar content source (collections/playlists)#43
enyineer wants to merge 6 commits intoMoonfin-Client:masterfrom
enyineer:feature/custom-mediabar

Conversation

@enyineer
Copy link
Contributor

@enyineer enyineer commented Mar 8, 2026

Summary

Closes #39

Allows administrators and users to configure the media bar to display content from specific Jellyfin collections and/or playlists, instead of only random library items.

Features

  • Content Source selector — choose between "Library (Random)" (existing behavior) or "Collections / Playlists"
  • Collection/Playlist picker — multi-select with poster thumbnails and type badges (Collection vs Playlist)
  • Shuffle toggle — randomize item order from selected collections, or maintain sort order
  • Admin defaults — admins can set default source type, default collections, and shuffle preference for all users
  • Backward compatible — if nothing is configured, the existing random behavior is preserved
  • Settings sync — new settings sync across devices like all other Moonfin settings

Changes

Backend

  • MoonfinSettingsProfile.cs — added MediaBarSourceType, MediaBarCollectionIds, MediaBarShuffleItems
  • MoonfinUserSettings.cs — added matching legacy v1 fields for migration
  • MoonfinSettingsService.cs — added reset entries in ClearLegacyFields
  • configPage.html — added admin default controls (source type dropdown, collection picker, shuffle toggle)

Frontend

  • api.js — added getCollectionsAndPlaylists() and getCollectionItems() methods
  • mediabar.jsloadContent() branches on source type; applySettings() tracks new settings
  • settings.js — source dropdown, collection picker UI, shuffle toggle, loadCollectionPicker() method
  • storage.js — defaults + server↔local sync mappings for 3 new settings
  • settings.css — collection picker styles

Screenshots

User Settings — Default (Random)

user-settings-default-random

User Settings — Collections / Playlists

user-settings-mediabar-collections-playlists

Admin Settings — Default Collections / Playlists

admin-settings-collections-playlists

…and an expanded configuration interface across frontend and backend.

Signed-off-by: enyineer <nico.enking@gmail.com>
@enyineer
Copy link
Contributor Author

enyineer commented Mar 8, 2026

Hey! Just a heads-up — this PR includes some formatting/whitespace changes alongside the actual feature work. These came from the IDE auto-formatter running on files that were touched during development (e.g. consistent indentation, trailing spaces, quote style normalization in JS).

They don't affect functionality at all, but I understand they add noise to the diff. If you'd prefer to keep those out and only have the feature-related changes, just let me know and I'll revert the formatting to match the original style. Happy either way!

@broken-droid
Copy link

For a library option, I think people were also interested in picking which libraries to use. It'd probably be convenient to have a synced setting for selected library ids that all clients can use. --Just imo, but maybe someone else can chime in.

@enyineer
Copy link
Contributor Author

Great idea, I'll look into that at Sunday (maybe earlier if I have time for it).

Would be interested in Axl's opinion though.

…abar

# Conflicts:
#	frontend/src/components/settings.js
#	frontend/src/utils/storage.js
@enyineer
Copy link
Contributor Author

image

What do you think about this? Should we remove the "Content Type" in favor of picking actual libraries or leave it as complimenting feature? I'm unsure, because they both kind of do the same while being different filters. Having both might be confusing.

Allow users to optionally select specific Jellyfin libraries when using
Library (Random) mode. When no libraries are selected, all libraries are
used (preserving existing default behavior).

- Add mediaBarLibraryIds to backend models and settings service
- Extend getRandomItems() API to support parentId filtering per library
- Add library picker UI in user settings and admin config page
- Reuse collection picker styling for consistent UX
@enyineer
Copy link
Contributor Author

The failing CI is because of a permissions issue that will be fixed by #48

I'll update this branch as soon as #48 is merged so the build can run again.

@RadicalMuffinMan
Copy link
Contributor

I agree with @broken-droid it should be per-library and we can build out an endpoint that the tv and mobile clients can use as well but I can handle that part

@broken-droid
Copy link

What do you think about this? Should we remove the "Content Type" in favor of picking actual libraries or leave it as complimenting feature? I'm unsure, because they both kind of do the same while being different filters. Having both might be confusing.

I like it. I think it makes sense to keep content type too. You don't really know how everyone has their libraries set up.

@RadicalMuffinMan
Copy link
Contributor

Sorry was out and about doing errands, looing at #48 now

@RadicalMuffinMan
Copy link
Contributor

The main thing I get asked for lately is local trailers and per-library for the media bar

- Remove mediaBarContentType from backend models, service, frontend
  storage/settings/mediabar/api, and README
- Add GET /Moonfin/MediaBar?profile= endpoint that resolves user settings
  and queries ILibraryManager for media bar items server-side
- Frontend calls unified endpoint first with client-side fallback
- Update README with new library selection settings and MediaBar endpoint
@enyineer
Copy link
Contributor Author

enyineer commented Mar 14, 2026

Changes in this update

Removed: mediaBarContentType setting

Per your feedback on preferring actual library selection over content type filtering, the mediaBarContentType setting has been removed from:

  • Backend models (MoonfinSettingsProfile.cs, MoonfinUserSettings.cs)
  • Settings service (ClearLegacyFields)
  • Frontend: storage mappings, settings UI, media bar component, and API utility

This is a BREAKING CHANGE! Existing settings for "Content Type" will be lost. However, it is better to only have one filter IMO because it might be confusing if users accidentally select "Shows only" while also selecting a Library that only contains Movies yields 0 results.

New: GET /Moonfin/MediaBar endpoint

A new server-side endpoint that serves media bar content directly. This enables any client (Android, TV, etc.) to fetch resolved media bar items with a single call — no need to reimplement the settings resolution + library query logic on each platform.

How it works:

  • Resolves user settings per device profile (desktop, mobile, tv, global)
  • Queries ILibraryManager for movies/series (library source) or collection items
  • Returns items in a shape compatible with Jellyfin's BaseItemDto (same property names: Id, Name, ImageTags, BackdropImageTags, etc.)
  • Supports library filtering via mediaBarLibraryIds and shuffle via mediaBarShuffleItems
GET /Moonfin/MediaBar?profile=desktop
Authorization: MediaBrowser Token="..."

The web frontend already uses this endpointmediabar.js now calls it first with a fallback to the previous client-side logic if unavailable. Adding support to Android/TV clients should be straightforward since the response format matches Jellyfin's native item API.

Fixes

  • Settings dialog profile resolution: createDialog was resolving settings for the physical device profile instead of the active edit profile, causing stale device-level overrides to mask global changes. Fixed by using Storage.getAll(Storage.getActiveEditProfile()).
  • Cross-version compatibility: The endpoint uses only stable BaseItem APIs (no IDtoService, IUserManager, or SortOrder which changed between Jellyfin 10.10 and 10.11). Shuffling is done in-memory.
  • Double MediaBar request: Initialized content-tracking state in init() to prevent a redundant reload from the sync event.

…diabar

# Conflicts:
#	frontend/src/components/mediabar.js
#	frontend/src/utils/api.js
@github-actions
Copy link

github-actions bot commented Mar 14, 2026

✅ Build Successful

The plugin compiled successfully against .NET 8 / Jellyfin 10.10.0.

Property Value
Commit e4bed26
Workflow Build #11

@enyineer enyineer marked this pull request as draft March 14, 2026 09:31
@enyineer
Copy link
Contributor Author

There's still a bug with Collections / Playlists in the new endpoint return 0 results. I'll investigate.

@enyineer
Copy link
Contributor Author

enyineer commented Mar 14, 2026

Fix: Collections/Playlists in MediaBar endpoint

The GetCollectionItems method was initially using InternalItemsQuery with ParentId, which returned 0 items because Jellyfin BoxSets use LinkedChildren (not parent-child hierarchy).

Subsequent fixes using Folder.GetChildren() and ILibraryManager.GetItemList() both hit MissingMethodException due to Jellyfin 10.10→10.11 API changes (the User type parameter changed).

Final approach avoids all unstable method signatures:

  1. GetItemById() to fetch the collection (stable across versions)
  2. Cast to Folder (type check only, no method call)
  3. Iterate folder.LinkedChildren (data property — no method resolution)
  4. GetItemById() per linked child to resolve items (stable across versions)

This keeps the plugin compatible with both Jellyfin 10.10 and 10.11+.

@enyineer enyineer force-pushed the feature/custom-mediabar branch from 59a9d4f to e4bed26 Compare March 14, 2026 09:41
@enyineer enyineer marked this pull request as ready for review March 14, 2026 09:46
@RadicalMuffinMan
Copy link
Contributor

Hey! Just a heads-up — this PR includes some formatting/whitespace changes alongside the actual feature work. These came from the IDE auto-formatter running on files that were touched during development (e.g. consistent indentation, trailing spaces, quote style normalization in JS).

They don't affect functionality at all, but I understand they add noise to the diff. If you'd prefer to keep those out and only have the feature-related changes, just let me know and I'll revert the formatting to match the original style. Happy either way!

please do, it makes it a bit harder to review the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancment for media bar

3 participants