From b376a0de12aa11e4be3af2dc24f2ff33538ba7b4 Mon Sep 17 00:00:00 2001 From: "T. Okubo" Date: Mon, 30 Nov 2015 23:04:45 +0900 Subject: [PATCH] Add methods to MediaLibrary --- src/media_library.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/media_library.rs b/src/media_library.rs index 563587b..ef8f5bc 100644 --- a/src/media_library.rs +++ b/src/media_library.rs @@ -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 { + 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 { + 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) };