1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use ffi;
use ::{Instance, MediaList};
pub struct MediaLibrary {
pub ptr: *mut ffi::libvlc_media_library_t,
}
impl MediaLibrary {
pub fn new(instance: &Instance) -> Option<MediaLibrary> {
unsafe{
let p = ffi::libvlc_media_library_new(instance.ptr);
if p.is_null() { None }else{ Some(MediaLibrary{ptr: p}) }
}
}
pub fn load(&self) -> Result<(), ()> {
unsafe{
if ffi::libvlc_media_library_load(self.ptr) == 0 { Ok(()) }else{ Err(()) }
}
}
pub fn media_list(&self) -> Option<MediaList> {
unsafe{
let p = ffi::libvlc_media_library_media_list(self.ptr);
if p.is_null() { None }else{ Some(MediaList{ptr: p}) }
}
}
}
impl Drop for MediaLibrary {
fn drop(&mut self) {
unsafe{ ffi::libvlc_media_library_release(self.ptr) };
}
}