Skip to content

feat: add IINA auto-pause support via mpv IPC socket - #858

Open
yuamera wants to merge 1 commit into
kyleneideck:masterfrom
yuamera:auto-pause-support-iina
Open

feat: add IINA auto-pause support via mpv IPC socket#858
yuamera wants to merge 1 commit into
kyleneideck:masterfrom
yuamera:auto-pause-support-iina

Conversation

@yuamera

@yuamera yuamera commented May 22, 2026

Copy link
Copy Markdown

Add IINA Auto-Pause Support

Summary

Add auto-pause support for IINA, a modern macOS media player based on mpv.

Background

IINA is one of the most popular open-source media players on macOS. Unlike Spotify/iTunes/VLC, IINA does not support AppleScript or Scripting Bridge, which are the standard mechanisms used by Background Music to control music players.

After extensive research, we discovered that IINA is built on top of mpv and supports mpv's JSON IPC protocol via Unix domain socket.

Implementation

  • Add BGIINA music player class implementing BGMMusicPlayer protocol
  • Control IINA playback via mpv JSON IPC protocol over Unix domain socket
  • Support multiple socket paths: /tmp/iina-mpv-socket, /tmp/mpv-socket
  • Cache successful socket path for performance

Security Measures

  • Use lstat to prevent symlink attacks
  • Verify socket file owner matches current user
  • Verify peer credentials via LOCAL_PEERCRED after connection
  • Set socket timeout (5 seconds) to prevent blocking

Commands Used

  • get_property "pause" - Query playback state
  • set_property "pause", true/false - Control playback

Prerequisite

User must configure ~/.config/mpv/mpv.conf with:

input-ipc-server=/tmp/iina-mpv-socket

Then restart IINA for the configuration to take effect.

Files Changed

  • BGMApp/BGMApp/Music Players/BGIINA.h (new)
  • BGMApp/BGMApp/Music Players/BGIINA.m (new)
  • BGMApp/BGMApp/Music Players/BGMMusicPlayers.mm (modified - add IINA import and registration)
  • BGMApp/BGMApp.xcodeproj/project.pbxproj (modified - add new files)

Testing

  • Tested on: macOS 15.7.5 (Intel x86_64)
  • IINA version: 1.4.3
  • Test scenarios:
    1. IINA playing video + browser audio → IINA pauses ✓
    2. Browser audio stops → IINA resumes ✓
    3. IINA manually paused → does not auto-resume ✓
    4. IINA closed → no errors ✓
    5. Socket not configured → graceful fallback ✓

@yuamera
yuamera force-pushed the auto-pause-support-iina branch from 0935df5 to ced811d Compare May 22, 2026 06:18
Add auto-pause support for IINA, a modern macOS media player based on mpv.

Implementation:
- Add BGIINA music player class implementing BGMMusicPlayer protocol
- Control IINA playback via mpv JSON IPC protocol over Unix domain socket
- Support multiple socket paths: /tmp/iina-mpv-socket, /tmp/mpv-socket
- Cache successful socket path for performance

Security measures:
- Use lstat to prevent symlink attacks
- Verify socket file owner matches current user
- Verify peer credentials via LOCAL_PEERCRED after connection
- Set socket timeout (5 seconds) to prevent blocking

Commands used:
- get_property "pause" - Query playback state
- set_property "pause", true/false - Control playback

Prerequisite:
User must configure ~/.config/mpv/mpv.conf with:
  input-ipc-server=/tmp/iina-mpv-socket

Files changed:
- BGMApp/BGMApp/Music Players/BGIINA.h (new)
- BGMApp/BGMApp/Music Players/BGIINA.m (new)
- BGMApp/BGMApp/Music Players/BGMMusicPlayers.mm (modified)
- BGMApp/BGMApp.xcodeproj/project.pbxproj (modified)

Tested on: macOS 15.7.5 (Intel x86_64), IINA 1.4.3
@yuamera
yuamera force-pushed the auto-pause-support-iina branch from ced811d to cb5f661 Compare May 22, 2026 06:21
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