pub struct Media { /* private fields */ }
Implementations§
Source§impl Media
impl Media
Sourcepub fn new_location(instance: &Instance, mrl: &str) -> Option<Media>
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.
Sourcepub fn new_path<T: AsRef<Path>>(instance: &Instance, path: T) -> Option<Media>
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}
pub fn new_fd(instance: &Instance, fd: i32) -> Option<Media>
pub fn mrl(&self) -> Option<String>
Sourcepub fn event_manager<'a>(&'a self) -> EventManager<'a>
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}
Sourcepub fn get_meta(&self, meta: Meta) -> Option<String>
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.
Sourcepub fn set_meta(&self, meta: Meta, value: &str)
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)
Sourcepub fn parse_async(&self)
pub fn parse_async(&self)
Parse a media.
pub fn tracks(&self) -> Option<Vec<MediaTrack>>
Sourcepub fn raw(&self) -> *mut libvlc_media_t
pub fn raw(&self) -> *mut libvlc_media_t
Returns raw pointer
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more