Skip to content

Commit

Permalink
add player usage in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaDve committed Sep 10, 2023
1 parent 9fae8ac commit d405597
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ Create MPRIS MediaPlayer2 server

To implement a server, this crate provides two flavors: you can either create a custom struct that implements `RootInterface` and `PlayerInterface`, or you can use the premade mutable `Player` struct that already implements the interfaces internally.

## Player Usage

```rust
#[async_std::main]
async fn main() {
let player = Player::builder("com.me.Application")
.can_play(true)
.can_pause(true)
.build()
.unwrap();

player.connect_play_pause(|| {
println!("PlayPause");
});

player.run().await.unwrap();
}
```

## Supported Interfaces

This library supports all interfaces defined in the [MPRIS2 specification](https://specifications.freedesktop.org/mpris-spec/2.2/index.html). However, the premade `Player` struct currently only supports the more commonly used `org.mpris.MediaPlayer2` and `org.mpris.MediaPlayer2.Player` interfaces.
Expand All @@ -25,7 +44,7 @@ impl PlayerInterface for MyPlayer {

#[async_std::main]
async fn main() {
let server = Server::new("Test.Application", MyPlayer).unwrap();
let server = Server::new("com.me.Application", MyPlayer).unwrap();
server.run().await.unwrap();
}
```
Expand All @@ -52,7 +71,7 @@ impl TracklistInterface for MyPlayer {

#[async_std::main]
async fn main() {
let server = Server::new("Test.Application", Player).unwrap();
let server = Server::new("com.me.Application", Player).unwrap();
server.run_with_track_list().await.unwrap();
}
```
Expand All @@ -79,7 +98,7 @@ impl PlaylistsInterface for MyPlayer {

#[async_std::main]
async fn main() {
let server = Server::new("Test.Application", Player).unwrap();
let server = Server::new("com.me.Application", Player).unwrap();
server.run_with_playlists().await.unwrap();
}
```
Expand Down Expand Up @@ -112,7 +131,7 @@ impl TracklistInterface for MyPlayer {

#[async_std::main]
async fn main() {
let server = Server::new("Test.Application", Player).unwrap();
let server = Server::new("com.me.Application", Player).unwrap();
server.run_with_all().await.unwrap();
}
```
Expand Down

0 comments on commit d405597

Please sign in to comment.