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