Example #1
0
// OpenMediaUri loads a media instance from the given uri.
func (this *Instance) OpenMediaUri(uri string) (*Media, error) {
	if this.ptr == nil {
		return nil, os.EINVAL
	}

	c := C.CString(uri)
	defer C.free(unsafe.Pointer(c))

	if m := C.libvlc_media_new_location(this.ptr, c); m != nil {
		return &Media{m}, nil
	}

	return nil, checkError()
}
Example #2
0
func newMedia(path string, local bool) (*Media, error) {
	if instance == nil {
		return nil, errors.New("Module must be first initialized")
	}

	cPath := C.CString(path)
	defer C.free(unsafe.Pointer(cPath))

	var media *C.libvlc_media_t = nil
	if local {
		media = C.libvlc_media_new_path(instance, cPath)
	} else {
		media = C.libvlc_media_new_location(instance, cPath)
	}

	if media == nil {
		return nil, getError()
	}

	return &Media{media: media}, nil
}