Struct EventManager

Source
pub struct EventManager<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> EventManager<'a>

Source

pub fn attach<F>(&self, event_type: EventType, callback: F) -> Result<(), ()>
where F: Fn(Event, VLCObject) + Send + 'static,

Examples found in repository?
examples/cli_player.rs (lines 29-39)
11fn main() {
12    let args: Vec<String> = std::env::args().collect();
13
14    let path = match args.get(1) {
15        Some(s) => s,
16        None => {
17            println!("Usage: cli_audio_player path_to_a_media_file");
18            return;
19        }
20    };
21    let instance = Instance::new().unwrap();
22    
23    let md = Media::new_path(&instance, path).unwrap();    
24    let mdp = MediaPlayer::new(&instance).unwrap();
25    
26    let (tx, rx) = channel::<()>();
27    
28    let em = md.event_manager();
29    let _ = em.attach(EventType::MediaStateChanged, move |e, _| {
30        match e {
31            Event::MediaStateChanged(s) => {
32                println!("State : {:?}", s);
33                if s == State::Ended || s == State::Error {
34                    tx.send(()).unwrap();
35                }
36            },
37            _ => (),
38        }
39    });
40    
41    mdp.set_media(&md);
42    
43    // Start playing
44    mdp.play().unwrap();
45    
46    // Wait for end state
47    rx.recv().unwrap();    
48}
Source

pub fn raw(&self) -> *mut libvlc_event_manager_t

Returns raw pointer

Auto Trait Implementations§

§

impl<'a> Freeze for EventManager<'a>

§

impl<'a> RefUnwindSafe for EventManager<'a>

§

impl<'a> !Send for EventManager<'a>

§

impl<'a> !Sync for EventManager<'a>

§

impl<'a> Unpin for EventManager<'a>

§

impl<'a> UnwindSafe for EventManager<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.