Skip to content

fix(desktop): load provider external subtitles into native player#168

Open
fmustafayaman wants to merge 1 commit into
NuvioMedia:Devfrom
fmustafayaman:fix/desktop-external-subtitles
Open

fix(desktop): load provider external subtitles into native player#168
fmustafayaman wants to merge 1 commit into
NuvioMedia:Devfrom
fmustafayaman:fix/desktop-external-subtitles

Conversation

@fmustafayaman

Copy link
Copy Markdown

Summary

On macOS/Windows the desktop native player surface received the externalSubtitles list in PlatformPlayerSurface but never forwarded it to NativePlayerSurface, so subtitles supplied by stream providers (getStreamsexternalSubtitles) never reached mpv. As a result the in-player subtitle menu showed nothing under Built-in, even though the provider returned valid subtitle tracks.

This change:

  • Forwards externalSubtitles from PlatformPlayerSurface into NativePlayerSurface.
  • After the native player has attached the media, adds each subtitle URL via the existing setSubtitleUriNativePlayerBridge.addSubtitleUrl (mpv sub-add ... select) path.

The Android engine (PlayerEngine.android.kt) already wires externalSubtitles into the player via MediaItem.SubtitleConfiguration; this brings the desktop native engine to parity.

Implementation notes

  • Pure Kotlin change in composeApp/src/desktopMain/.../player/PlayerEngine.desktop.kt; no native (.mm / .cpp) changes required since addSubtitleUrl already exists in the bridge.
  • Subtitles are added in a LaunchedEffect keyed on controller, sourceUrl, externalSubtitles and gated on hostFirstFullSizePaintComplete, with a short delay so the player has loaded the media before sub-add is issued.

Test plan

  • Built locally on macOS arm64 (./gradlew :composeApp:run).
  • Played a stream from a provider that returns externalSubtitles; logs show setSubtitleUri being invoked with a valid player handle and the subtitle track appearing/selectable under Built-in (previously empty).
  • Verify on Windows native player.

Made with Cursor

On macOS/Windows the native player surface ignored the `externalSubtitles`
passed to `PlatformPlayerSurface`, so subtitles supplied by stream providers
(via `getStreams` -> `externalSubtitles`) never reached mpv and the
subtitle menu showed nothing under "Built-in".

Forward `externalSubtitles` into `NativePlayerSurface` and, once the player
has attached, add each subtitle URL through the existing `setSubtitleUri`
(mpv `sub-add`) path. The Android engine already wires these up; this brings
the desktop native engine to parity.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant