| Crates.io | tauri-plugin-libmpv |
| lib.rs | tauri-plugin-libmpv |
| version | 0.3.2 |
| created_at | 2025-09-27 00:52:11.341654+00 |
| updated_at | 2025-11-24 04:32:22.901521+00 |
| description | A Tauri plugin for embedding the mpv player in your app via libmpv. |
| homepage | |
| repository | https://github.com/nini22P/tauri-plugin-libmpv |
| max_upload_size | |
| id | 1856836 |
| size | 280,495 |
A Tauri plugin for embedding the mpv player in your app via libmpv.
npm run tauri add libmpv
The setup script automatically downloads the libmpv-wrapper. On Windows, it also downloads libmpv (via zhongfly's builds).
For macOS and Linux, please install the system libmpv manually:
brew install mpvsudo apt install libmpv-devRun the script:
npx tauri-plugin-libmpv-api setup-lib
If you prefer to set things up manually, please follow the instructions below for your operating system.
This plugin requires two parts to work:
libmpv-wrapper (Interface between plugin and libmpv).libmpv (The video player core).Download the Wrapper:
libmpv-wrapper-windows-x86_64.ziplibmpv-wrapper-windows-aarch64.ziplibmpv-wrapper.dll.Download libmpv:
mpv-dev-lgpl-...7z for your architecture (x86_64 or aarch64).v3 version unless you are sure your CPU supports it.libmpv-2.dll.Project Setup:
lib inside your src-tauri directory.libmpv-wrapper.dll and libmpv-2.dll into src-tauri/lib/.Install System libmpv:
sudo apt install libmpv-dev
Download the Wrapper:
libmpv-wrapper-linux-x86_64.ziplibmpv-wrapper-linux-aarch64.ziplibmpv-wrapper.so.Project Setup:
lib inside your src-tauri directory.libmpv-wrapper.so into src-tauri/lib/.Install System libmpv:
brew install mpv
Download the Wrapper:
libmpv-wrapper-macos-aarch64.ziplibmpv-wrapper-macos-x86_64.ziplibmpv-wrapper.dylib.Project Setup:
lib inside your src-tauri directory.libmpv-wrapper.dylib into src-tauri/lib/.You must configure Tauri to bundle the dynamic libraries (.dll or .so) with your application so they are available at runtime.
src-tauri/tauri.conf.json{
"bundle": {
"resources": [
"lib/**/*"
]
}
}
For mpv to properly embed into your Tauri window, you need to configure transparency:
src-tauri/tauri.conf.json{
"app": {
"windows": [
{
"title": "Your App",
"width": 1280,
"height": 720,
"transparent": true // Add this line
}
]
}
}
/* In your main CSS file */
html,
body {
background: transparent;
}
import {
MpvObservableProperty,
MpvConfig,
init,
observeProperties,
command,
setProperty,
getProperty,
destroy,
} from 'tauri-plugin-libmpv-api'
// Properties to observe
// Tip: The optional third element, 'none', signals to TypeScript that the property's value may be null
// (e.g., when a file is not loaded), ensuring type safety in the callback function.
const OBSERVED_PROPERTIES = [
['pause', 'flag'],
['time-pos', 'double', 'none'],
['duration', 'double', 'none'],
['filename', 'string', 'none'],
] as const satisfies MpvObservableProperty[]
// mpv configuration
const mpvConfig: MpvConfig = {
initialOptions: {
'vo': 'gpu-next',
'hwdec': 'auto-safe',
'keep-open': 'yes',
'force-window': 'yes',
},
observedProperties: OBSERVED_PROPERTIES,
}
// Initialize mpv
try {
await init(mpvConfig)
console.log('mpv initialization completed successfully!')
} catch (error) {
console.error('mpv initialization failed:', error)
}
// Observe properties
const unlisten = await observeProperties(
OBSERVED_PROPERTIES,
({ name, data }) => {
switch (name) {
case 'pause':
// data type: boolean
console.log('Playback paused state:', data)
break
case 'time-pos':
// data type: number | null
console.log('Current time position:', data)
break
case 'duration':
// data type: number | null
console.log('Duration:', data)
break
case 'filename':
// data type: string | null
console.log('Current playing file:', data)
break
}
})
// Load and play a file
await command('loadfile', ['/path/to/video.mp4'])
// Set property
await setProperty('volume', 75)
// Get property
const volume = await getProperty('volume', 'int64')
console.log('Current volume is:', volume)
// Clean up when done
// unlisten()
// await destroy()
| Platform | Status | Notes |
|---|---|---|
| Windows | ✅ | Fully tested. Requires libmpv-2.dll and libmpv-wrapper.dll. |
| Linux | ⚠️ | Experimental. Window embedding is not working. Requires system libmpv and libmpv-wrapper.so. |
| macOS | ⚠️ | Not tested. |
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MPL-2.0 License - see the LICENSE file for details.