示例#1
0
func main() {
	fmt.Printf(C.GoString(C.libvlc_get_version()) + "\n")

	var err error
	var inst *Instance
	var media *Media
	var player *Player

	args := []string{"-vvv", "--plugin-path=/Users/min/Applications/VLC3.0.0.app/Contents/MacOS/plugins"}
	if inst, err = New(args); err != nil {
		fmt.Fprintf(os.Stderr, "[e] New(): %v", err)
		return
	} else {
		fmt.Printf("Create vlc instance success.\n")
	}
	if inst == nil {
		fmt.Printf("vlc instance is null\n")
	}

	defer inst.Release()

	if media, err = inst.OpenMediaUri(uri); err != nil {
		fmt.Fprintf(os.Stderr, "[e] OpenMediaUri(): %v", err)
		return
	} else {
		fmt.Printf("Create vlc media location success")
	}

	// Create a player for the created media.
	if player, err = media.NewPlayer(); err != nil {
		fmt.Fprintf(os.Stderr, "[e] NewPlayer(): %v", err)
		media.Release()
		return
	}

	defer player.Release()

	media.Release()
	media = nil

	if player != nil {
		fmt.Print("Success!!\n")
	}

	// Play the video.
	player.Play()

	// Give the player 10 seconds of play time.
	time.Sleep(1e10)

	// Stop playing.
	player.Stop()
	//_, err = inst.OpenMediaUri("file:///Users/min/Downloads/dance.MOV")
	//if err != nil {
	//    fmt.Print(err)
	//    return
	//}

	//cstr := make([]*C.char, 1)
	//cstr[0] = C.CString("-vvv")

	//inst := C.libvlc_new(C.int(1), *(***C.char)(unsafe.Pointer(&cstr)))
	//if inst == nil {
	//    fmt.Printf("Create vlc instance failed.\n")
	//    return
	//}
	//media := C.libvlc_media_new_path(inst, C.CString("/Users/min/Downloads/dance.MOV"))
	//player := C.libvlc_media_player_new_from_media(media)
	//C.libvlc_media_release(media)
	//C.libvlc_media_player_play(player)
	//return
}
示例#2
0
文件: vlc.go 项目: egelmex/go-vlc
// Version returns the libVLC version as a human-readable string.
func VersionString() string { return C.GoString(C.libvlc_get_version()) }