Introducing a new way to review your PRs.

Read the announcement

huynhsontung / screenbox

LibVLC-based media player for the Universal Windows Platform

View on GitHub

19 documents · Updated Nov 23, 2026

docs / media-library

Media library and discovery

Screenbox turns local and network media into one set of browsable media items. It builds music and video library views from file sources and metadata, then presents those items as folders, songs, albums, artists, videos, playlists, and search results.

Media model

Media items

The Screenbox.Core/…/MediaViewModel.cs model is the common item used by library, folder, playlist, and playback experiences. It keeps a source identity with display metadata, media type, duration, artwork, availability, and music or video properties. A source location remains the stable link back to the file, network path, or URI.

Music metadata supplies title, artist, album, album artist, genre, year, and track order. Video metadata supplies title, subtitle, contributors, year, duration, and video size. Details and thumbnails can load after the item first appears, so browsing does not depend on every property being ready at once.

References: Screenbox.Core/…/MediaViewModel.cs• L21-78 Screenbox.Core/…/MediaInfo.cs• L7-19 Screenbox.Core/…/MusicInfo.cs• L6-17 Screenbox.Core/…/VideoInfo.cs• L6-21

File and network sources

IFileMediaSource represents a local or network file through its path and can resolve its file object when needed. URI sources cover media that is identified by a non-file address. This lets the same media item flow through direct opening, library browsing, recent media, and playlists without requiring each feature to define its own identity model.

Some sources represent a container rather than one playable item. An expandable source must produce child media items before playback or queue creation. See media source resolution for the source and expansion rules.

References: Screenbox.Core/…/IMediaSource.cs• L5-23 Screenbox.Core/…/IFileMediaSource.cs• L6-35 Screenbox.Core/…/IExpandableMediaSource.cs• L7-16 Screenbox.Core/…/MediaSourceFactory.cs• L7-47

Library snapshots

Music library

The music library is a replaceable snapshot of songs, albums, artists, genres, and fallback groups. Each song is linked to its album and one or more artists. These links let the application move from a song to its album or artist and let album and artist pages build their song lists from the same source data.

Albums use album name and album artist as their identity. Artists use a normalized name. Songs without usable tags stay visible through the unknown album or unknown artist groups instead of disappearing from library views.

References: Screenbox.Core/…/MusicLibrary.cs• L6-41 Screenbox.Core/…/AlbumViewModelFactory.cs• L17-50 Screenbox.Core/…/ArtistViewModelFactory.cs• L19-33

Video library

The video library is a snapshot of video media. It does not create album or artist relationships. Video browsing therefore uses the file and folder structure, while video cards and detail views use the title and video metadata on each item.

References: Screenbox.Core/…/VideosLibrary.cs• L6-19 Screenbox.Core/…/VideosPageViewModel.cs• L22-62

Library state

Screenbox.Core/…/LibraryContext.cs holds the active music and video snapshots, their storage-library handles, and loading state. Pages listen for replacement snapshots and rebuild their visible groups. This gives all library pages the same view of a refresh and prevents one page from owning a separate copy of library data.

References: Screenbox.Core/…/LibraryContext.cs• L7-30 Screenbox.Core/…/LibraryCoordinator.cs• L105-168

Indexing and refresh

Library indexing

The library service initializes the platform music and videos libraries, creates supported-file queries, and turns query results into the music or video snapshots. A query can use the platform indexer when the setting allows it. On supported devices, removable storage can also join the library when the related setting and access permission are available.

The service can use stored media records as a fast starting point. It checks library paths and tracked changes before accepting the cached view. If the cache is not valid, it reads the library again and rebuilds the relationships.

The library lifecycle moves from storage access to query creation, media fetch, snapshot replacement, and page refresh.

flowchart LR
    A[Music or video library] --> B[Supported-file query]
    B --> C[Metadata and source items]
    C --> D[Music or video snapshot]
    D --> E[Library pages and search]
    F[Cached records] --> C
    G[File or folder changes] --> B

References: Screenbox.Core/…/ILibraryService.cs• L15-57 Screenbox.Core/…/LibraryService.cs• L50-75 Screenbox.Core/…/LibraryService.cs• L110-214 Screenbox.Core/…/LibraryService.cs• L217-305

Change tracking

The library coordinator owns query watchers, refresh timers, and cancellation for active fetches. File changes are debounced before a refresh so a group of changes produces one library update. Changing indexer or removable-storage settings recreates the watchers. The UI can therefore show partial progress while the final snapshot is still loading.

References: Screenbox.Core/…/LibraryCoordinator.cs• L19-42 Screenbox.Core/…/LibraryCoordinator.cs• L70-102 Screenbox.Core/…/LibraryCoordinator.cs• L181-310

Browsing and organization

Song browsing

The song view starts from all songs in the music snapshot. It can filter by genre and group songs by title, album, artist, year, or date added. The selected sort order is part of the music browsing experience, and playing a song uses the current song collection as the queue context.

References: Screenbox.Core/…/SongsPageViewModel.cs• L20-29 Screenbox.Core/…/SongsPageViewModel.cs• L56-107 Screenbox.Core/…/SongsPageViewModel.cs• L110-239 Screenbox/…/SongsPage.xaml• L22-60

Album browsing

The album view groups the music snapshot into album cards. Genre filtering applies to the songs related to each album. Users can group albums by title, artist, year, or date added, then open an album page or play its ordered songs.

An album page is a focused view of the album relationship. It shows the album art, year, song count, total duration, and track order, and it can play or shuffle the album contents.

References: Screenbox.Core/…/AlbumsPageViewModel.cs• L21-33 Screenbox.Core/…/AlbumsPageViewModel.cs• L64-131 Screenbox.Core/…/AlbumViewModel.cs• L19-46 Screenbox.Core/…/AlbumDetailsPageViewModel.cs• L14-95

Artist browsing

The artist view groups known artists by the first character of their name. An artist page groups the artist's songs by album and orders those groups by release year. The same related-song set supports browsing, play, shuffle, and queue actions.

References: Screenbox.Core/…/ArtistsPageViewModel.cs• L16-20 Screenbox.Core/…/ArtistsPageViewModel.cs• L48-90 Screenbox.Core/…/ArtistDetailsPageViewModel.cs• L19-100 Screenbox.Core/…/ArtistViewModel.cs• L17-27

Folder browsing

Folder browsing exposes the physical organization of supported media. A folder item represents either a child folder or a media item. Breadcrumbs preserve the path through the folder tree, and the current folder's supported items form the playback collection for that view.

The video experience links its library roots to this folder browser. A library with one root opens that folder directly. A library with several roots first shows the roots, so users can choose which source tree to enter.

References: Screenbox.Core/…/FolderViewPageViewModel.cs• L22-47 Screenbox.Core/…/FolderViewPageViewModel.cs• L68-129 Screenbox.Core/…/FolderViewPageViewModel.cs• L192-271 Screenbox.Core/…/FilesService.cs• L70-81

Playlist and recent experiences

Playlist items

Playlists are user-managed collections of media items rather than another library classification. A playlist keeps its own order and can contain repeated media items as separate entries. It can be played, queued, reordered, saved, renamed, exported, or opened as a detail view.

Playlist entries retain enough media identity and metadata to be restored even when they are not currently part of the active library snapshot. See playlists and recent media for persistence and recent-item behavior.

References: Screenbox.Core/…/PlaylistsContext.cs• L7-16 Screenbox.Core/…/PlaylistViewModel.cs• L23-46 Screenbox.Core/…/PlaylistViewModel.cs• L103-145 Screenbox.Core/…/PlaylistViewModel.cs• L167-233

Recent media

Recent media is a separate entry point built from the platform's recently used file list. It reuses known media items when possible, removes stale entries, and loads missing details or thumbnails when the Home view needs them. A recent item can come from outside the indexed library while still using the same media model.

References: Screenbox.Core/…/HomePageViewModel.cs• L26-70 Screenbox.Core/…/HomePageViewModel.cs• L109-239 Screenbox.Core/…/FilesService.cs• L149-176

Search and discovery

Search runs across the current music, video, and playlist collections. It matches display names without regard to case and returns separate result groups for songs, videos, artists, albums, and playlists. Suggestions draw from the same groups and favor matches near the start of a name.

The result page shows a compact section for each category with a path to the full category result when more items exist. Selecting an artist, album, or song returns the user to the same detail and playback flows used by library pages.

flowchart LR
    Q[Search text] --> S[Local collection search]
    S --> R[Grouped result]
    R --> P[Artists, albums, songs, videos, playlists]
    P --> D[Detail or playback flow]

See search and content discovery for search behavior and result navigation.

References: Screenbox.Core/…/ISearchService.cs• L6-15 Screenbox.Core/…/SearchService.cs• L12-111 Screenbox.Core/…/SearchResult.cs• L6-50 Screenbox.Core/…/SearchResultPageViewModel.cs• L15-157 Screenbox/…/SearchResultPage.xaml• L91-230

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the music snapshot's song-to-album and song-to-artist relationships aligned with the metadata fields used by grouping and detail pages.
  • Keep library query filters and folder-browser supported formats aligned when supported media types change.
  • Preserve source location identity when changing cache records, playlist records, or media factory lookup rules.
  • Keep search result categories aligned with the result page sections and category-specific “See all” navigation.
  • Keep snapshot replacement and loading notifications aligned with pages that rebuild their groups after a library refresh.

Important failure modes

TriggerConsequenceGuard
A music file has no usable album or artist tagsThe song cannot join a named album or artistKeep it in the unknown album or unknown artist group.
A cached library no longer matches its folders or tracked changesLibrary pages can show removed or missing mediaValidate paths and changes before accepting the cache.
A source file or network path is no longer availableThe item can remain visible but cannot load details, artwork, or playbackResolve the source lazily and expose availability instead of assuming the file is present.
A playlist or folder item is an expandable containerQueue creation can treat the container as a playable fileExpand the source before direct playback.
A search category grows beyond the result-page previewThe first page hides valid matchesPreserve the category count and enable its full-result route.

Key files

FileWhy to read it
Screenbox.Core/…/LibraryContext.csShows the shared music and video library state.
Screenbox.Core/…/LibraryCoordinator.csShows how library watching, refresh, cancellation, and loading state are coordinated.
Screenbox.Core/…/LibraryService.csShows how storage queries become music and video snapshots.
Screenbox.Core/…/MediaViewModel.csDefines the common media item used across library and playback experiences.
Screenbox.Core/…/AlbumViewModelFactory.csShows how songs become album relationships.
Screenbox.Core/…/ArtistViewModelFactory.csShows how song artist metadata becomes artist relationships.
Screenbox.Core/…/FolderViewPageViewModel.csShows physical folder navigation and folder playback collections.
Screenbox.Core/…/AlbumsPageViewModel.csShows album filtering and grouping.
Screenbox.Core/…/ArtistsPageViewModel.csShows artist grouping and browsing.
Screenbox.Core/…/SearchService.csShows the shared discovery surface across media categories.
Screenbox.Core/…/PlaylistViewModel.csShows how user-owned collections connect media items to queue and persistence flows.