2024-12-12 11:04:33 +01:00
|
|
|
[![Coverage](https://pages.pvv.ntnu.no/Projects/mpvipc-async/master/coverage/badges/for_the_badge.svg)](https://pages.pvv.ntnu.no/Projects/mpvipc-async/master/coverage/src/)
|
|
|
|
[![Docs](https://img.shields.io/badge/docs-blue?style=for-the-badge&logo=rust)](https://pages.pvv.ntnu.no/Projects/mpvipc-async/master/docs/mpvipc-async/)
|
2024-04-30 17:39:33 +02:00
|
|
|
|
2024-12-12 11:04:33 +01:00
|
|
|
# mpvipc-async
|
2017-05-29 17:54:12 +02:00
|
|
|
|
|
|
|
A small library which provides bindings to control existing mpv instances through sockets.
|
|
|
|
|
|
|
|
## Dependencies
|
|
|
|
|
|
|
|
- `mpv`
|
2024-05-04 00:06:43 +02:00
|
|
|
- `cargo` (make dependency)
|
|
|
|
- `cargo-nextest` (test depencency)
|
|
|
|
- `grcov` (test depencency)
|
2017-05-29 17:54:12 +02:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
Make sure mpv is started with the following option:
|
2024-05-04 00:06:43 +02:00
|
|
|
|
|
|
|
```bash
|
2022-07-10 15:34:14 +02:00
|
|
|
$ mpv --input-ipc-server=/tmp/mpv.sock --idle
|
2024-05-04 00:06:43 +02:00
|
|
|
```
|
2017-05-29 17:54:12 +02:00
|
|
|
|
2024-05-04 00:06:43 +02:00
|
|
|
Here is a small code example which connects to the socket `/tmp/mpv.sock` and toggles playback.
|
2017-05-29 17:54:12 +02:00
|
|
|
|
2022-07-10 15:34:14 +02:00
|
|
|
```rust
|
2017-05-29 17:54:12 +02:00
|
|
|
use mpvipc::*;
|
|
|
|
|
2024-05-04 00:06:43 +02:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<(), MpvError> {
|
|
|
|
let mpv = Mpv::connect("/tmp/mpv.sock").await?;
|
|
|
|
let paused: bool = mpv.get_property("pause").await?;
|
2017-05-29 17:54:12 +02:00
|
|
|
mpv.set_property("pause", !paused).expect("Error pausing");
|
|
|
|
}
|
2024-05-04 00:06:43 +02:00
|
|
|
```
|