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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
use ffi;
use ::{Instance, Media, EventManager};
pub struct MediaList {
pub ptr: *mut ffi::libvlc_media_list_t,
}
impl MediaList {
pub fn new(instance: &Instance) -> Option<MediaList> {
unsafe{
let p = ffi::libvlc_media_list_new(instance.ptr);
if p.is_null() { None }else{ Some(MediaList{ptr: p}) }
}
}
pub fn set_media(&self, md: &Media) {
unsafe{ ffi::libvlc_media_list_set_media(self.ptr, md.ptr); }
}
pub fn media(&self) -> Option<Media> {
unsafe{
let p = ffi::libvlc_media_list_media(self.ptr);
if p.is_null() { None }else{ Some(Media{ptr: p}) }
}
}
pub fn add_media(&self, md: &Media) -> Result<(), ()> {
unsafe{
if ffi::libvlc_media_list_add_media(self.ptr, md.ptr) == 0 { Ok(()) }else{ Err(()) }
}
}
pub fn insert_media(&self, md: &Media, pos: i32) -> Result<(), ()> {
unsafe{
if ffi::libvlc_media_list_insert_media(self.ptr, md.ptr, pos) == 0 { Ok(()) }else{ Err(()) }
}
}
pub fn remove_index(&self, pos: i32) -> Result<(), ()> {
unsafe{
if ffi::libvlc_media_list_remove_index(self.ptr, pos) == 0 { Ok(()) }else{ Err(()) }
}
}
pub fn count(&self) -> i32 {
unsafe{ ffi::libvlc_media_list_count(self.ptr) }
}
pub fn item_at_index(&self, pos: i32) -> Option<Media> {
unsafe{
let p = ffi::libvlc_media_list_item_at_index(self.ptr, pos);
if p.is_null() { None }else{ Some(Media{ptr: p}) }
}
}
pub fn index_of_item(&self, md: &Media) -> Option<i32> {
unsafe{
let i = ffi::libvlc_media_list_index_of_item(self.ptr, md.ptr);
if i == -1 { None }else{ Some(i) }
}
}
pub fn is_readonly(&self) -> bool {
unsafe{ if ffi::libvlc_media_list_is_readonly(self.ptr) == 0 { false }else{ true } }
}
pub fn lock(&self) {
unsafe{ ffi::libvlc_media_list_lock(self.ptr); }
}
pub fn unlock(&self) {
unsafe{ ffi::libvlc_media_list_unlock(self.ptr); }
}
pub fn event_manager<'a>(&'a self) -> EventManager<'a> {
unsafe{
let p = ffi::libvlc_media_list_event_manager(self.ptr);
assert!(!p.is_null());
EventManager{ptr: p, _phantomdata: ::std::marker::PhantomData}
}
}
}
impl Drop for MediaList {
fn drop(&mut self) {
unsafe{ ffi::libvlc_media_list_release(self.ptr) };
}
}