| Crates.io | music-notification |
| lib.rs | music-notification |
| version | 0.2.0 |
| created_at | 2025-11-15 03:51:28.314623+00 |
| updated_at | 2025-11-15 03:52:42.359618+00 |
| description | A Tauri plugin for music notifications |
| homepage | |
| repository | https://github.com/VMASPAD/tauri-plugin-music-notification |
| max_upload_size | |
| id | 1933985 |
| size | 297,961 |
A Tauri plugin for Android that provides music playback notifications with media controls.
Install the plugin using your preferred package manager:
npm run tauri add music-notification-api
Add the plugin to your Cargo.toml:
[dependencies]
music-notification = "0.1.0"
Register the plugin in your Tauri app:
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_music_notification::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Add the required permissions to your src-tauri/capabilities/default.json:
{
"permissions": [
"music-notification:default"
]
}
The plugin automatically includes the required Android permissions:
INTERNET - For streaming audioFOREGROUND_SERVICE - For background playbackFOREGROUND_SERVICE_MEDIA_PLAYBACK - For media playback servicePOST_NOTIFICATIONS - For displaying notificationsimport { play, pause, resume, stop, next, previous, seek, getState } from 'music-notification-api';
// Play music
await play({
url: "https://example.com/song.mp3",
title: "Song Title",
artist: "Artist Name",
album: "Album Name"
});
// Pause playback
await pause();
// Resume playback
await resume();
// Stop playback
await stop();
// Skip to next track
await next();
// Go to previous track
await previous();
// Seek to position (in milliseconds)
await seek(30000); // Seek to 30 seconds
// Get current playback state
const state = await getState();
console.log(state.isPlaying); // true/false
console.log(state.position); // Current position in ms
console.log(state.duration); // Total duration in ms
play(options: PlayOptions)Starts playing music from a URL.
Parameters:
url (string, required): The URL of the audio filetitle (string, optional): Song titleartist (string, optional): Artist namealbum (string, optional): Album nameReturns: Promise<{ success: boolean; message?: string }>
pause()Pauses the current playback.
Returns: Promise<{ success: boolean }>
resume()Resumes paused playback.
Returns: Promise<{ success: boolean }>
stop()Stops playback and clears the notification.
Returns: Promise<{ success: boolean }>
next()Skips to the next track (if available in playlist).
Returns: Promise<{ success: boolean }>
previous()Goes back to the previous track (if available in playlist).
Returns: Promise<{ success: boolean }>
seek(position: number)Seeks to a specific position in the current track.
Parameters:
position (number): Position in millisecondsReturns: Promise<{ success: boolean }>
getState()Gets the current playback state.
Returns: Promise<PlaybackState>
interface PlaybackState {
isPlaying: boolean;
position: number; // in milliseconds
duration: number; // in milliseconds
}
| Platform | Supported |
|---|---|
| Android | ✅ |
| iOS | ❌ |
| Windows | ❌ |
| macOS | ❌ |
| Linux | ❌ |
Currently, this plugin only supports Android. Desktop implementations return placeholder responses.
Check out the example app for a complete implementation.
MIT
Contributions are welcome! Please feel free to submit a Pull Request.