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

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

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

	return nil, checkError()
}
Beispiel #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
}
Beispiel #3
0
// MediaNewPath creates a media for a certain file path.
func (vlc *VLC) MediaNewPath(path string) (*Media, error) {
	str := C.CString(path)
	defer C.free(unsafe.Pointer(str))
	media := C.libvlc_media_new_path(vlc.instance, str)
	return (*Media)(media), LastError()
}