// New creates and initializes a new VLC instance with the given parameters. // Returns nil and a possible error if no instance could be created. func New(argv []string) (i *Instance, err error) { cstr := make([]*C.char, len(argv)) for i := range cstr { cstr[i] = C.CString(argv[i]) } if c := C.libvlc_new(C.int(len(argv)), *(***C.char)(unsafe.Pointer(&cstr))); c != nil { i = &Instance{c} } else { err = checkError() } for i := range cstr { C.free(unsafe.Pointer(cstr[i])) } return }
func Init(args ...string) error { if instance != nil { return nil } argc := len(args) argv := make([]*C.char, argc) for i, arg := range args { argv[i] = C.CString(arg) } defer func() { for i := range argv { C.free(unsafe.Pointer(argv[i])) } }() instance = C.libvlc_new(C.int(argc), *(***C.char)(unsafe.Pointer(&argv))) if instance == nil { return getError() } return nil }
// New creates a new instance of libVLC. func New() (*VLC, error) { vlc := &VLC{} vlc.instance = C.libvlc_new(0, nil) return vlc, LastError() }