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 / playlists-and-recent-media

Playlists and recent media

Playlists and recent media give users two ways to return to media they care about. Playlists are named collections that persist across app runs and can be edited or exported. Recent media is a view of recently opened or played local items that uses system access records so the app can find them again.

Collection contexts

The collection contexts provide shared in-memory views for the pages and playback features. PlaylistsContext holds the loaded user playlists, while RecentContext holds recent media and the access-token links needed to resolve it. These contexts keep list pages, detail pages, search, and playback state aligned without making each view load its own copy. References: Screenbox.Core/…/PlaylistsContext.cs• L7-16, Screenbox.Core/…/RecentContext.cs• L8-32, Screenbox.Core/…/ServiceHelpers.cs• L60-61

Playlist context

The playlist context is the shared source for the playlist list view. Startup loads persistent records into this context, and create, rename, and delete actions update the same collection so navigation sees the current set. References: Screenbox.Core/…/MainPageViewModel.cs• L289-317, Screenbox.Core/…/PlaylistsPageViewModel.cs• L21-44

Recent context

The recent context joins display items to the operating system's Most Recently Used list. It stores both the visible media and the token mappings that let the app remove stale entries or remove one item when the user asks. References: Screenbox.Core/…/RecentContext.cs• L8-32, Screenbox.Core/…/HomePageViewModel.cs• L128-220

Playlist persistence

Playlist persistence separates a user collection from the media library. The persistence service saves a playlist record with its name, update time, and ordered media locations, then restores media details when the collection is loaded. The database keeps playlist rows and ordered item rows, so deleting a playlist also removes its items. References: Screenbox.Core/…/IPlaylistService.cs• L9-37, Screenbox.Core/…/DatabaseService.Playlists.cs• L11-63, Screenbox.Core/…/DatabaseService.Schema.cs• L370-385

The service also bridges playlists and portable files. Users can import entries from M3U or M3U8 files and export a playlist as UTF-8 M3U8. Imported entries become a normal persistent playlist, while exported entries carry a title and location for playback outside the app. References: Screenbox.Core/…/PlaylistService.cs• L82-114, Screenbox.Core/…/PlaylistsPageViewModel.cs• L82-106

Playlist list view

The playlist list view is the entry point for managing named collections. It supports creation, import, rename, export, deletion, and multi-select playback actions. A selected playlist can start playback, add its items to the queue, or play after the current item. References: Screenbox/Pages/PlaylistsPage.xaml#L73-L205, Screenbox/…/PlaylistsPage.xaml.cs• L46-81, Screenbox.Core/…/PlaylistsPageViewModel.cs• L56-163

The list view treats several selected playlists as one playback request. A single selected playlist keeps its playlist identity as the queue origin. Multiple selected playlists become an ad-hoc media collection. This distinction lets playback and recent-media logic tell a durable playlist from a temporary combination. References: Screenbox.Core/…/PlaylistsPageViewModel.cs• L108-150, Screenbox.Core/…/QueueOrigin.cs• L40-50

Playlist detail view

The detail view presents one playlist as an ordered playback collection. It shows the collection name, item count, and total run time, then lets users play from a chosen item, shuffle the collection, add files, remove items, reorder items, rename the playlist, export it, or delete it. References: Screenbox/Pages/PlaylistDetailsPage.xaml#L106-L243, Screenbox.Core/…/PlaylistDetailsPageViewModel.cs• L54-169

The detail view accepts files through both a picker and drag and drop. Dropped playlist sources can expand into their media entries before insertion. Changes to the item list are saved after the list settles, so reorder and add operations update the persistent collection without requiring a separate save action. References: Screenbox/…/PlaylistDetailsPage.xaml.cs• L88-112, Screenbox.Core/…/PlaylistDetailsPageViewModel.cs• L116-140, Screenbox.Core/…/PlaylistViewModel.cs• L81-100

The following flow shows how playlist edits become durable data and how playback keeps the playlist identity.

flowchart LR
    A[Playlist list or detail view] --> B[Playlist view model]
    B --> C[Playlist service]
    C --> D[Persistent playlist records]
    B --> E[Queue with playlist origin]
    E --> F[Playback and recent-media tracking]

Recent-media view

The recent-media view gives the home page a fast return path to local media. Playback and file-opening flows add eligible files or collections to the system MRU list, and the home page resolves those records into media cards when it loads. The view supports direct play, play next, queue, multi-select playback, and removal. References: Screenbox.Core/…/FilesService.cs• L149-176, Screenbox.Core/…/QueueService.cs• L144-160, Screenbox/Pages/HomePage.xaml#L138-L195, Screenbox.Core/…/HomePageViewModel.cs• L276-353

Recent entries are best effort because a file can move, disappear, or lose access after it is recorded. The home page drops entries it cannot resolve when the system reports a missing or unauthorized file, while it keeps entries that may refer to a folder or a temporarily unavailable source. It loads details and thumbnails after the list is built. References: Screenbox.Core/…/HomePageViewModel.cs• L150-239, Screenbox.Core/…/HomePageViewModel.cs• L242-274, Screenbox.Core/…/HomePageViewModel.cs• L355-385

The recent list is controlled by the general setting that shows recent media. Turning it off clears the shared recent context. Clearing recent history also clears the system MRU list, which removes the access records used to rebuild the view. References: Screenbox.Core/…/SettingsPageViewModel.cs• L134-141, Screenbox.Core/…/SettingsPageViewModel.cs• L259-272

Playback origins

Playback origins describe what created a queue. A playlist origin uses the stable playlist ID, while an album, artist, single item, or ad-hoc media collection uses its own source identity. This identity allows a playlist detail card to show active playback and prevents a temporary collection from being treated as a saved playlist. References: Screenbox.Core/…/QueueOrigin.cs• L12-72, Screenbox.Core/…/PlaylistViewModel.cs• L153-176

When playback starts from a durable playlist, the queue retains that playlist origin. When playback starts from a folder, playlist file, or multi-file selection, the queue records a media-collection origin instead. The system MRU list tracks file-backed collections so the app can retain access to them for later recent-media loading. References: Screenbox.Core/…/QueueService.cs• L195-220, Screenbox.Core/…/QueueService.cs• L246-263, Screenbox.Core/…/QueueService.cs• L483-490

Change checklist

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

  • Keep playlist item order consistent between the detail view, the playlist record, and the ordered database rows.
  • Keep queue-origin identity aligned with playlist IDs so active playback state still maps to the correct playlist.
  • Keep M3U import and export behavior aligned with the media locations accepted by queue parsing.
  • Keep recent-media removal aligned with both the visible collection and its system MRU token.
  • Keep the recent-media setting aligned with both context clearing and new MRU registration.

Important failure modes

TriggerConsequenceGuard
A recent MRU token points to a moved, deleted, or inaccessible fileThe entry cannot be rebuilt and can remain as stale system stateRemove tokens for missing or unauthorized files during recent-list refresh
A playlist item has no usable locationThe item cannot play or export as a valid M3U entrySkip blank or about:blank locations during export and keep unavailable items distinct
A playlist is deleted while its detail view is openThe page can still hold an old in-memory sourceDelete through the persistence service and leave the detail page only after deletion succeeds
Playlist item changes are not persisted after reorder or insertThe visible order differs from the next loaded orderSave after collection changes through the playlist view model

Key files

FileWhy to read it
Screenbox.Core/…/PlaylistsContext.csShared playlist collection used by list and navigation views
Screenbox.Core/…/RecentContext.csShared recent collection and system-token links
Screenbox.Core/…/IPlaylistService.csContract for playlist save, load, import, and export
Screenbox.Core/…/PlaylistService.csBoundary between user actions, storage, and playlist files
Screenbox.Core/…/DatabaseService.Playlists.csPersistence model for playlist names and ordered items
Screenbox.Core/…/PlaylistViewModel.csPlaylist identity, edits, playback actions, and save behavior
Screenbox.Core/…/PlaylistsPageViewModel.csPlaylist list actions and multi-playlist playback
Screenbox.Core/…/PlaylistDetailsPageViewModel.csSingle-playlist editing and detail actions
Screenbox.Core/…/HomePageViewModel.csRecent-media loading, cleanup, and playback actions
Screenbox.Core/…/QueueOrigin.csIdentity rules that connect collections to playback state
Screenbox/Pages/PlaylistsPage.xamlPlaylist list interaction surface
Screenbox/Pages/PlaylistDetailsPage.xamlPlaylist detail and ordered item interaction surface
Screenbox/Pages/HomePage.xamlRecent-media interaction surface