func (p *Player) AudioTrackCount() (int, error) {
	if err := p.assertInit(); err != nil {
		return 0, err
	}
	count := int(C.libvlc_audio_get_track_count(p.player))
	if count < 0 {
		return 0, errOrDefault(getError(), ErrMediaNotInitialized)
	}
	return count, nil
}
AudioTrackCount returns the number of audio tracks available
in the current media of the player.
package vlc
import "C"
import (
	"io"
	"time"
	"unsafe"
)
type PlayerRole uint
const (
	PlayerRoleNone PlayerRole = iota
	PlayerRoleMusic
	PlayerRoleVideo
	PlayerRoleCommunication
	PlayerRoleGame
	PlayerRoleNotification
	PlayerRoleAnimation
	PlayerRoleProduction
	PlayerRoleAccessibility
	PlayerRoleTest
)
type TitleFlag uint
const (
	TitleFlagMenu TitleFlag = iota + 0x01
	TitleFlagInteractive
)
type TitleInfo struct {
	Name     string         
	Duration time.Duration  
	Flags    TitleFlag      
}
type ChapterInfo struct {
	Name     string         
	Duration time.Duration  
	Offset   time.Duration  
}
type NavigationAction uint
const (
	NavigationActionActivate NavigationAction = iota
	NavigationActionUp
	NavigationActionDown
	NavigationActionLeft
	NavigationActionRight
	NavigationActionPopup
)
type Player struct {
	player *C.libvlc_media_player_t
}
func NewPlayer() (*Player, error) {
	if err := inst.assertInit(); err != nil {
		return nil, err
	}
	player := C.libvlc_media_player_new(inst.handle)
	if player == nil {
		return nil, errOrDefault(getError(), ErrPlayerCreate)
	}
	return &Player{player: player}, nil
}
func (p *Player) Release() error {
	if err := p.assertInit(); err != nil {
		return nil
	}
	C.libvlc_media_player_release(p.player)
	p.player = nil
	return getError()
}
func (p *Player) Play() error {
	if err := p.assertInit(); err != nil {
		return err
	}
	if p.IsPlaying() {
		return nil
	}
	if C.libvlc_media_player_play(p.player) < 0 {
		return getError()
	}
	return nil
}
func (p *Player) IsPlaying() bool {
	if err := p.assertInit(); err != nil {
		return false
	}
	return C.libvlc_media_player_is_playing(p.player) != 0
}
func (p *Player) WillPlay() bool {
	if err := p.assertInit(); err != nil {
		return false
	}
	return C.libvlc_media_player_will_play(p.player) != 0
}
func (p *Player) Stop() error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_media_player_stop(p.player)
	return getError()
}
func (p *Player) SetPause(pause bool) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_media_player_set_pause(p.player, C.int(boolToInt(pause)))
	return getError()
}
func (p *Player) TogglePause() error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_media_player_pause(p.player)
	return getError()
}
func (p *Player) CanPause() bool {
	if err := p.assertInit(); err != nil {
		return false
	}
	return C.libvlc_media_player_can_pause(p.player) != 0
}
func (p *Player) IsSeekable() bool {
	if err := p.assertInit(); err != nil {
		return false
	}
	return C.libvlc_media_player_is_seekable(p.player) != 0
}
func (p *Player) VideoOutputCount() int {
	if err := p.assertInit(); err != nil {
		return 0
	}
	return int(C.libvlc_media_player_has_vout(p.player))
}
func (p *Player) IsScrambled() bool {
	if err := p.assertInit(); err != nil {
		return false
	}
	return C.libvlc_media_player_program_scrambled(p.player) != 0
}
func (p *Player) PlaybackRate() float32 {
	if err := p.assertInit(); err != nil {
		return 0
	}
	return float32(C.libvlc_media_player_get_rate(p.player))
}
func (p *Player) SetPlaybackRate(rate float32) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_media_player_set_rate(p.player, C.float(rate))
	return getError()
}
func (p *Player) SetFullScreen(fullscreen bool) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_set_fullscreen(p.player, C.int(boolToInt(fullscreen)))
	return getError()
}
func (p *Player) ToggleFullScreen() error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_toggle_fullscreen(p.player)
	return getError()
}
func (p *Player) IsFullScreen() (bool, error) {
	if err := p.assertInit(); err != nil {
		return false, err
	}
	return C.libvlc_get_fullscreen(p.player) != C.int(0), getError()
}
func (p *Player) Volume() (int, error) {
	if err := p.assertInit(); err != nil {
		return 0, err
	}
	return int(C.libvlc_audio_get_volume(p.player)), getError()
}
func (p *Player) SetVolume(volume int) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_audio_set_volume(p.player, C.int(volume))
	return getError()
}
func (p *Player) IsMuted() (bool, error) {
	if err := p.assertInit(); err != nil {
		return false, err
	}
	return C.libvlc_audio_get_mute(p.player) > C.int(0), getError()
}
func (p *Player) SetMute(mute bool) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_audio_set_mute(p.player, C.int(boolToInt(mute)))
	return getError()
}
func (p *Player) ToggleMute() error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_audio_toggle_mute(p.player)
	return getError()
}
func (p *Player) Media() (*Media, error) {
	if err := p.assertInit(); err != nil {
		return nil, err
	}
	media := C.libvlc_media_player_get_media(p.player)
	if media == nil {
		return nil, nil
	}
	C.libvlc_media_release(media)
	return &Media{media}, nil
}
func (p *Player) SetMedia(m *Media) error {
	return p.setMedia(m)
}
func (p *Player) LoadMediaFromPath(path string) (*Media, error) {
	return p.loadMedia(path, true)
}
func (p *Player) LoadMediaFromURL(url string) (*Media, error) {
	return p.loadMedia(url, false)
}
func (p *Player) LoadMediaFromReadSeeker(r io.ReadSeeker) (*Media, error) {
	m, err := NewMediaFromReadSeeker(r)
	if err != nil {
		return nil, err
	}
	if err = p.setMedia(m); err != nil {
		m.release()
		return nil, err
	}
	return m, nil
}
func (p *Player) SetAudioOutput(output string) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	cOutput := C.CString(output)
	defer C.free(unsafe.Pointer(cOutput))
	if C.libvlc_audio_output_set(p.player, cOutput) != 0 {
		return errOrDefault(getError(), ErrAudioOutputSet)
	}
	return nil
}
func (p *Player) AudioOutputDevices() ([]*AudioOutputDevice, error) {
	if err := p.assertInit(); err != nil {
		return nil, err
	}
	return parseAudioOutputDeviceList(C.libvlc_audio_output_device_enum(p.player))
}
func (p *Player) AudioOutputDevice() (string, error) {
	if err := p.assertInit(); err != nil {
		return "", err
	}
	cName := C.libvlc_audio_output_device_get(p.player)
	if cName == nil {
		return "", ErrAudioOutputDeviceMissing
	}
	defer C.free(unsafe.Pointer(cName))
	return C.GoString(cName), nil
}
func (p *Player) SetAudioOutputDevice(device, output string) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	var cOutput *C.char
	if output != "" {
		cOutput = C.CString(output)
		defer C.free(unsafe.Pointer(cOutput))
	}
	cDevice := C.CString(device)
	defer C.free(unsafe.Pointer(cDevice))
	C.libvlc_audio_output_device_set(p.player, cOutput, cDevice)
	return getError()
}
func (p *Player) StereoMode() (StereoMode, error) {
	if err := p.assertInit(); err != nil {
		return StereoModeError, err
	}
	return StereoMode(C.libvlc_audio_get_channel(p.player)), getError()
}
func (p *Player) SetStereoMode(mode StereoMode) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	if C.libvlc_audio_set_channel(p.player, C.int(mode)) != 0 {
		return errOrDefault(getError(), ErrStereoModeSet)
	}
	return nil
}
func (p *Player) MediaLength() (int, error) {
	if err := p.assertInit(); err != nil {
		return 0, err
	}
	return int(C.libvlc_media_player_get_length(p.player)), getError()
}
func (p *Player) MediaState() (MediaState, error) {
	if err := p.assertInit(); err != nil {
		return 0, err
	}
	state := int(C.libvlc_media_player_get_state(p.player))
	return MediaState(state), getError()
}
func (p *Player) MediaPosition() (float32, error) {
	if err := p.assertInit(); err != nil {
		return 0, err
	}
	return float32(C.libvlc_media_player_get_position(p.player)), getError()
}
func (p *Player) SetMediaPosition(pos float32) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_media_player_set_position(p.player, C.float(pos))
	return getError()
}
func (p *Player) MediaTime() (int, error) {
	if err := p.assertInit(); err != nil {
		return 0, err
	}
	return int(C.libvlc_media_player_get_time(p.player)), getError()
}
func (p *Player) SetMediaTime(t int) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_media_player_set_time(p.player, C.libvlc_time_t(int64(t)))
	return getError()
}
func (p *Player) NextFrame() error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_media_player_next_frame(p.player)
	return getError()
}
func (p *Player) Scale() (float64, error) {
	if err := p.assertInit(); err != nil {
		return 0, err
	}
	return float64(C.libvlc_video_get_scale(p.player)), getError()
}
func (p *Player) SetScale(scale float64) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	C.libvlc_video_set_scale(p.player, C.float(scale))
	return getError()
}
func (p *Player) AspectRatio() (string, error) {
	if err := p.assertInit(); err != nil {
		return "", err
	}
	aspectRatio := C.libvlc_video_get_aspect_ratio(p.player)
	if aspectRatio == nil {
		return "", getError()
	}
	defer C.free(unsafe.Pointer(aspectRatio))
	return C.GoString(aspectRatio), getError()
}
func (p *Player) SetAspectRatio(aspectRatio string) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	cAspectRatio := C.CString(aspectRatio)
	C.libvlc_video_set_aspect_ratio(p.player, cAspectRatio)
	C.free(unsafe.Pointer(cAspectRatio))
	return getError()
}
func (p *Player) AudioDelay() (time.Duration, error) {
	if err := p.assertInit(); err != nil {
		return 0, err
	}
	delay := C.libvlc_audio_get_delay(p.player)
	return time.Duration(delay) * time.Microsecond, getError()
}
func (p *Player) SetAudioDelay(d time.Duration) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	if C.libvlc_audio_set_delay(p.player, C.int64_t(d.Microseconds())) != 0 {
		return errOrDefault(getError(), ErrMediaTrackNotFound)
	}
	return nil
}
func (p *Player) SubtitleDelay() (time.Duration, error) {
	if err := p.assertInit(); err != nil {
		return 0, err
	}
	delay := C.libvlc_video_get_spu_delay(p.player)
	return time.Duration(delay) * time.Microsecond, getError()
}
func (p *Player) SetSubtitleDelay(d time.Duration) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	if C.libvlc_video_set_spu_delay(p.player, C.int64_t(d.Microseconds())) != 0 {
		return errOrDefault(getError(), ErrMediaTrackNotFound)
	}
	return nil
}
func (p *Player) VideoTrackCount() (int, error) {
	if err := p.assertInit(); err != nil {
		return 0, err
	}
	count := int(C.libvlc_video_get_track_count(p.player))
	if count < 0 {
		return 0, errOrDefault(getError(), ErrMediaNotInitialized)
	}
	return count, nil
}
func (p *Player) VideoTrackDescriptors() ([]*MediaTrackDescriptor, error) {
	if err := p.assertInit(); err != nil {
		return nil, err
	}
	cDescriptors := C.libvlc_video_get_track_description(p.player)
	return parseMediaTrackDescriptorList(cDescriptors)
}
func (p *Player) VideoTrackID() (int, error) {
	if err := p.assertInit(); err != nil {
		return 0, err
	}
	return int(C.libvlc_video_get_track(p.player)), nil
}
func (p *Player) SetVideoTrack(trackID int) error {
	if err := p.assertInit(); err != nil {
		return err
	}
	if C.libvlc_video_set_track(p.player, C.int(trackID)) != 0 {
		return errOrDefault(getError(), ErrInvalidMediaTrack)
	}
	return nil
}