Included observation ID in PropertyChange event

This commit is contained in:
Jonas Frei 2019-06-20 05:58:31 +02:00
parent d5ecc48b1d
commit 5b28c95a0a
4 changed files with 4 additions and 7 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "mpvipc" name = "mpvipc"
version = "1.1.6" version = "1.1.7"
authors = ["Jonas Frei <freijon@pm.me>"] authors = ["Jonas Frei <freijon@pm.me>"]
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"

View File

@ -26,7 +26,7 @@ fn main() -> Result<(), Error> {
loop { loop {
let event = mpv.event_listen()?; let event = mpv.event_listen()?;
match event { match event {
Event::PropertyChange(property) => match property { Event::PropertyChange(_, property) => match property {
Property::Path(Some(value)) => println!("\nPlaying: {}", value), Property::Path(Some(value)) => println!("\nPlaying: {}", value),
Property::Path(None) => (), Property::Path(None) => (),
Property::Pause(value) => pause = value, Property::Pause(value) => pause = value,
@ -52,7 +52,6 @@ fn main() -> Result<(), Error> {
Property::Metadata(None) => (), Property::Metadata(None) => (),
Property::Unknown { Property::Unknown {
name: _, name: _,
id: _,
data: _, data: _,
} => (), } => (),
}, },

View File

@ -308,12 +308,11 @@ fn try_convert_property(name: &str, id: isize, data: MpvDataType) -> Event {
warn!("Property {} not implemented", name); warn!("Property {} not implemented", name);
Property::Unknown { Property::Unknown {
name: name.to_string(), name: name.to_string(),
id,
data, data,
} }
} }
}; };
Event::PropertyChange(property) Event::PropertyChange(id, property)
} }
pub fn listen(instance: &mut Mpv) -> Result<Event, Error> { pub fn listen(instance: &mut Mpv) -> Result<Event, Error> {

View File

@ -36,7 +36,7 @@ pub enum Event {
MetadataUpdate, MetadataUpdate,
Seek, Seek,
PlaybackRestart, PlaybackRestart,
PropertyChange(Property), PropertyChange(isize, Property),
ChapterChange, ChapterChange,
Unimplemented, Unimplemented,
} }
@ -50,7 +50,6 @@ pub enum Property {
Metadata(Option<HashMap<String, MpvDataType>>), Metadata(Option<HashMap<String, MpvDataType>>),
Unknown { Unknown {
name: String, name: String,
id: isize,
data: MpvDataType, data: MpvDataType,
}, },
} }