Tauri Plugin Player
A Tauri plugin that provides media player control functionality for desktop and mobile platforms (Android, with iOS planned).
Features
- Player State Management: Update and manage player state including playback status, position, seek, volume, and playlists
- Media Event Channel: Receive media control events (play/pause, next/previous track) from native platform integrations
- Cross-Platform Support: Works on desktop (stub implementation) and Android (full native integration)
- Type-Safe API: Fully typed Rust and Kotlin APIs with serde serialization
Architecture
Rust Core (src/)
lib.rs: Plugin initialization and registration with Tauricommands.rs: Tauri command handlers (update_state)models.rs: Shared data models (Track,Playlist,UpdateState,MediaEvent, etc.)error.rs: Error types and result handlingdesktop.rs: Desktop platform implementation (stub)mobile.rs: Mobile platform implementation (delegates to native code)
Android Implementation (android/)
PlayerPlugin.kt: Tauri plugin interface with commands:initChannel: Initialize event channel for media eventsupdateState: Update player state from frontend
Player.kt: Player implementation with state management and event emission
Data Models
Track
Playlist
UpdateState
MediaEvent
InitChannel
Usage
Setup
Add the plugin to your Tauri application in src-tauri/src/main.rs:
Rust API
Access the player from any Tauri context:
use PlayerExt;
Primary methods on Player:
update_state(payload: UpdateState) -> Result<StateResponse>: Updates playback state, position, seek, volume, and playlistinit_channel(payload: InitChannel) -> Result<InitChannelResponse>: Initializes the media event channel for native play/pause/next/previous events
Command API
The plugin exposes the following Tauri command:
update_state: Update player state from the frontend
Dependencies
tauri: ^2.0.0serde: Serialization frameworkthiserror: Error handling
Platform Support
- Desktop (Windows, macOS, Linux): Stub implementation (methods return empty responses)
- Android: Full native implementation with media session integration
- iOS: Planned (native bindings defined but not implemented)
Development
Building
Android
The Android implementation is located in android/ and follows standard Tauri plugin conventions for mobile platforms.
Package Information
- Name:
app-tauri-plugin-player - Version: 0.1.4
- Description: Player plugin
- License: See workspace license
Notes
- The desktop implementation currently provides stub methods that return empty responses
- The iOS implementation structure exists but is not yet fully implemented
- The JavaScript/TypeScript guest bindings (
guest-js/) are not currently included in the repository