Expand description
MPRIS media player control via D-Bus.
§Quick Start
use wayle_media::MediaService;
let media = MediaService::new().await?;
// Get active player
if let Some(player) = media.active_player.get() {
println!("{}: {:?}", player.identity.get(), player.playback_state.get());
println!("Track: {}", player.metadata.title.get());
}§Watching for Changes
use wayle_media::MediaService;
use futures::StreamExt;
// React to player list changes
let mut stream = media.player_list.watch();
while let Some(players) = stream.next().await {
println!("{} players available", players.len());
}§Playback Control
if let Some(player) = media.active_player.get() {
player.play_pause().await?;
player.next().await?;
player.set_volume(0.5.into()).await?;
}§Configuration
| Method | Effect |
|---|---|
with_daemon() | Control playback from scripts or other processes |
with_art_cache() | Download and cache HTTP album art to disk |
ignore_player(pattern) | Skip players matching the pattern |
position_poll_interval(dur) | How often to refresh playback position (default: 1s) |
use wayle_media::MediaService;
let media = MediaService::builder()
.with_daemon()
.with_art_cache()
.ignore_player("chromium".to_string())
.ignore_player("firefox".to_string())
.build()
.await?;§D-Bus Interface
When with_daemon() is enabled, the service registers on the session bus.
- Service:
com.wayle.Media1 - Path:
/com/wayle/Media - Interface:
com.wayle.Media1
See dbus.md for the full interface specification.
§Reactive Properties
All fields are Property<T>:
.get()- Current value snapshot.watch()- Stream yielding on changes
§Service Fields
| Field | Type | Description |
|---|---|---|
player_list | Vec<Arc<Player>> | All MPRIS players |
active_player | Option<Arc<Player>> | Selected player for control |
§Control Methods
On Player:
play_pause(),next(),previous()- Playbackseek(),set_position()- Positionset_volume(),set_loop_mode(),set_shuffle_mode()- Settings
Modules§
- core
- Core media domain models
- types
- Type definitions for media service configuration, states, and identifiers
Structs§
- Media
Proxy - D-Bus client proxy for controlling the media service.
- Media
Service - MPRIS media player service. See crate-level docs for usage patterns.
- Media
Service Builder - Builder for configuring and creating a MediaService instance.
Enums§
- Error
- Errors that can occur during media operations
Constants§
- SERVICE_
NAME - D-Bus service name.
- SERVICE_
PATH - D-Bus object path.