Add methods to MediaLibrary

merge-requests/7/merge
T. Okubo 2015-11-30 23:04:45 +09:00
parent 3eab90b03e
commit b376a0de12
1 changed files with 26 additions and 0 deletions

View File

@ -3,11 +3,37 @@
// Licensed under the MIT license, see the LICENSE file.
use ffi;
use ::{Instance, MediaList};
pub struct MediaLibrary {
pub ptr: *mut ffi::libvlc_media_library_t,
}
impl MediaLibrary {
/// Create an new Media Library object.
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}) }
}
}
/// Load media library.
pub fn load(&self) -> Result<(), ()> {
unsafe{
if ffi::libvlc_media_library_load(self.ptr) == 0 { Ok(()) }else{ Err(()) }
}
}
/// Get media library subitems.
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) };