Struct Media

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

Implementations§

Source§

impl Media

Source

pub fn new_location(instance: &Instance, mrl: &str) -> Option<Media>

Create a media with a certain given media resource location, for instance a valid URL.

Source

pub fn new_path<T: AsRef<Path>>(instance: &Instance, path: T) -> Option<Media>

Create a media for a certain file path.

Examples found in repository?
examples/cli_player.rs (line 23)
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 new_fd(instance: &Instance, fd: i32) -> Option<Media>

Source

pub fn mrl(&self) -> Option<String>

Source

pub fn event_manager<'a>(&'a self) -> EventManager<'a>

Examples found in repository?
examples/cli_player.rs (line 28)
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 get_meta(&self, meta: Meta) -> Option<String>

Read the meta of the media. If the media has not yet been parsed this will return None.

Source

pub fn set_meta(&self, meta: Meta, value: &str)

Set the meta of the media. (This function will not save the meta, call save_meta in order to save the meta)

Source

pub fn save_meta(&self) -> bool

Save the meta previously set.

Source

pub fn state(&self) -> State

Get current state of media descriptor object.

Source

pub fn duration(&self) -> Option<i64>

Get duration (in ms) of media descriptor object item.

Source

pub fn parse(&self)

Parse a media.

Source

pub fn parse_async(&self)

Parse a media.

Source

pub fn is_parsed(&self) -> bool

Get Parsed status for media descriptor object.

Source

pub fn tracks(&self) -> Option<Vec<MediaTrack>>

Source

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

Returns raw pointer

Trait Implementations§

Source§

impl Drop for Media

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Media

§

impl RefUnwindSafe for Media

§

impl !Send for Media

§

impl !Sync for Media

§

impl Unpin for Media

§

impl UnwindSafe for Media

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.