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 / external-media-integrations

External media integrations

External media integrations let Screenbox send playback to devices outside the app or use the current media item to drive a Lively Wallpaper visualizer. Casting moves playback to a discovered renderer, while Lively keeps a local visualizer in step with the queue and playback state.

Integration model

The integrations use the existing player and queue as their source of truth. Casting changes the player’s output target. Lively reads the selected visualizer and current queue item, then sends the media state to the visualizer.

The two paths have different ownership:

IntegrationExternal targetMain purpose
CastingA network renderer such as a cast devicePlay media outside the local app
LivelyA local web-based wallpaper visualizerDisplay playback-aware visuals and track data

The relationship between local playback and these targets is summarized below.

flowchart LR
    Q[Current queue item] --> P[Local media player]
    P --> C[Cast target]
    Q --> L[Lively visualizer]
    P --> S[Playback state]
    S --> L

Casting

Casting provides a short-lived device discovery and control flow from the player controls. A renderer is an available external playback target that reports its name, type, and audio or video support.

Cast target discovery

The cast control opens discovery when its flyout opens and stops discovery when the flyout closes. The watcher reports targets as they appear or disappear, so the user sees only devices that are currently available.

The shared cast context holds the active watcher and selected target. The control view model owns the visible list and removes a target when the watcher reports that it is gone.

References: Screenbox/…/CastControl.xaml.cs• L19-26 Screenbox.Core/…/CastControlViewModel.cs• L44-69 Screenbox.Core/…/RendererWatcher.cs• L11-30 Screenbox.Core/…/CastContext.cs• L7-14

Cast session control

The user selects an available renderer and starts casting from the player controls. Screenbox then assigns that renderer to the media player and records the active target. Stopping casting clears the target and resumes local output.

The cast service keeps this boundary small: it creates a discovery watcher and applies or removes the active renderer. The detailed cast behavior is described in Casting media.

References: Screenbox/…/PlayerControls.xaml.cs• L51-70 Screenbox.Core/…/CastControlViewModel.cs• L71-99 Screenbox.Core/…/ICastService.cs• L7-18 Screenbox.Core/…/CastService.cs• L8-22

Lively wallpaper control

Lively integration uses a visualizer, which is a Lively wallpaper package that can render a local web page. Screenbox lists built-in and user-installed visualizers, lets the user select one, and presents the selected page in a muted WebView.

Visualizer selection

The selector loads visualizers from the app’s preset and user locations. It stores the selected path in player settings so the same visualizer can be restored later. Users can also import supported ZIP packages and remove user-installed visualizers.

Only packages with Lively metadata and local web or web-audio types are accepted for installation. The service also identifies whether a visualizer supports music data or pause notifications, so playback updates are sent only when the visualizer declares support.

References: Screenbox.Lively/…/ILivelyWallpaperService.cs• L8-12 Screenbox.Lively/…/LivelyWallpaperService.cs• L21-73 Screenbox.Lively/…/LivelyWallpaperUtil.cs• L13-51 Screenbox.Lively/…/LivelyWallpaperSelectorViewModel.cs• L62-90 Screenbox.Lively/…/LivelyWallpaperSelectorViewModel.cs• L108-157

Playback state bridge

The wallpaper player follows visualizer changes and current queue-item changes through app messages. When the selected page is ready, it sends supported Lively callbacks for the current track and pause state. Track data includes the title, artist, and available thumbnail.

The WebView is muted because the local media player remains the playback source. When the wallpaper is hidden, the player delays visual updates and reports the hidden state as a pause event when the visualizer supports that feature.

References: Screenbox.Lively/…/LivelyWallpaperPlayerViewModel.cs• L29-105 Screenbox.Lively/…/LivelyWallpaperPlayerViewModel.cs• L107-123 Screenbox.Lively/…/LivelyWallpaperPlayerViewModel.cs• L209-259 Screenbox/…/LivelyWebWallpaperPlayer.xaml.cs• L41-57 Screenbox/…/LivelyWebWallpaperPlayer.xaml.cs• L159-205

Service boundary

Both integrations are registered as app services and exposed to UI controls through view models. This keeps device discovery, package handling, and playback-state translation separate from the player pages that present them.

The core app owns casting. The Lively project adds its service and view models during app startup, while the player and selector controls provide the user-facing entry points.

References: Screenbox.Core/…/ServiceHelpers.cs• L26-28 Screenbox.Core/…/ServiceHelpers.cs• L59-86 Screenbox/App.xaml.cs• L129-148 Screenbox.Lively/LivelyWallpaperServiceExtensions.cs• L11-27

Change checklist

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

  • Keep cast discovery lifetime aligned with the cast flyout. A watcher that remains active after the flyout closes can keep stale targets and event handlers alive.
  • Keep renderer availability and active-renderer state aligned. A removed target must not remain selectable or be sent back to the media player.
  • Keep Lively package validation aligned with the metadata fields used by the WebView player. A package that loads in the selector may still lack a usable page or supported playback callbacks.
  • Keep queue-item and playback-state messages aligned with the Lively callbacks. Changes to title, artist, thumbnail, or pause state affect external visualizers without changing the local player.
  • Keep the saved Lively path compatible with visualizer discovery. A path that no longer resolves must fall back to the default visualizer.

Important failure modes

TriggerConsequenceGuard
The cast target disappears during discovery or castingThe target is removed and can no longer receive playbackRenderer-loss handling removes it from the list and clears the selection
No media player exists when discovery or cast control startsDiscovery or cast commands do not startCast control checks the current player before creating a watcher or applying a target
An imported ZIP lacks valid Lively metadata or required web wallpaper supportThe visualizer is rejected and is not added to the selectorPackage metadata is read and checked before extraction is kept
The saved visualizer path no longer existsNo prior visualizer can be restoredSelection falls back to the default entry
A WebView page cannot load or lacks a Lively callbackThe visualizer shows no page or misses track and pause updatesNavigation errors are reported and updates are gated by page readiness and capability flags

Key files

FileWhy to read it
Screenbox.Core/…/CastControlViewModel.csShows the user flow for discovering, selecting, starting, and stopping a cast session
Screenbox.Core/…/ICastService.csDefines the boundary between cast controls and the media player
Screenbox.Core/…/RendererWatcher.csShows how external playback targets appear and disappear
Screenbox.Lively/…/LivelyWallpaperService.csShows how visualizers are found, validated, and installed
Screenbox.Lively/…/LivelyWallpaperSelectorViewModel.csShows selection persistence and user visualizer management
Screenbox.Lively/…/LivelyWallpaperPlayerViewModel.csShows how queue and playback state become Lively updates
Screenbox/…/LivelyWebWallpaperPlayer.xaml.csShows the WebView lifecycle and visibility handling for visualizers