Crates.io Docs CI

DISCLAIMER: the project is still in an early state. All parts may be subject to change.

Souvlaki

A cross-platform library for handling OS media controls and metadata. One abstraction for Linux, MacOS and Windows.

Supported platforms

Windows

MacOS

Screenshots coming soon.

Linux

Coming soon.

Example

The main struct is MediaControls. In order to create this struct you need a PlatformConfig. This struct contains all of the platform-specific requirements for spawning media controls. Here are the differences between the platforms:

A full cross-platform app would look like this:

```rust use souvlaki::{MediaControlEvent, MediaControls, MediaMetadata, PlatformConfig};

fn main() { #[cfg(not(target_os = "windows"))] let hwnd = None;

#[cfg(target_os = "windows")]
let hwnd = {
    use raw_window_handle::windows::WindowsHandle;

    let handle: WindowsHandle = unimplemented!();
    Some(handle.hwnd)
};

let config = PlatformConfig {
    dbus_name: "my_player",
    display_name: "My Player",
    hwnd,
};

let mut controls = MediaControls::new(config);

// The closure must be Send and have a static lifetime.
controls
    .attach(|event: MediaControlEvent| println!("Event received: {:?}", event))
    .unwrap();

// Update the media metadata.
controls
    .set_metadata(MediaMetadata {
        title: Some("Souvlaki Space Station"),
        artist: Some("Slowdive"),
        album: Some("Souvlaki"),
        ..Default::default()
    })
    .unwrap();

// Your actual logic goes here.
loop {
    std::thread::sleep(std::time::Duration::from_secs(1));
}

// The controls automatically detach on drop.

} ```

Check out this example here.

Thanks 💗