# mpv integration

Yokan resolves `io.github.kmpmpv:kmp-mpv:0.1.0-SNAPSHOT` from the repository-contained `vendor/kmp-mpv` composite build. A standalone checkout therefore needs no adjacent repository or local Maven publication.

## Backend behavior

| Target | Primary | Fallback |
|---|---|---|
| Android | mpv 0.39.0, bundled for four ABIs | ComposeMediaPlayer if mpv initialization fails |
| Windows x64 | bundled media-kit `libmpv-2.dll` + Compose software frames | ComposeMediaPlayer |
| macOS | bundled media-kit XCFramework binaries + Compose software frames | ComposeMediaPlayer |
| Linux | distribution libmpv + Compose software frames | ComposeMediaPlayer when libmpv is missing |
| iOS arm64 device | embedded media-kit XCFrameworks + software frames | ComposeMediaPlayer if initialization fails |
| iOS simulator | unavailable in the media-kit archive | ComposeMediaPlayer |

The common controller routes requests with custom headers through Yokan's local media stream proxy, serializes player commands, and mirrors mpv state into the existing UI contract.

Desktop initializes mpv with `vo=libmpv` and copies its software-rendered BGRA frames into a Compose `ImageBitmap`. Keeping video inside the Compose scene preserves the z-order and input handling of Yokan's playback controls; a heavyweight AWT `Canvas` would otherwise cover those controls on desktop.

## iOS build

`iosApp/BuildSharedFramework.sh` builds the Compose framework, runs `vendor/kmp-mpv/scripts/prepare-media-kit-ios.sh` for device builds, copies every native framework into the application Frameworks directory, and signs them when Xcode supplies a signing identity.

The Xcode target links `Mpv.framework` and `Lua.framework` only for `iphoneos`. The pinned archive has no simulator slice, so simulator builds intentionally avoid those linker flags.

## Linux prerequisite

Install the system mpv/libmpv package before launching Yokan. Debian/Ubuntu development environments use `mpv` and `libmpv-dev`. The application catches libmpv initialization failure and retains its previous ComposeMediaPlayer path as a runtime fallback.

## Native artifact and license audit

Artifact URLs, SHA-256 checksums, Lua verification, and licensing notes live in `vendor/kmp-mpv/README.md` and `vendor/kmp-mpv/THIRD_PARTY_NOTICES.md`. The pinned Windows binary has GPL features enabled and must be handled as a GPL distribution.
