Struct Instance

Source
pub struct Instance { /* private fields */ }

Implementations§

Source§

impl Instance

Source

pub fn new() -> Option<Instance>

Create and initialize a libvlc instance.

Examples found in repository?
examples/cli_player.rs (line 21)
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 add_intf(&self, name: &str) -> Result<(), ()>

Try to start a user interface for the libvlc instance.

Source

pub fn set_user_agent(&self, name: &str, http: &str)

Sets the application name. LibVLC passes this as the user agent string when a protocol requires it.

Source

pub fn wait(&self)

Waits until an interface causes the instance to exit.

Source

pub fn set_app_id(&self, id: &str, version: &str, icon: &str)

Sets some meta-information about the application.

Source

pub fn audio_filter_list_get(&self) -> Option<ModuleDescriptionList>

Returns a list of audio filters that are available.

Source

pub fn video_filter_list_get(&self) -> Option<ModuleDescriptionList>

Returns a list of video filters that are available.

Source

pub fn set_log<F: Fn(LogLevel, Log, Cow<'_, str>) + Send + 'static>(&self, f: F)

Set logging callback

Source

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

Returns raw pointer

Trait Implementations§

Source§

impl Drop for Instance

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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.