Compare commits
4 Commits
test-highl
...
main
Author | SHA1 | Date | |
---|---|---|---|
a6c6bf4388 | |||
5a74dd0b02 | |||
ee5aa30335 | |||
e3297bef15 |
@ -7,8 +7,8 @@ authors = [
|
|||||||
]
|
]
|
||||||
description = "A small library which provides bindings to control existing mpv instances through sockets."
|
description = "A small library which provides bindings to control existing mpv instances through sockets."
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
repository = "https://git.pvv.ntnu.no/Projects/mpvipc-async"
|
repository = "https://git.pvv.ntnu.no/Grzegorz/mpvipc-async"
|
||||||
documentation = "https://pages.pvv.ntnu.no/Projects/mpvipc-async/main/docs/mpvipc_async/"
|
documentation = "https://pages.pvv.ntnu.no/Grzegorz/mpvipc-async/main/docs/mpvipc_async/"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.75"
|
rust-version = "1.75"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[![Coverage](https://pages.pvv.ntnu.no/Projects/mpvipc-async/main/coverage/badges/for_the_badge.svg)](https://pages.pvv.ntnu.no/Projects/mpvipc-async/main/coverage/src/)
|
[![Coverage](https://pages.pvv.ntnu.no/Grzegorz/mpvipc-async/main/coverage/badges/for_the_badge.svg)](https://pages.pvv.ntnu.no/Grzegorz/mpvipc-async/main/coverage/src/)
|
||||||
[![Docs](https://img.shields.io/badge/docs-blue?style=for-the-badge&logo=rust)](https://pages.pvv.ntnu.no/Projects/mpvipc-async/main/docs/mpvipc_async/)
|
[![Docs](https://img.shields.io/badge/docs-blue?style=for-the-badge&logo=rust)](https://pages.pvv.ntnu.no/Grzegorz/mpvipc-async/main/docs/mpvipc_async/)
|
||||||
|
|
||||||
# mpvipc-async
|
# mpvipc-async
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ pub(crate) trait IntoRawCommandPart {
|
|||||||
|
|
||||||
/// Generic data type representing all possible data types that mpv can return.
|
/// Generic data type representing all possible data types that mpv can return.
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
pub enum MpvDataType {
|
pub enum MpvDataType {
|
||||||
Array(Vec<MpvDataType>),
|
Array(Vec<MpvDataType>),
|
||||||
Bool(bool),
|
Bool(bool),
|
||||||
|
@ -109,7 +109,7 @@ pub enum Event {
|
|||||||
VideoReconfig,
|
VideoReconfig,
|
||||||
AudioReconfig,
|
AudioReconfig,
|
||||||
PropertyChange {
|
PropertyChange {
|
||||||
id: u64,
|
id: Option<u64>,
|
||||||
name: String,
|
name: String,
|
||||||
data: Option<MpvDataType>,
|
data: Option<MpvDataType>,
|
||||||
},
|
},
|
||||||
@ -296,7 +296,7 @@ fn parse_client_message(event: &Map<String, Value>) -> Result<Event, MpvError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn parse_property_change(event: &Map<String, Value>) -> Result<Event, MpvError> {
|
fn parse_property_change(event: &Map<String, Value>) -> Result<Event, MpvError> {
|
||||||
let id = get_key_as!(as_u64, "id", event);
|
let id = get_optional_key_as!(as_u64, "id", event);
|
||||||
let property_name = get_key_as!(as_str, "name", event);
|
let property_name = get_key_as!(as_str, "name", event);
|
||||||
let data = event.get("data").map(json_to_value).transpose()?;
|
let data = event.get("data").map(json_to_value).transpose()?;
|
||||||
|
|
||||||
|
@ -323,9 +323,9 @@ impl MpvExt for Mpv {
|
|||||||
Switch::Off => "yes",
|
Switch::Off => "yes",
|
||||||
Switch::Toggle => {
|
Switch::Toggle => {
|
||||||
if self.is_playing().await? {
|
if self.is_playing().await? {
|
||||||
"no"
|
|
||||||
} else {
|
|
||||||
"yes"
|
"yes"
|
||||||
|
} else {
|
||||||
|
"no"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
BIN
test_assets/black-background-30s-480p.mp4
Normal file
BIN
test_assets/black-background-30s-480p.mp4
Normal file
Binary file not shown.
@ -43,7 +43,7 @@ where
|
|||||||
match event {
|
match event {
|
||||||
Some(Ok(event)) => {
|
Some(Ok(event)) => {
|
||||||
match event {
|
match event {
|
||||||
Event::PropertyChange { id: MPV_CHANNEL_ID, name, data } => {
|
Event::PropertyChange { id: Some(MPV_CHANNEL_ID), name, data } => {
|
||||||
let property = parse_property(&name, data).unwrap();
|
let property = parse_property(&name, data).unwrap();
|
||||||
if !on_property(property.clone()) {
|
if !on_property(property.clone()) {
|
||||||
return Err(PropertyCheckingThreadError::UnexpectedPropertyError(property))
|
return Err(PropertyCheckingThreadError::UnexpectedPropertyError(property))
|
||||||
|
@ -52,7 +52,7 @@ async fn test_observe_event_successful() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
event,
|
event,
|
||||||
Event::PropertyChange {
|
Event::PropertyChange {
|
||||||
id: 1,
|
id: Some(1),
|
||||||
name: "volume".to_string(),
|
name: "volume".to_string(),
|
||||||
data: Some(MpvDataType::Double(64.0))
|
data: Some(MpvDataType::Double(64.0))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user