forked from henrym/go-vlc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
library.go
58 lines (48 loc) · 1.24 KB
/
library.go
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
// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// license. Its contents can be found at:
// http://creativecommons.org/publicdomain/zero/1.0
package vlc
//#include <stdlib.h>
//#include <vlc/vlc.h>
import "C"
import (
"syscall"
)
// A media library
type Library struct {
ptr *C.libvlc_media_library_t
}
// Retain increments the reference count of the instance.
func (this *Library) Retain() (err error) {
if this.ptr == nil {
return syscall.EINVAL
}
C.libvlc_media_library_retain(this.ptr)
return
}
// Release decreases the reference count of the instance and destroys it when it reaches zero.
func (this *Library) Release() (err error) {
if this.ptr == nil {
return syscall.EINVAL
}
C.libvlc_media_library_release(this.ptr)
return
}
// Load loads the library contents.
func (this *Library) Load() error {
if this.ptr == nil {
return syscall.EINVAL
}
C.libvlc_media_library_load(this.ptr)
return checkError()
}
// Items returns a list of all the media items in this library.
func (this *Library) Items() (*MediaList, error) {
if this.ptr == nil {
return nil, syscall.EINVAL
}
if c := C.libvlc_media_library_media_list(this.ptr); c != nil {
return &MediaList{c}, nil
}
return nil, checkError()
}