A demo application built with Tauri 2.0, Next.js, and the Tauri Opener plugin to play videos in VLC player.
- Node.js (v16 or later)
- Rust (latest stable)
- VLC Media Player installed
- Install dependencies:
npm install
- Add the opener plugin:
npm run tauri add opener
This command automatically:
- Adds the plugin to your Rust dependencies
- Configures the plugin in
tauri.conf.json
- Installs the required npm package
- Configure permissions in
src-tauri/capabilities/default.json
:
{
"permissions": [
"core:default",
"opener:default",
"opener:allow-open-url",
"opener:allow-open-path",
"opener:allow-default-urls"
]
}
Here's how to use the opener plugin in your React component:
import { openPath } from '@tauri-apps/plugin-opener';
const handleOpenVLC = async () => {
try {
setIsLoading(true);
setError(null);
await openPath(videoUrl, '-a VLC');
console.log('Video opened in VLC');
} catch (err: unknown) {
console.error('Failed to open video:', err);
if (err instanceof Error) {
setError(err.message);
} else {
setError('Failed to open video');
}
} finally {
setIsLoading(false);
}
};
Start the development server:
npm run tauri:dev
- Make sure VLC is installed on your system
- Uses
openPath
with-a VLC
flag for macOS