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:
| Integration | External target | Main purpose |
|---|---|---|
| Casting | A network renderer such as a cast device | Play media outside the local app |
| Lively | A local web-based wallpaper visualizer | Display 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
| Trigger | Consequence | Guard |
|---|---|---|
| The cast target disappears during discovery or casting | The target is removed and can no longer receive playback | Renderer-loss handling removes it from the list and clears the selection |
| No media player exists when discovery or cast control starts | Discovery or cast commands do not start | Cast control checks the current player before creating a watcher or applying a target |
| An imported ZIP lacks valid Lively metadata or required web wallpaper support | The visualizer is rejected and is not added to the selector | Package metadata is read and checked before extraction is kept |
| The saved visualizer path no longer exists | No prior visualizer can be restored | Selection falls back to the default entry |
| A WebView page cannot load or lacks a Lively callback | The visualizer shows no page or misses track and pause updates | Navigation errors are reported and updates are gated by page readiness and capability flags |
Key files
| File | Why to read it |
|---|---|
| Screenbox.Core/…/CastControlViewModel.cs | Shows the user flow for discovering, selecting, starting, and stopping a cast session |
| Screenbox.Core/…/ICastService.cs | Defines the boundary between cast controls and the media player |
| Screenbox.Core/…/RendererWatcher.cs | Shows how external playback targets appear and disappear |
| Screenbox.Lively/…/LivelyWallpaperService.cs | Shows how visualizers are found, validated, and installed |
| Screenbox.Lively/…/LivelyWallpaperSelectorViewModel.cs | Shows selection persistence and user visualizer management |
| Screenbox.Lively/…/LivelyWallpaperPlayerViewModel.cs | Shows how queue and playback state become Lively updates |
| Screenbox/…/LivelyWebWallpaperPlayer.xaml.cs | Shows the WebView lifecycle and visibility handling for visualizers |