Merge branch 'add-client-message-event' into 'master'
Add support for `client-message` events See merge request mpv-ipc/mpvipc!4
This commit is contained in:
commit
cea343cd3b
13
src/ipc.rs
13
src/ipc.rs
|
@ -414,6 +414,19 @@ pub fn listen(instance: &mut Mpv) -> Result<Event, Error> {
|
||||||
|
|
||||||
try_convert_property(name.as_ref(), id, data)
|
try_convert_property(name.as_ref(), id, data)
|
||||||
}
|
}
|
||||||
|
"client-message" => {
|
||||||
|
let args = match e["args"] {
|
||||||
|
Value::Array(ref a) => json_array_to_vec(a)
|
||||||
|
.iter()
|
||||||
|
.map(|arg| match arg {
|
||||||
|
MpvDataType::String(s) => Ok(s.to_owned()),
|
||||||
|
_ => Err(Error(ErrorCode::JsonContainsUnexptectedType)),
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<_>, _>>(),
|
||||||
|
_ => return Err(Error(ErrorCode::JsonContainsUnexptectedType)),
|
||||||
|
}?;
|
||||||
|
Event::ClientMessage { args }
|
||||||
|
}
|
||||||
_ => Event::Unimplemented,
|
_ => Event::Unimplemented,
|
||||||
};
|
};
|
||||||
Ok(event)
|
Ok(event)
|
||||||
|
|
|
@ -25,6 +25,7 @@ pub enum Event {
|
||||||
PlaybackRestart,
|
PlaybackRestart,
|
||||||
PropertyChange { id: usize, property: Property },
|
PropertyChange { id: usize, property: Property },
|
||||||
ChapterChange,
|
ChapterChange,
|
||||||
|
ClientMessage { args: Vec<String> },
|
||||||
Unimplemented,
|
Unimplemented,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue