Included observation ID in PropertyChange event

This commit is contained in:
Jonas Frei 2019-06-20 05:58:31 +02:00
parent d5ecc48b1d
commit b8590c2ae3
3 changed files with 3 additions and 6 deletions

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,
}, },
} }