4.6 KiB
API Media Player
API Media Player is a web-first PWA for browsing Hydrus media and handing playback off to native apps instead of an in-browser player.
What works today
- Start the app with
npm startand connect a Hydrus server from the web settings screen - Use
npm run devwhen you want the live-reload development server - Add one or more Hydrus clients from the Settings page or a local
.envfile - Launch playback in native apps:
- Windows and Linux desktop:
mpvthroughmpv-handler:// - Android:
mpv-androidthroughintent:// - iPhone and iPad: VLC through
vlc-x-callback://
- Windows and Linux desktop:
Fast start
- Install Node.js 20 or newer.
- Install dependencies:
npm install
- Start the app:
npm start
- Open the local URL printed in the terminal. By default it starts on
http://localhost:4173, but it will move to the next free port if that one is already in use.
On a fresh install the app opens the Hydrus server settings first. Add your host, port, and API key there, test the connection, then save the server before browsing the library. Playback itself is always external, so actual media launch still depends on the platform-specific player flow below.
npm start now builds the app and serves the production output, which is the safer default for devices like Raspberry Pi. Use npm run dev only when you specifically want the Vite development server and live reload.
Connect Hydrus (optional)
If you want real library data, duplicate .env.example as .env and fill in your Hydrus values:
VITE_HYDRUS_HOST=http://localhost
VITE_HYDRUS_PORT=45869
VITE_HYDRUS_API_KEY=
VITE_HYDRUS_SSL=false
You can also add or edit servers entirely from Settings inside the app. Nothing is preconfigured on first launch, so you enter the Hydrus connection details yourself.
Browsers cannot attach custom Hydrus API headers to direct media URLs. If your Hydrus setup requires header-based authentication for file access, put a trusted reverse proxy in front of it or provide playable URLs another way.
Playback setup by device
Windows desktop
- Install
mpvand optionallyyt-dlp. - Open an elevated PowerShell or Windows Terminal.
- From the repo root, run:
npm run setup:mpv-handler
The repo already includes the Windows mpv-handler binaries under scripts/, so the helper script can:
- reuse the bundled handler files
- detect
mpvandyt-dlpfromPATHwhen possible - update
scripts/config.toml - register
mpv-handler://andmpv-handler-debug://
To remove the registration later:
npm run uninstall:mpv-handler
Linux desktop
- Install
mpvand optionallyyt-dlp. - Download and extract the latest upstream Linux release:
https://github.com/akiirui/mpv-handler/releases/latest/download/mpv-handler-linux-amd64.zip
- Run the helper against the extracted folder:
npm run setup:mpv-handler -- --root /path/to/extracted/mpv-handler-linux-amd64
On Linux the helper copies the binary and desktop files into ~/.local, writes config.toml, and runs xdg-mime for both protocol handlers.
Android
Install mpv-android (is.xyz.mpv). No extra handler setup is needed.
iPhone / iPad
Install VLC for iOS. The app sends playback to vlc-x-callback:// automatically.
macOS desktop
The app can still browse Hydrus and demo content on macOS, but this repo does not currently automate mpv-handler:// registration for desktop macOS. If you already have a compatible custom protocol handler installed, the desktop playback flow will use it. Otherwise, use another supported playback platform for now.
Optional userscript for direct media URLs
If you want direct file loads in the browser to jump into mpv before the page player starts, install the userscript served by this app:
/userscripts/api-media-player-open-in-mpv.user.js
Examples:
http://localhost:4173/userscripts/api-media-player-open-in-mpv.user.js
http://127.0.0.1:4173/userscripts/api-media-player-open-in-mpv.user.js
If preview chooses a different port because 4173 is busy, use that same port for the userscript URL too.
It only activates on localhost, loopback, RFC1918 LAN IPs, and .local or .lan hosts. On desktop it redirects to mpv-handler://...; on Android it redirects to the mpv app through intent://....
Useful commands
npm start
npm run dev
npm run build
npm run preview
npm run typecheck
npm run setup:mpv-handler -- --help
More detail
See scripts/README.md for the helper script behavior, flags, and the Windows/Linux manual fallbacks.