Skip to content

fix(player): load mpv scripts before init; place separate-window player on Harbor's display - #1422

Closed
Thunderhawkk wants to merge 1 commit into
harborstremio:beta-branchfrom
Thunderhawkk:mpv-scripts
Closed

Thunderhawkk wants to merge 1 commit into
harborstremio:beta-branchfrom
Thunderhawkk:mpv-scripts

Conversation

@Thunderhawkk

Copy link
Copy Markdown
Collaborator

Summary

Fixes Windows HDR script loading and separate-window display placement:

Script loading: scripts, script-opts, and load-scripts are init-only mpv options that cannot be set after mpv_initialize. extra_options are now split into init-only and runtime pairs so scripts (e.g. hdr-mode.lua, display-info.lua) are applied before initialization.

Separate-window placement: the separate-window player always opened on the primary monitor. It now opens on the monitor where the Harbor main window sits, by resolving the main window's monitor index and setting mpv's screen option before init.
Removed dead vo-window tracking: drops MPV_VO_MONITOR / capture_mpv_vo_monitor — the vo window is destroyed before restore runs, so the feature could never work. SDR restore now simply targets the Harbor main window's monitor.

Known limitation (intentional, not addressed here): separate-window mode still does not flip the display back to SDR on exit. That behavior is left as-is per the current scope; only embedded-mode exit restore is guaranteed.

Why

  • The separate-window mpv window ignored which display the user was actually using, landing on the primary monitor instead of the TV.
  • The vo-window monitor tracking for HDR restore was fundamentally broken (referenced a window destroyed before restore) and was removed rather than papered over.
  • apply_pre_init previously couldn't express script configuration at all because script options are rejected after init; splitting extra_options gives the pre-init pass the missing capability.
  • This fits Harbor's architecture: Rust owns OS/display behavior, and the frontend only re-syncs its HDR stage state after the OS-level flip lands.

Verification

  • cargo check --manifest-path src-tauri/Cargo.toml — clean
  • cargo test --manifest-path src-tauri/Cargo.toml --lib extra_option_parser — 8 passed.
  • cargo test --manifest-path src-tauri/Cargo.toml --lib script_pre_init — 5 passed.
  • pnpm run typecheck
  • Manual (pending TV retest): separate-window player should open on the monitor showing the Harbor main window. With HDR mode lua script Embedded-mode HDR-off-on-exit restore behavior is unchanged.

Platform Impact

  • Windows: primary target — EnumDisplayMonitors index resolution, pre-init screen set, DisplayConfig-based HDR flip/restore (Win32_Devices_Display feature added).

Checklist

  • This pull request is focused and contains no unrelated refactors.
  • I ran vp check for the changed files.
  • I ran vp run typecheck after TypeScript changes.
  • I ran the relevant Cargo checks after Rust changes.
  • I tested affected platforms when the change is platform-specific.
  • I preserved playback, navigation, and configured hotkey behavior where applicable.
  • I added or updated tests for behavior changes.
  • I removed secrets, tokens, private URLs, and personal data from logs and screenshots.

@Talal1011 Talal1011 added this to the Beta 0.9.126 milestone Sep 13, 2026
@Talal1011

Copy link
Copy Markdown
Collaborator

Release tracking: this work was integrated through our experimental/beta release branch and is carried in Beta 0.9.126 (published build e758926), with integration adjustments where needed. Closing the PR as already incorporated into the release build; this does not indicate a new merge into the upstream beta branch. Thank you for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants