feat(album): show total album size on the album header - #1618
Open
Thomas05000005 wants to merge 2 commits into
Open
feat(album): show total album size on the album header#1618Thomas05000005 wants to merge 2 commits into
Thomas05000005 wants to merge 2 commits into
Conversation
Sums the size of each track's first MediaSourceInfo and renders it next to the existing track count and runtime in ItemInfo. Hidden when the server doesn't report sizes for any track in the album, matching the maintainer's guidance on finamp-app#1146 (display only when the server provides the size). Adds a small formatBytes() helper for the adaptive B/KB/MB/GB output. Closes finamp-app#1146
6 tasks
Thomas05000005
marked this pull request as ready for review
May 8, 2026 15:51
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.
Summary
Shows the total size of an album right next to the existing track count and runtime on the album screen header. The size is computed by summing the
Sizefield of each track's firstMediaSourceInfoand is rendered with an adaptiveB / KB / MB / GBformatter. The row is hidden whenever the server does not report sizes for any track in the album.Closes #1146 (scoped to the first bullet only - the other three were already separately addressed or duplicated, per the maintainer's reply on the issue).
Implementation
Three small files:
lib/components/format_bytes.dart(new) - top-levelformatBytes(int)helper that picksB,KB,MBorGBbased on the magnitude. Modeled on the existingprint_duration.dart(also a top-level helper in the same folder, no class).lib/components/AlbumScreen/item_info.dart- reads each track'smediaSources?.first?.size, sums them withfold, and adds anIconAndText(iconData: Icons.sd_storage, ...)between the track-count/duration row and the release-date row when the total is greater than zero.lib/services/jellyfin_api.dart- addsMediaSourcesto thedefaultFieldsconstant. Without this, the Items API does not includemediaSourcesin the response, sot.mediaSources?.first?.sizeis always null and the size row never appears. TheMediaSourcesfield is documented as a validFieldsvalue directly in the same file'sgetItemsparameter docstring.Notes
defaultFields(it addsSortName). If fix(api): request SortName field so fast scroll matches the sorted list #1619 lands first, this PR will need a trivial rebase to keep both fields. If reviewers prefer a single PR that adds both fields, I can fold them together - happy to follow whichever is easier on review.FinampSettingstoggle for this. The original report and the maintainer's response treat the size as plain metadata to display, in line with how track count and duration are already shown. A toggle could always be added in a follow-up if reviewers want one.MediaSourceInfo.size(already on the existingBaseItemDto.mediaSourcesfield). Computation happens once perItemInfo.build, which already runs on each album-screen open - same cost as the existingrunTimeTicksDurationsummation a few lines above.mediaSourcesandmediaSources.first.size, it contributes 0 to the sum. The row is hidden when the total is 0, so albums where no track has a size value reported render exactly as today.Test plan
Tested on Windows desktop (
flutter run -d windows) against a real Jellyfin server:Sizereported by the server: a row with the SD-storage icon shows the formatted total (verified, e.g. "32.9 MB" on a one-track album)MediaSourceswas confirmed required: without it ondefaultFieldsthe row never appeared even when the player itself shows the per-track size when playingOut of scope (per maintainer's reply on the issue)
Code assistance
Used Claude (LLM) to follow the existing helpers' structure, to discover that the size lives on
MediaSourceInforather than onBaseItemDtodirectly, and to find thatMediaSourceshad to be added todefaultFieldsfor the Items API to actually include the data we read.