vlc

package module
v3.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 16 Imported by: 28

Documentation

Overview

Package vlc provides Golang bindings for libVLC version 3.X.

Usage

Initialization

// Initialize libVLC. Additional command line arguments can be passed in
// to libVLC by specifying them in the Init function.
if err := vlc.Init("--no-video", "--quiet"); err != nil {
	log.Fatal(err)
}
defer vlc.Release()

Player example

// Create a new player.
player, err := vlc.NewPlayer()
if err != nil {
	log.Fatal(err)
}
defer func() {
	player.Stop()
	player.Release()
}()

// Add a media file from path or from URL.
// Set player media from path:
// media, err := player.LoadMediaFromPath("localpath/test.mp4")
// Set player media from URL:
media, err := player.LoadMediaFromURL("http://stream-uk1.radioparadise.com/mp3-32")
if err != nil {
	log.Fatal(err)
}
defer media.Release()

// Retrieve player event manager.
manager, err := player.EventManager()
if err != nil {
	log.Fatal(err)
}

// Register the media end reached event with the event manager.
quit := make(chan struct{})
eventCallback := func(event vlc.Event, userData interface{}) {
	close(quit)
}

eventID, err := manager.Attach(vlc.MediaPlayerEndReached, eventCallback, nil)
if err != nil {
	log.Fatal(err)
}
defer manager.Detach(eventID)

// Start playing the media.
if err = player.Play(); err != nil {
	log.Fatal(err)
}

<-quit

List player example

// Create a new list player.
player, err := vlc.NewListPlayer()
if err != nil {
	log.Fatal(err)
}
defer func() {
	player.Stop()
	player.Release()
}()

// Create a new media list.
list, err := vlc.NewMediaList()
if err != nil {
	log.Fatal(err)
}
defer list.Release()

err = list.AddMediaFromPath("localpath/test1.mp3")
if err != nil {
	log.Fatal(err)
}

err = list.AddMediaFromURL("http://stream-uk1.radioparadise.com/mp3-32")
if err != nil {
	log.Fatal(err)
}

// Set player media list.
if err = player.SetMediaList(list); err != nil {
	log.Fatal(err)
}

// Media files can be added to the list after the list has been added
// to the player. The player will play these files as well.
err = list.AddMediaFromPath("localpath/test2.mp3")
if err != nil {
	log.Fatal(err)
}

// Retrieve player event manager.
manager, err := player.EventManager()
if err != nil {
	log.Fatal(err)
}

// Register the media end reached event with the event manager.
quit := make(chan struct{})
eventCallback := func(event vlc.Event, userData interface{}) {
	close(quit)
}

eventID, err := manager.Attach(vlc.MediaListPlayerPlayed, eventCallback, nil)
if err != nil {
	log.Fatal(err)
}
defer manager.Detach(eventID)

// Start playing the media list.
if err = player.Play(); err != nil {
	log.Fatal(err)
}

<-quit

Handling multiple events example

// Create a new player.
player, err := vlc.NewPlayer()
if err != nil {
	log.Fatal(err)
}
defer func() {
	player.Stop()
	player.Release()
}()

// Add a media file from path or from URL.
// Set player media from path:
// media, err := player.LoadMediaFromPath("test.mp3")
// Set player media from URL:
media, err := player.LoadMediaFromURL("http://stream-uk1.radioparadise.com/mp3-32")
if err != nil {
	log.Fatal(err)
}
defer media.Release()

// Retrieve player event manager.
manager, err := player.EventManager()
if err != nil {
	log.Fatal(err)
}

// Create event handler.
quit := make(chan struct{})
eventCallback := func(event vlc.Event, userData interface{}) {
	switch event {
	case vlc.MediaPlayerEndReached:
		log.Println("Player end reached")
		close(quit)
	case vlc.MediaPlayerTimeChanged:
		media, err := player.Media()
		if err != nil {
			log.Println(err)
			break
		}

		stats, err := media.Stats()
		if err != nil {
			log.Println(err)
			break
		}

		log.Printf("%+v\n", stats)
	}
}

// Register events with the event manager.
events := []vlc.Event{
	vlc.MediaPlayerTimeChanged,
	vlc.MediaPlayerEndReached,
}

var eventIDs []vlc.EventID
for _, event := range events {
	eventID, err := manager.Attach(event, eventCallback, nil)
	if err != nil {
		log.Fatal(err)
	}

	eventIDs = append(eventIDs, eventID)
}

// De-register attached events.
defer func() {
	for _, eventID := range eventIDs {
		manager.Detach(eventID)
	}
}()

// Start playing the media.
if err = player.Play(); err != nil {
	log.Fatal(err)
}

<-quit

Index

Constants

View Source
const (
	MediaListViewItemAdded = 0x300 + iota
	MediaListViewWillAddItem
	MediaListViewItemDeleted
	MediaListViewWillDeleteItem
)

Deprecated events.

View Source
const (
	// MediaListPlayerPlayed is triggered when playback of the media list
	// of the list player has ended.
	MediaListPlayerPlayed = 0x400 + iota

	// MediaListPlayerNextItemSet is triggered when the current item
	// of a media list player has changed to a different item.
	MediaListPlayerNextItemSet

	// MediaListPlayerStopped is triggered when playback
	// of a media list player is stopped programmatically.
	MediaListPlayerStopped
)

Variables

View Source
var (
	ErrModuleInitialize     = errors.New("could not initialize module")
	ErrModuleNotInitialized = errors.New("module is not initialized")
	ErrUserInterfaceStart   = errors.New("could not start user interface")
)

Module errors.

View Source
var (
	ErrPlayerCreate                = errors.New("could not create player")
	ErrPlayerNotInitialized        = errors.New("player is not initialized")
	ErrPlayerPlay                  = errors.New("cannot play the requested media")
	ErrPlayerSetVolume             = errors.New("could not set player volume")
	ErrPlayerSetRenderer           = errors.New("could not set player renderer")
	ErrPlayerSetEqualizer          = errors.New("could not set player equalizer")
	ErrPlayerInvalidRole           = errors.New("invalid player role")
	ErrPlayerTitleNotInitialized   = errors.New("player title not initialized")
	ErrPlayerChapterNotInitialized = errors.New("player chapter not initialized")
)

Player errors.

View Source
var (
	ErrListPlayerCreate         = errors.New("could not create list player")
	ErrListPlayerNotInitialized = errors.New("list player not initialized")
)

List player errors.

View Source
var (
	ErrMediaCreate             = errors.New("could not create media")
	ErrMediaNotFound           = errors.New("could not find media")
	ErrMediaNotInitialized     = errors.New("media is not initialized")
	ErrMediaListCreate         = errors.New("could not create media list")
	ErrMediaListNotFound       = errors.New("could not find media list")
	ErrMediaListNotInitialized = errors.New("media list is not initialized")
	ErrMediaListReadOnly       = errors.New("media list is read-only")
	ErrMediaListActionFailed   = errors.New("could not perform media list action")
	ErrMissingMediaStats       = errors.New("could not get media statistics")
	ErrInvalidMediaStats       = errors.New("invalid media statistics")
	ErrMissingMediaLocation    = errors.New("could not get media location")
	ErrMissingMediaDimensions  = errors.New("could not get media dimensions")
	ErrMediaMetaSave           = errors.New("could not save media metadata")
	ErrMediaParse              = errors.New("could not parse media")
	ErrMediaNotParsed          = errors.New("media is not parsed")
)

Media errors.

View Source
var (
	ErrMediaTrackNotInitialized = errors.New("media track is not initialized")
	ErrMediaTrackNotFound       = errors.New("could not find media track")
	ErrInvalidMediaTrack        = errors.New("invalid media track")
)

Media track errors.

View Source
var (
	ErrMissingEventManager  = errors.New("could not get event manager instance")
	ErrInvalidEventCallback = errors.New("invalid event callback")
	ErrEventAttach          = errors.New("could not attach event")
)

Event manager errors.

View Source
var (
	ErrAudioOutputListMissing       = errors.New("could not get audio output list")
	ErrAudioOutputSet               = errors.New("could not set audio output")
	ErrAudioOutputDeviceListMissing = errors.New("could not get audio output device list")
	ErrAudioOutputDeviceMissing     = errors.New("could not get audio output device")
	ErrFilterListMissing            = errors.New("could not get filter list")
	ErrStereoModeSet                = errors.New("could not set stereo mode")
	ErrVideoViewpointSet            = errors.New("could not set video viewpoint")
	ErrVideoSnapshot                = errors.New("could not take video snapshot")
	ErrCursorPositionMissing        = errors.New("could not get cursor position")
)

Audio/Video errors.

View Source
var (
	ErrRendererDiscovererParse          = errors.New("could not parse renderer discoverer")
	ErrRendererDiscovererCreate         = errors.New("could not create renderer discoverer")
	ErrRendererDiscovererNotInitialized = errors.New("renderer discoverer not initialized")
	ErrRendererDiscovererStart          = errors.New("could not start renderer discoverer")
	ErrRendererNotInitialized           = errors.New("renderer not initialized")
)

Renderer discoverer errors.

View Source
var (
	ErrMediaDiscovererParse          = errors.New("could not parse media discoverer")
	ErrMediaDiscovererCreate         = errors.New("could not create media discoverer")
	ErrMediaDiscovererNotInitialized = errors.New("media discoverer not initialized")
	ErrMediaDiscovererStart          = errors.New("could not start media discoverer")
)

Media discoverer errors.

View Source
var (
	ErrEqualizerCreate         = errors.New("could not create equalizer")
	ErrEqualizerNotInitialized = errors.New("equalizer not initialized")
	ErrEqualizerAmpValueSet    = errors.New("could not set equalizer amplification value")
)

Equalizer errors.

View Source
var (
	ErrInvalid = errors.New("the provided value is not valid")
)

Generic errors.

Functions

func EqualizerBandCount added in v3.1.2

func EqualizerBandCount() uint

EqualizerBandCount returns the number of distinct equalizer frequency bands.

func EqualizerBandFrequencies added in v3.1.2

func EqualizerBandFrequencies() []float64

EqualizerBandFrequencies returns the frequencies of all available equalizer bands, sorted by their indices in ascending order.

func EqualizerBandFrequency added in v3.1.2

func EqualizerBandFrequency(index uint) float64

EqualizerBandFrequency returns the frequency of the equalizer band with the specified index. The index must be a number greater than or equal to 0 and less than EqualizerBandCount(). The function returns -1 for invalid indices.

func EqualizerPresetCount added in v3.1.2

func EqualizerPresetCount() uint

EqualizerPresetCount returns the number of available equalizer presets.

func EqualizerPresetName added in v3.1.2

func EqualizerPresetName(index uint) string

EqualizerPresetName returns the name of the equalizer preset with the specified index. The index must be a number greater than or equal to 0 and less than EqualizerPresetCount(). The function returns an empty string for invalid indices.

func EqualizerPresetNames added in v3.1.2

func EqualizerPresetNames() []string

EqualizerPresetNames returns the names of all available equalizer presets, sorted by their indices in ascending order.

func Init

func Init(args ...string) error

Init creates an instance of the libVLC module. Must be called only once and the module instance must be released using the Release function.

func Release

func Release() error

Release destroys the instance created by the Init function.

func SetAppID added in v3.0.4

func SetAppID(id, version, icon string) error

SetAppID sets metadata for identifying the application.

func SetAppName added in v3.0.4

func SetAppName(name, userAgent string) error

SetAppName sets the human-readable application name and the HTTP user agent. The specified user agent is used when a protocol requires it.

func StartUserInterface added in v3.0.4

func StartUserInterface(name string) error

StartUserInterface attempts to start a user interface for the libVLC instance. Pass an empty string as the name parameter in order to start the default interface.

Types

type AudioOutput

type AudioOutput struct {
	Name        string
	Description string
}

AudioOutput contains information regarding an audio output.

func AudioOutputList

func AudioOutputList() ([]*AudioOutput, error)

AudioOutputList returns the list of available audio outputs. In order to change the audio output of a media player instance, use the Player.SetAudioOutput method.

type AudioOutputDevice added in v3.1.4

type AudioOutputDevice struct {
	Name        string
	Description string
}

AudioOutputDevice contains information regarding an audio output device.

func ListAudioOutputDevices added in v3.1.4

func ListAudioOutputDevices(output string) ([]*AudioOutputDevice, error)

ListAudioOutputDevices returns the list of available devices for the specified audio output. Use the AudioOutputList method in order to obtain the list of available audio outputs. In order to change the audio output device of a media player instance, use Player.SetAudioOutputDevice.

NOTE: Not all audio outputs support this. An empty list of devices does
not imply that the specified audio output does not work.
Some audio output devices in the list might not work in some circumstances.
By default, it is recommended to not specify any explicit audio device.

type ChapterInfo added in v3.1.5

type ChapterInfo struct {
	Name     string        // Name of the chapter.
	Duration time.Duration // Duration of the chapter.
	Offset   time.Duration // Offset from the start of the media or media title.
}

ChapterInfo contains information regarding a media chapter. DVD and Blu-ray formats have their content split into titles and chapters. However, chapters are supported by other media formats as well.

type DeinterlaceMode added in v3.1.6

type DeinterlaceMode string

DeinterlaceMode defines deinterlacing modes which can be used when rendering videos.

For more information see https://wiki.videolan.org/Deinterlacing.
const (
	DeinterlaceModeDisable  DeinterlaceMode = ""
	DeinterlaceModeDiscard  DeinterlaceMode = "discard"
	DeinterlaceModeBlend    DeinterlaceMode = "blend"
	DeinterlaceModeMean     DeinterlaceMode = "mean"
	DeinterlaceModeBob      DeinterlaceMode = "bob"
	DeinterlaceModeLinear   DeinterlaceMode = "linear"
	DeinterlaceModeX        DeinterlaceMode = "x"
	DeinterlaceModeYadif    DeinterlaceMode = "yadif"
	DeinterlaceModeYadif2x  DeinterlaceMode = "yadif2x"
	DeinterlaceModePhosphor DeinterlaceMode = "phosphor"
	DeinterlaceModeIVTC     DeinterlaceMode = "ivtc"
)

Deinterlace modes.

type Equalizer added in v3.1.2

type Equalizer struct {
	// contains filtered or unexported fields
}

Equalizer represents an audio equalizer. Use Player.SetEqualizer to assign the equalizer to a player instance.

func NewEqualizer added in v3.1.2

func NewEqualizer() (*Equalizer, error)

NewEqualizer returns a new equalizer with all frequency values set to zero.

func NewEqualizerFromPreset added in v3.1.2

func NewEqualizerFromPreset(index uint) (*Equalizer, error)

NewEqualizerFromPreset returns a new equalizer with the frequency values copied from the preset with the specified index. The index must be a number greater than or equal to 0 and less than EqualizerPresetCount().

func (*Equalizer) AmpValueAtIndex added in v3.1.2

func (e *Equalizer) AmpValueAtIndex(index uint) (float64, error)

AmpValueAtIndex returns the amplification value for the equalizer frequency band with the specified index, in Hz. The index must be a number greater than or equal to 0 and less than EqualizerBandCount().

func (*Equalizer) PreampValue added in v3.1.2

func (e *Equalizer) PreampValue() (float64, error)

PreampValue returns the pre-amplification value of the equalizer in Hz.

func (*Equalizer) Release added in v3.1.2

func (e *Equalizer) Release() error

Release destroys the equalizer instance.

func (*Equalizer) SetAmpValueAtIndex added in v3.1.2

func (e *Equalizer) SetAmpValueAtIndex(value float64, index uint) error

SetAmpValueAtIndex sets the amplification value for the equalizer frequency band with the specified index, in Hz. The index must be a number greater than or equal to 0 and less than EqualizerBandCount().

func (*Equalizer) SetPreampValue added in v3.1.2

func (e *Equalizer) SetPreampValue(value float64) error

SetPreampValue sets the pre-amplification value of the equalizer. The specified amplification value is clamped to the [-20.0, 20.0] Hz range.

type Event

type Event int

Event represents an event that can occur inside libvlc.

const (
	// MediaMetaChanged is triggered when the metadata of a media item changes.
	MediaMetaChanged Event = iota

	// MediaSubItemAdded is triggered when a Subitem is added to a media item.
	MediaSubItemAdded

	// MediaDurationChanged is triggered when the duration
	// of a media item changes.
	MediaDurationChanged

	// MediaParsedChanged is triggered when the parsing state
	// of a media item changes.
	MediaParsedChanged

	// MediaFreed is triggered when a media item is freed.
	MediaFreed

	// MediaStateChanged is triggered when the state of the media item changes.
	MediaStateChanged

	// MediaSubItemTreeAdded is triggered when a Subitem tree is
	// added to a media item.
	MediaSubItemTreeAdded

	// MediaThumbnailGenerated is triggered when a thumbnail
	// generation is completed.
	MediaThumbnailGenerated
)

Media events.

const (
	MediaPlayerMediaChanged Event = 0x100 + iota
	MediaPlayerNothingSpecial
	MediaPlayerOpening
	MediaPlayerBuffering
	MediaPlayerPlaying
	MediaPlayerPaused
	MediaPlayerStopped
	MediaPlayerForward
	MediaPlayerBackward
	MediaPlayerEndReached
	MediaPlayerEncounteredError
	MediaPlayerTimeChanged
	MediaPlayerPositionChanged
	MediaPlayerSeekableChanged
	MediaPlayerPausableChanged
	MediaPlayerTitleChanged
	MediaPlayerSnapshotTaken
	MediaPlayerLengthChanged
	MediaPlayerVout
	MediaPlayerScrambledChanged
	MediaPlayerESAdded
	MediaPlayerESDeleted
	MediaPlayerESSelected
	MediaPlayerCorked
	MediaPlayerUncorked
	MediaPlayerMuted
	MediaPlayerUnmuted
	MediaPlayerAudioVolume
	MediaPlayerAudioDevice
	MediaPlayerChapterChanged
)

Player events.

const (
	// MediaListItemAdded is triggered when a media item is added to a media list.
	MediaListItemAdded Event = 0x200 + iota

	// MediaListWillAddItem is triggered when a media item is about to get
	// added to a media list.
	MediaListWillAddItem

	// MediaListItemDeleted is triggered when a media item is deleted
	// from a media list.
	MediaListItemDeleted

	// MediaListWillDeleteItem is triggered when a media item is about to get
	// deleted from a media list.
	MediaListWillDeleteItem

	// MediaListEndReached is triggered when a media list has reached the end.
	MediaListEndReached
)

Media list events.

const (
	MediaDiscovererStarted Event = 0x500 + iota
	MediaDiscovererEnded
)

Deprecated events.

const (
	// RendererDiscovererItemAdded is triggered when a new renderer item is
	// found by a renderer discoverer. The renderer item is valid until deleted.
	RendererDiscovererItemAdded Event = 0x502 + iota

	// RendererDiscovererItemDeleted is triggered when a previously discovered
	// renderer item was deleted by a renderer discoverer. The renderer item
	// is no longer valid.
	RendererDiscovererItemDeleted
)

Renderer events.

const (
	VlmMediaAdded Event = 0x600 + iota
	VlmMediaRemoved
	VlmMediaChanged
	VlmMediaInstanceStarted
	VlmMediaInstanceStopped
	VlmMediaInstanceStatusInit
	VlmMediaInstanceStatusOpening
	VlmMediaInstanceStatusPlaying
	VlmMediaInstanceStatusPause
	VlmMediaInstanceStatusEnd
	VlmMediaInstanceStatusError
)

VideoLAN Manager events.

type EventCallback

type EventCallback func(Event, interface{})

EventCallback represents an event notification callback function.

type EventID

type EventID uint64

EventID uniquely identifies a registered event.

type EventManager

type EventManager struct {
	// contains filtered or unexported fields
}

EventManager wraps a libvlc event manager.

func (*EventManager) Attach

func (em *EventManager) Attach(event Event, callback EventCallback, userData interface{}) (EventID, error)

Attach registers a callback for an event notification.

func (*EventManager) Detach

func (em *EventManager) Detach(eventIDs ...EventID)

Detach unregisters the specified event notification.

type ListPlayer

type ListPlayer struct {
	// contains filtered or unexported fields
}

ListPlayer is an enhanced media player used to play media lists.

func NewListPlayer

func NewListPlayer() (*ListPlayer, error)

NewListPlayer creates a new list player instance.

func (*ListPlayer) EventManager

func (lp *ListPlayer) EventManager() (*EventManager, error)

EventManager returns the event manager responsible for the list player.

func (*ListPlayer) IsPlaying

func (lp *ListPlayer) IsPlaying() bool

IsPlaying returns a boolean value specifying if the player is currently playing.

func (*ListPlayer) MediaList

func (lp *ListPlayer) MediaList() *MediaList

MediaList returns the current media list of the player, if one exists.

func (*ListPlayer) MediaState

func (lp *ListPlayer) MediaState() (MediaState, error)

MediaState returns the state of the current media.

func (*ListPlayer) Play

func (lp *ListPlayer) Play() error

Play plays the current media list.

func (*ListPlayer) PlayAtIndex

func (lp *ListPlayer) PlayAtIndex(index uint) error

PlayAtIndex plays the media at the specified index from the current media list.

func (*ListPlayer) PlayItem added in v3.0.3

func (lp *ListPlayer) PlayItem(m *Media) error

PlayItem plays the specified media item. The item must be part of the current media list of the player.

func (*ListPlayer) PlayNext

func (lp *ListPlayer) PlayNext() error

PlayNext plays the next media in the current media list.

func (*ListPlayer) PlayPrevious

func (lp *ListPlayer) PlayPrevious() error

PlayPrevious plays the previous media in the current media list.

func (*ListPlayer) Player

func (lp *ListPlayer) Player() (*Player, error)

Player returns the underlying Player instance of the list player.

func (*ListPlayer) Release

func (lp *ListPlayer) Release() error

Release destroys the list player instance.

func (*ListPlayer) SetMediaList

func (lp *ListPlayer) SetMediaList(ml *MediaList) error

SetMediaList sets the media list to be played.

func (*ListPlayer) SetPause added in v3.0.3

func (lp *ListPlayer) SetPause(pause bool) error

SetPause sets the pause state of the list player. Pass in `true` to pause the current media, or `false` to resume it.

func (*ListPlayer) SetPlaybackMode

func (lp *ListPlayer) SetPlaybackMode(mode PlaybackMode) error

SetPlaybackMode sets the player playback mode for the media list. By default, it plays the media list once and then stops.

func (*ListPlayer) SetPlayer

func (lp *ListPlayer) SetPlayer(player *Player) error

SetPlayer sets the underlying Player instance of the list player.

func (*ListPlayer) Stop

func (lp *ListPlayer) Stop() error

Stop cancels the currently playing media list, if there is one.

func (*ListPlayer) TogglePause

func (lp *ListPlayer) TogglePause() error

TogglePause pauses/resumes the player. Calling this method has no effect if there is no media.

type Logo struct {
	// contains filtered or unexported fields
}

Logo represents a logo that can be displayed over a media instance.

For more information see https://wiki.videolan.org/Documentation:Modules/logo.

func (*Logo) DisplayDuration added in v3.1.6

func (l *Logo) DisplayDuration() (time.Duration, error)

DisplayDuration returns the global duration for which a logo file is set to be displayed before displaying the next one (if one is available). The global display duration can be overridden by each provided logo file. Default: 1s.

func (*Logo) Enable added in v3.1.6

func (l *Logo) Enable(enable bool) error

Enable enables or disables the logo. By default, the logo is disabled.

func (*Logo) Opacity added in v3.1.6

func (l *Logo) Opacity() (int, error)

Opacity returns the global opacity of the logo. The returned opacity is a value between 0 (transparent) and 255 (opaque). The global opacity can be overridden by each provided logo file. Default: 255.

func (*Logo) Position added in v3.1.6

func (l *Logo) Position() (Position, error)

Position returns the position of the logo, relative to its container. Default: vlc.PositionTopLeft.

func (*Logo) RepeatCount added in v3.1.6

func (l *Logo) RepeatCount() (int, error)

RepeatCount returns the number of times the logo sequence is set to be repeated.

func (*Logo) SetDisplayDuration added in v3.1.6

func (l *Logo) SetDisplayDuration(displayDuration time.Duration) error

SetDisplayDuration sets the duration for which to display a logo file before displaying the next one (if one is available). The global display duration can be overridden by each provided logo file.

func (*Logo) SetFiles added in v3.1.6

func (l *Logo) SetFiles(files ...*LogoFile) error

SetFiles sets the sequence of files to be displayed for the logo.

func (*Logo) SetOpacity added in v3.1.6

func (l *Logo) SetOpacity(opacity int) error

SetOpacity sets the global opacity of the logo. If an opacity override is not specified when setting the logo files, the global opacity is used. The opacity is specified as an integer between 0 (transparent) and 255 (opaque). The global opacity can be overridden by each provided logo file.

func (*Logo) SetPosition added in v3.1.6

func (l *Logo) SetPosition(position Position) error

SetPosition sets the position of the logo, relative to its container.

func (*Logo) SetRepeatCount added in v3.1.6

func (l *Logo) SetRepeatCount(count int) error

SetRepeatCount sets the number of times the logo sequence should repeat. Pass in `-1` to repeat the logo sequence indefinitely, `0` to disable logo sequence looping or a positive number to repeat the logo sequence a specific number of times. Default: -1 (the logo sequence is repeated indefinitely).

func (*Logo) SetX added in v3.1.6

func (l *Logo) SetX(x int) error

SetX sets the X coordinate of the logo. The value is specified relative to the position of the logo inside its container, i.e. the position set using the `Logo.SetPosition` method.

NOTE: the method has no effect if the position of the logo is set to
`vlc.PositionCenter`, `vlc.PositionTop` or `vlc.PositionBottom`.

func (*Logo) SetY added in v3.1.6

func (l *Logo) SetY(y int) error

SetY sets the Y coordinate of the logo. The value is specified relative to the position of the logo inside its container.

NOTE: the method has no effect if the position of the logo is set to
`vlc.PositionCenter`, `vlc.PositionLeft` or `vlc.PositionRight`.

func (*Logo) X added in v3.1.6

func (l *Logo) X() (int, error)

X returns the X coordinate of the logo. The returned value is relative to the position of the logo inside its container, i.e. the position set using Logo.SetPosition method. Default: 0.

func (*Logo) Y added in v3.1.6

func (l *Logo) Y() (int, error)

Y returns the Y coordinate of the logo. The returned value is relative to the position of the logo inside its container, i.e. the position set using the `Logo.SetPosition` method. Default: 0.

type LogoFile added in v3.1.6

type LogoFile struct {
	// contains filtered or unexported fields
}

LogoFile represents a logo file which can be used as a media player's logo. The logo of a player can also be composed of a series of alternating files.

func NewLogoFileFromImage added in v3.1.6

func NewLogoFileFromImage(img image.Image, displayDuration time.Duration, opacity int) (*LogoFile, error)

NewLogoFileFromImage returns a new logo file with the specified image. The file is displyed for the provided duration. If the specified display duration is negative, the global display duration set on the logo the file is applied to is used. The provided opacity must be a value between 0 (transparent) and 255 (opaque). If the specified opacity is negative, the global opacity set on the logo the file is applied to is used.

func NewLogoFileFromPath added in v3.1.6

func NewLogoFileFromPath(path string, displayDuration time.Duration, opacity int) (*LogoFile, error)

NewLogoFileFromPath returns a new logo file with the specified path. The file is displyed for the provided duration. If the specified display duration is negative, the global display duration set on the logo the file is applied to is used. The provided opacity must be a value between 0 (transparent) and 255 (opaque). If the specified opacity is negative, the global opacity set on the logo the file is applied to is used.

type Marquee added in v3.1.6

type Marquee struct {
	// contains filtered or unexported fields
}

Marquee represents a marquee text than can be displayed over a media instance, along with its visual properties.

For more information see https://wiki.videolan.org/Documentation:Modules/marq.

func (*Marquee) Color added in v3.1.6

func (m *Marquee) Color() (color.Color, error)

Color returns the marquee text color. Opacity information is included in the returned color. Default: white.

func (*Marquee) DisplayDuration added in v3.1.6

func (m *Marquee) DisplayDuration() (time.Duration, error)

DisplayDuration returns the duration for which the marquee text is set to be displayed. Default: 0 (the marquee is displayed indefinitely).

func (*Marquee) Enable added in v3.1.6

func (m *Marquee) Enable(enable bool) error

Enable enables or disables the marquee. By default, the marquee is disabled.

func (*Marquee) Opacity added in v3.1.6

func (m *Marquee) Opacity() (int, error)

Opacity returns the opacity of the marquee text. The returned opacity is a value between 0 (transparent) and 255 (opaque). Default: 255.

func (*Marquee) Position added in v3.1.6

func (m *Marquee) Position() (Position, error)

Position returns the position of the marquee, relative to its container. Default: vlc.PositionTopLeft.

func (*Marquee) RefreshInterval added in v3.1.6

func (m *Marquee) RefreshInterval() (time.Duration, error)

RefreshInterval returns the interval between marquee text updates. The marquee text refreshes mainly when using time format string sequences. Default: 1s.

func (*Marquee) SetColor added in v3.1.6

func (m *Marquee) SetColor(color color.Color) error

SetColor sets the color of the marquee text. The opacity of the text is also set, based on the alpha value of the color.

func (*Marquee) SetDisplayDuration added in v3.1.6

func (m *Marquee) SetDisplayDuration(displayDuration time.Duration) error

SetDisplayDuration sets the duration for which to display the marquee text.

func (*Marquee) SetOpacity added in v3.1.6

func (m *Marquee) SetOpacity(opacity int) error

SetOpacity sets the opacity of the marquee text. The opacity is specified as an integer between 0 (transparent) and 255 (opaque).

func (*Marquee) SetPosition added in v3.1.6

func (m *Marquee) SetPosition(position Position) error

SetPosition sets the position of the marquee, relative to its container.

func (*Marquee) SetRefreshInterval added in v3.1.6

func (m *Marquee) SetRefreshInterval(refreshInterval time.Duration) error

SetRefreshInterval sets the interval between marquee text updates. The marquee text refreshes mainly when using time format string sequences.

func (*Marquee) SetSize added in v3.1.6

func (m *Marquee) SetSize(size int) error

SetSize sets the font size used to render the marquee text.

func (*Marquee) SetText added in v3.1.6

func (m *Marquee) SetText(text string) error

SetText sets the marquee text. The specified text can contain time format string sequences which are converted to the requested time values at runtime. Most of the time conversion specifiers supported by the `strftime` C function can be used.

Common time format string sequences:
%Y = year, %m = month, %d = day, %H = hour, %M = minute, %S = second.
For more information see https://en.cppreference.com/w/c/chrono/strftime.

func (*Marquee) SetX added in v3.1.6

func (m *Marquee) SetX(x int) error

SetX sets the X coordinate of the marquee text. The value is specified relative to the position of the marquee inside its container.

NOTE: the method has no effect if the position of the marquee is set to
`vlc.PositionCenter`, `vlc.PositionTop` or `vlc.PositionBottom`.

func (*Marquee) SetY added in v3.1.6

func (m *Marquee) SetY(y int) error

SetY sets the Y coordinate of the marquee text. The value is specified relative to the position of the marquee inside its container.

NOTE: the method has no effect if the position of the marquee is set to
`vlc.PositionCenter`, `vlc.PositionLeft` or `vlc.PositionRight`.

func (*Marquee) Size added in v3.1.6

func (m *Marquee) Size() (int, error)

Size returns the font size used to render the marquee text. Default: 0 (default font size is used).

func (*Marquee) Text added in v3.1.6

func (m *Marquee) Text() (string, error)

Text returns the marquee text. Default: "".

func (*Marquee) X added in v3.1.6

func (m *Marquee) X() (int, error)

X returns the X coordinate of the marquee text. The returned value is relative to the position of the marquee inside its container, i.e. the position set using the `Marquee.SetPosition` method. Default: 0.

func (*Marquee) Y added in v3.1.6

func (m *Marquee) Y() (int, error)

Y returns the Y coordinate of the marquee text. The returned value is relative to the position of the marquee inside its container, i.e. the position set using the `Marquee.SetPosition` method. Default: 0.

type Media

type Media struct {
	// contains filtered or unexported fields
}

Media is an abstract representation of a playable media file.

func NewMediaFromPath

func NewMediaFromPath(path string) (*Media, error)

NewMediaFromPath creates a new media instance based on the media located at the specified path.

func NewMediaFromReadSeeker added in v3.0.9

func NewMediaFromReadSeeker(r io.ReadSeeker) (*Media, error)

NewMediaFromReadSeeker creates a new media instance based on the provided read seeker.

func NewMediaFromScreen added in v3.0.3

func NewMediaFromScreen(opts *MediaScreenOptions) (*Media, error)

NewMediaFromScreen creates a media instance from the current computer screen, using the specified options.

NOTE: This functionality requires the VLC screen module to be installed.
See installation instructions at https://github.com/adrg/libvlc-go/wiki.
See https://wiki.videolan.org/Documentation:Modules/screen.

func NewMediaFromURL

func NewMediaFromURL(url string) (*Media, error)

NewMediaFromURL creates a new media instance based on the media located at the specified URL.

func (*Media) AddOptions

func (m *Media) AddOptions(options ...string) error

AddOptions adds the specified options to the media. The specified options determine how a media player reads the media, allowing advanced reading or streaming on a per-media basis.

func (*Media) Duplicate added in v3.0.8

func (m *Media) Duplicate() (*Media, error)

Duplicate duplicates the current media instance.

NOTE: Call the Release method on the returned media in order to
free the allocated resources.

func (*Media) Duration added in v3.0.4

func (m *Media) Duration() (time.Duration, error)

Duration returns the media duration in milliseconds.

NOTE: The duration can only be obtained for parsed media instances.
Either play the media once or call one of the parsing methods first.

func (*Media) EventManager

func (m *Media) EventManager() (*EventManager, error)

EventManager returns the event manager responsible for the media.

func (*Media) IsParsed

func (m *Media) IsParsed() (bool, error)

IsParsed returns true if the media was parsed.

NOTE: Deprecated in libVLC v3.0.0+. Use ParseStatus instead.

func (*Media) Location

func (m *Media) Location() (string, error)

Location returns the media location, which can be either a local path or a URL, depending on how the media was loaded.

func (*Media) Meta

func (m *Media) Meta(key MediaMetaKey) (string, error)

Meta reads the value of the specified media metadata key.

func (*Media) Parse

func (m *Media) Parse() error

Parse fetches local art, metadata and track information synchronously.

NOTE: Deprecated in libVLC v3.0.0+. Use ParseWithOptions instead.

func (*Media) ParseAsync

func (m *Media) ParseAsync() error

ParseAsync fetches local art, metadata and track information asynchronously. Listen to the MediaParsedChanged event on the media event manager the track when the parsing has finished. However, if the media was already parsed, the event is not sent.

NOTE: Deprecated in libVLC v3.0.0+. Use ParseWithOptions instead.

func (*Media) ParseStatus added in v3.0.2

func (m *Media) ParseStatus() (MediaParseStatus, error)

ParseStatus returns the parsing status of the media.

func (*Media) ParseWithOptions added in v3.0.2

func (m *Media) ParseWithOptions(timeout int, opts ...MediaParseOption) error

ParseWithOptions fetches art, metadata and track information asynchronously, using the specified options. Listen to the MediaParsedChanged event on the media event manager the track when the parsing has finished. However, if the media was already parsed, the event is not sent. If no option is provided, the media is parsed only if it is a local file. The timeout parameter specifies the maximum amount of time allowed to preparse the media, in milliseconds.

// Timeout values:
timeout <  0: use default preparse time.
timeout == 0: wait indefinitely.
timeout >  0: wait the specified number of milliseconds.

func (*Media) Release

func (m *Media) Release() error

Release destroys the media instance.

func (*Media) SaveMeta

func (m *Media) SaveMeta() error

SaveMeta saves the previously set media metadata.

func (*Media) SetMeta

func (m *Media) SetMeta(key MediaMetaKey, val string) error

SetMeta sets the specified media metadata key to the provided value. In order to save the metadata on the media file, call SaveMeta.

func (*Media) SetUserData added in v3.0.9

func (m *Media) SetUserData(userData interface{}) error

SetUserData associates the passed in user data with the media instance. The data can be retrieved by using the UserData method.

func (*Media) State added in v3.0.4

func (m *Media) State() (MediaState, error)

State returns the current state of the media instance.

func (*Media) Stats

func (m *Media) Stats() (*MediaStats, error)

Stats returns playback statistics for the media.

func (*Media) StopParse added in v3.0.2

func (m *Media) StopParse() error

StopParse stops the parsing of the media. When the media parsing is stopped, the MediaParsedChanged event is sent and the parsing status of the media is set to MediaParseTimeout.

func (*Media) SubItems added in v3.0.4

func (m *Media) SubItems() (*MediaList, error)

SubItems returns a media list containing the sub-items of the current media instance. If the media does not have any sub-items, an empty media list is returned.

NOTE: Call the Release method on the returned media list in order to
free the allocated resources.

func (*Media) Tracks added in v3.0.7

func (m *Media) Tracks() ([]*MediaTrack, error)

Tracks returns the tracks (audio, video, subtitle) of the current media.

NOTE: The tracks can only be obtained for parsed media instances.
Either play the media once or call one of the parsing methods first.

func (*Media) Type added in v3.0.7

func (m *Media) Type() (MediaType, error)

Type returns the type of the media instance.

func (*Media) UserData added in v3.0.9

func (m *Media) UserData() (interface{}, error)

UserData returns the user data associated with the media instance.

NOTE: The method returns `nil` if no user data is found.

type MediaAudioTrack added in v3.0.7

type MediaAudioTrack struct {
	Channels uint // number of audio channels.
	Rate     uint // audio sample rate.
}

MediaAudioTrack contains information specific to audio media tracks.

type MediaDiscoverer added in v3.1.3

type MediaDiscoverer struct {
	// contains filtered or unexported fields
}

MediaDiscoverer represents a media discovery service. Discovery services use different discovery protocols (e.g. MTP, UPnP, SMB) in order to find available media instances.

func NewMediaDiscoverer added in v3.1.3

func NewMediaDiscoverer(name string) (*MediaDiscoverer, error)

NewMediaDiscoverer instantiates the media discovery service identified by the specified name. Use the ListMediaDiscoverers method to obtain the list of available discovery service descriptors.

NOTE: Call the Release method on the discovery service instance in
order to free the allocated resources.

func (*MediaDiscoverer) IsRunning added in v3.1.3

func (md *MediaDiscoverer) IsRunning() bool

IsRunning returns true if the media discovery service is running.

func (*MediaDiscoverer) MediaList added in v3.1.3

func (md *MediaDiscoverer) MediaList() (*MediaList, error)

MediaList returns the media list associated with the discovery service, which contains the found media instances.

NOTE: The returned media list is read-only.

func (*MediaDiscoverer) Release added in v3.1.3

func (md *MediaDiscoverer) Release() error

Release stops and destroys the media discovery service along with all the media found by the instance.

func (*MediaDiscoverer) Start added in v3.1.3

Start starts the media discovery service and reports discovery events through the specified callback function.

NOTE: The Stop and Release methods should not be called from the callback
function. Doing so will result in undefined behavior.

func (*MediaDiscoverer) Stop added in v3.1.3

func (md *MediaDiscoverer) Stop() error

Stop stops the discovery service.

type MediaDiscovererDescriptor added in v3.1.3

type MediaDiscovererDescriptor struct {
	Name     string
	LongName string
	Category MediaDiscoveryCategory
}

MediaDiscovererDescriptor contains information about a media discovery service. Pass the `Name` field to the NewMediaDiscoverer method in order to create a new discovery service instance.

func ListMediaDiscoverers added in v3.1.3

func ListMediaDiscoverers(category MediaDiscoveryCategory) ([]*MediaDiscovererDescriptor, error)

ListMediaDiscoverers returns a list of descriptors identifying the available media discovery services of the specified category.

type MediaDiscoveryCallback added in v3.1.3

type MediaDiscoveryCallback func(Event, *Media, int)

MediaDiscoveryCallback is used by media discovery services to report discovery events. The callback provides the event, the media instance, and the index at which the action takes place in the media list of the discovery service.

The available events are:

  • MediaListWillAddItem
  • MediaListItemAdded
  • MediaListWillDeleteItem
  • MediaListItemDeleted

type MediaDiscoveryCategory added in v3.1.3

type MediaDiscoveryCategory uint

MediaDiscoveryCategory defines categories of media discovery services.

const (
	// Devices (e.g. portable devices supporting MTP, discs).
	MediaDiscoveryDevices MediaDiscoveryCategory = iota

	// LAN/WAN services (e.g. UPnP, SMB, SAP).
	MediaDiscoveryLAN

	// Internet services (e.g. podcasts, radio stations).
	MediaDiscoveryInternet

	// Local directories.
	MediaDiscoveryLocal
)

Media discovery categories.

type MediaList

type MediaList struct {
	// contains filtered or unexported fields
}

MediaList represents a collection of media files.

func NewMediaList

func NewMediaList() (*MediaList, error)

NewMediaList creates an empty media list.

func (*MediaList) AddMedia

func (ml *MediaList) AddMedia(m *Media) error

AddMedia adds the provided Media instance at the end of the media list.

func (*MediaList) AddMediaFromPath

func (ml *MediaList) AddMediaFromPath(path string) error

AddMediaFromPath loads the media file at the specified path and adds it at the end of the media list.

func (*MediaList) AddMediaFromReadSeeker added in v3.0.9

func (ml *MediaList) AddMediaFromReadSeeker(r io.ReadSeeker) error

AddMediaFromReadSeeker loads the media from the provided read seeker and adds it at the end of the media list.

func (*MediaList) AddMediaFromURL

func (ml *MediaList) AddMediaFromURL(url string) error

AddMediaFromURL loads the media file at the specified URL and adds it at the end of the the media list.

func (*MediaList) AssociateMedia added in v3.0.4

func (ml *MediaList) AssociateMedia(m *Media) error

AssociateMedia associates the specified media with the media list instance.

NOTE: If another media instance is already associated with the list,
it will be released.

func (*MediaList) AssociatedMedia added in v3.0.4

func (ml *MediaList) AssociatedMedia() (*Media, error)

AssociatedMedia returns the media instance associated with the list, if one exists. A media instance is automatically associated with the list of its sub-items.

NOTE: Do not call Release on the returned media instance.

func (*MediaList) Count

func (ml *MediaList) Count() (int, error)

Count returns the number of media items in the list.

func (*MediaList) EventManager

func (ml *MediaList) EventManager() (*EventManager, error)

EventManager returns the event manager responsible for the media list.

func (*MediaList) IndexOfMedia added in v3.0.3

func (ml *MediaList) IndexOfMedia(m *Media) (int, error)

IndexOfMedia returns the index of the specified media item in the list.

NOTE: The same instance of a media item can be present multiple times
in the list. The method returns the first matched index.

func (*MediaList) InsertMedia

func (ml *MediaList) InsertMedia(m *Media, index uint) error

InsertMedia inserts the provided Media instance in the list, at the specified index.

func (*MediaList) InsertMediaFromPath

func (ml *MediaList) InsertMediaFromPath(path string, index uint) error

InsertMediaFromPath loads the media file at the provided path and inserts it in the list, at the specified index.

func (*MediaList) InsertMediaFromReadSeeker added in v3.0.9

func (ml *MediaList) InsertMediaFromReadSeeker(r io.ReadSeeker, index uint) error

InsertMediaFromReadSeeker loads the media from the provided read seeker and inserts it in the list, at the specified index.

func (*MediaList) InsertMediaFromURL

func (ml *MediaList) InsertMediaFromURL(url string, index uint) error

InsertMediaFromURL loads the media file at the provided URL and inserts it in the list, at the specified index.

func (*MediaList) IsReadOnly

func (ml *MediaList) IsReadOnly() (bool, error)

IsReadOnly specifies if the media list can be modified.

func (*MediaList) Lock

func (ml *MediaList) Lock() error

Lock makes the caller the current owner of the media list.

func (*MediaList) MediaAtIndex

func (ml *MediaList) MediaAtIndex(index uint) (*Media, error)

MediaAtIndex returns the media item at the specified index from the list.

func (*MediaList) Release

func (ml *MediaList) Release() error

Release destroys the media list instance.

func (*MediaList) RemoveMediaAtIndex

func (ml *MediaList) RemoveMediaAtIndex(index uint) error

RemoveMediaAtIndex removes the media item at the specified index from the list.

func (*MediaList) Unlock

func (ml *MediaList) Unlock() error

Unlock releases ownership of the media list.

type MediaMetaKey

type MediaMetaKey uint

MediaMetaKey uniquely identifies a type of media metadata.

const (
	MediaTitle MediaMetaKey = iota
	MediaArtist
	MediaGenre
	MediaCopyright
	MediaAlbum
	MediaTrackNumber
	MediaDescription
	MediaRating
	MediaDate
	MediaSetting
	MediaURL
	MediaLanguage
	MediaNowPlaying
	MediaPublisher
	MediaEncodedBy
	MediaArtworkURL
	MediaTrackID
	MediaTrackTotal
	MediaDirector
	MediaSeason
	MediaEpisode
	MediaShowName
	MediaActors
	MediaAlbumArtist
	MediaDiscNumber
	MediaDiscTotal
)

Media metadata types.

func (MediaMetaKey) Validate

func (mt MediaMetaKey) Validate() error

Validate checks if the media metadata key is valid.

type MediaParseOption added in v3.0.2

type MediaParseOption uint

MediaParseOption defines different options for parsing media files.

const (
	// Parse media if it is a local file.
	MediaParseLocal MediaParseOption = 0x00

	// Parse media if it is a local or network file.
	MediaParseNetwork MediaParseOption = 0x01

	// Fetch metadata, track information and cover art using local resources.
	MediaFetchLocal MediaParseOption = 0x02

	// Fetch metadata, track information and cover art using network resources.
	MediaFetchNetwork MediaParseOption = 0x04

	// Interact with the user when preparsing media. Set this flag in order to
	// receive a callback if the input media is asking for credentials.
	MediaParseInteract MediaParseOption = 0x08
)

Media parse options.

type MediaParseStatus added in v3.0.2

type MediaParseStatus uint

MediaParseStatus represents the parsing status of a media file.

const (
	MediaParseUnstarted MediaParseStatus = iota
	MediaParseSkipped
	MediaParseFailed
	MediaParseTimeout
	MediaParseDone
)

Media parse statuses.

type MediaScreenOptions added in v3.0.3

type MediaScreenOptions struct {
	// Screen capture area.
	X      int // Left edge coordinate of the subscreen. Default: 0.
	Y      int // Top edge coordinate of the subscreen. Default: 0.
	Width  int // Width of the subscreen. Default: 0 (full screen width).
	Height int // Height of the subscreen. Default: 0 (full screen height).

	// Screen capture frame rate. Default: 0.
	FPS float64

	// Follow the mouse when capturing a subscreen. Default: false.
	FollowMouse bool

	// Mouse cursor image to use. If specified, the cursor will be overlayed
	// on the captured video. Default: "".
	// NOTE: Windows only.
	CursorImage string

	// Optimize the capture by fragmenting the screen in chunks of predefined
	// height (16 might be a good value). Default: 0 (disabled).
	// NOTE: Windows only.
	FragmentSize int
}

MediaScreenOptions provides configuration options for creating media instances from the current computer screen.

type MediaState

type MediaState uint

MediaState represents the state of a media file.

const (
	MediaNothingSpecial MediaState = iota
	MediaOpening
	MediaBuffering
	MediaPlaying
	MediaPaused
	MediaStopped
	MediaEnded
	MediaError
)

Media states.

type MediaStats

type MediaStats struct {
	// Input statistics.
	ReadBytes    int     // Input bytes read.
	InputBitRate float64 // Input bit rate.

	// Demux statistics.
	DemuxReadBytes     int     // Demux bytes read (demuxed data size).
	DemuxBitRate       float64 // Demux bit rate (content bit rate).
	DemuxCorrupted     int     // Demux corruptions (discarded).
	DemuxDiscontinuity int     // Demux discontinuities (dropped).

	// Video output statistics.
	DecodedVideo      int // Number of decoded video blocks.
	DisplayedPictures int // Number of displayed frames.
	LostPictures      int // Number of lost frames.

	// Audio output statistics.
	DecodedAudio       int // Number of decoded audio blocks.
	PlayedAudioBuffers int // Number of played audio buffers.
	LostAudioBuffers   int // Number of lost audio buffers.
}

MediaStats contains playback statistics for a media file.

type MediaSubtitleTrack added in v3.0.7

type MediaSubtitleTrack struct {
	Encoding string // character encoding of the subtitle.
}

MediaSubtitleTrack contains information specific to subtitle media tracks.

type MediaTrack added in v3.0.7

type MediaTrack struct {
	ID      int            // Media track identifier.
	Type    MediaTrackType // Media track type.
	BitRate uint           // Media track bit rate.

	// libVLC representation of the four-character code of the codec used by
	// the media track.
	Codec uint

	// The original four-character code of the codec used by the media track,
	// extracted from the container.
	OriginalCodec uint

	// Codec profile (real audio flavor, MPEG audio layer, H264 profile, etc.).
	// NOTE: Profile values are codec specific.
	Profile int

	// Stream restriction level (resolution, bitrate, codec features, etc.).
	// NOTE: Level values are codec specific.
	Level int

	Language    string // Media track language name.
	Description string // Description of the media track.

	// Type specific information.
	Audio    *MediaAudioTrack
	Video    *MediaVideoTrack
	Subtitle *MediaSubtitleTrack
}

MediaTrack contains information regarding a media track.

func (*MediaTrack) CodecDescription added in v3.0.7

func (mt *MediaTrack) CodecDescription() (string, error)

CodecDescription returns the description of the codec used by the media track.

type MediaTrackDescriptor added in v3.1.1

type MediaTrackDescriptor struct {
	ID          int    // Media track identifier.
	Description string // Description of the media track.
}

MediaTrackDescriptor contains information about a media track.

type MediaTrackType added in v3.0.7

type MediaTrackType int

MediaTrackType represents the type of a media track.

const (
	MediaTrackUnknown MediaTrackType = iota - 1
	MediaTrackAudio
	MediaTrackVideo
	MediaTrackText
)

Media track types.

type MediaType added in v3.0.7

type MediaType uint

MediaType represents the type of a media file.

const (
	MediaTypeUnknown MediaType = iota
	MediaTypeFile
	MediaTypeDirectory
	MediaTypeDisc
	MediaTypeStream
	MediaTypePlaylist
)

MediaTypes.

type MediaVideoTrack added in v3.0.7

type MediaVideoTrack struct {
	Width       uint             // video width.
	Height      uint             // video height.
	Orientation VideoOrientation // video orientation.
	Projection  VideoProjection  // video projection mode.
	Pose        VideoViewpoint   // video initial viewpoint.

	// Aspect ratio information.
	AspectRatioNum uint // aspect ratio numerator.
	AspectRatioDen uint // aspect ratio denominator.

	// Frame rate information.
	FrameRateNum uint // frame rate numerator.
	FrameRateDen uint // frame rate denominator.
}

MediaVideoTrack contains information specific to video media tracks.

type ModuleDescription added in v3.0.4

type ModuleDescription struct {
	Name      string
	ShortName string
	LongName  string
	Help      string
}

ModuleDescription contains information about a libVLC module.

func ListAudioFilters added in v3.0.4

func ListAudioFilters() ([]*ModuleDescription, error)

ListAudioFilters returns the list of available audio filters.

func ListVideoFilters added in v3.0.4

func ListVideoFilters() ([]*ModuleDescription, error)

ListVideoFilters returns the list of available video filters.

type NavigationAction uint

NavigationAction defines actions for navigating menus of VCDs, DVDs and BDs.

const (
	// Activate selected navigation item.
	NavigationActionActivate NavigationAction = iota

	// Move selection up.
	NavigationActionUp

	// Move selection down.
	NavigationActionDown

	// Move selection left.
	NavigationActionLeft

	// Move selection right.
	NavigationActionRight

	// Activate the popup menu.
	NavigationActionPopup
)

Navigation actions.

type PlaybackMode

type PlaybackMode uint

PlaybackMode defines playback modes for a media list.

const (
	Default PlaybackMode = iota
	Loop
	Repeat
)

Playback modes.

func (PlaybackMode) Validate added in v3.1.6

func (pm PlaybackMode) Validate() error

Validate checks if the playback mode valid.

type Player

type Player struct {
	// contains filtered or unexported fields
}

Player is a media player used to play a single media file. For playing media lists (playlists) use ListPlayer instead.

func NewPlayer

func NewPlayer() (*Player, error)

NewPlayer creates an instance of a single-media player.

func (*Player) AspectRatio added in v3.0.8

func (p *Player) AspectRatio() (string, error)

AspectRatio returns the aspect ratio of the current video.

func (*Player) AudioDelay added in v3.1.1

func (p *Player) AudioDelay() (time.Duration, error)

AudioDelay returns the delay of the current audio track, with microsecond precision.

func (*Player) AudioOutputDevice added in v3.1.4

func (p *Player) AudioOutputDevice() (string, error)

AudioOutputDevice returns the name of the current audio output device used by the media player.

NOTE: The initial value for the current audio output device identifier
may not be set or may be an unknown value. Applications should compare
the returned value against the known device identifiers to find the
current audio output device. It is possible for the audio output device
to be changed externally. That may make the method unsuitable to use for
applications which are attempting to track audio device changes.

func (*Player) AudioOutputDevices added in v3.1.4

func (p *Player) AudioOutputDevices() ([]*AudioOutputDevice, error)

AudioOutputDevices returns the list of available devices for the audio output used by the media player.

NOTE: Not all audio outputs support this. An empty list of devices does
not imply that the audio output used by the player does not work.
Some audio output devices in the list might not work in some circumstances.
By default, it is recommended to not specify any explicit audio device.

func (*Player) AudioTrackCount added in v3.1.1

func (p *Player) AudioTrackCount() (int, error)

AudioTrackCount returns the number of audio tracks available in the current media of the player.

func (*Player) AudioTrackDescriptors added in v3.1.1

func (p *Player) AudioTrackDescriptors() ([]*MediaTrackDescriptor, error)

AudioTrackDescriptors returns a descriptor list of the available audio tracks for the current player media.

func (*Player) AudioTrackID added in v3.1.1

func (p *Player) AudioTrackID() (int, error)

AudioTrackID returns the ID of the current audio track of the player.

NOTE: The method returns -1 if there is no active audio track.

func (*Player) Brightness added in v3.1.6

func (p *Player) Brightness() (float64, error)

Brightness returns the brightness set to be used when rendering videos. The returned brightness is a value between 0.0 and 2.0. Default: 1.0.

func (*Player) CanPause added in v3.0.5

func (p *Player) CanPause() bool

CanPause returns true if the media player can be paused.

func (*Player) ChapterCount added in v3.1.5

func (p *Player) ChapterCount() (int, error)

ChapterCount returns the number of chapters in the currently playing media.

NOTE: The method returns -1 if the player does not have a media instance.

func (*Player) ChapterIndex added in v3.1.5

func (p *Player) ChapterIndex() (int, error)

ChapterIndex returns the index of the currently playing media chapter.

NOTE: The method returns -1 if the player does not have a media instance.

func (*Player) Contrast added in v3.1.6

func (p *Player) Contrast() (float64, error)

Contrast returns the contrast set to be used when rendering videos. The returned contrast is a value between 0.0 and 2.0. Default: 1.0.

func (*Player) CursorPosition added in v3.1.4

func (p *Player) CursorPosition() (int, int, error)

CursorPosition returns the X and Y coordinates of the mouse cursor relative to the rendered area of the currently playing video.

NOTE: The coordinates are expressed in terms of the decoded video
resolution, not in terms of pixels on the screen. Either coordinate may
be negative or larger than the corresponding dimension of the video, if
the cursor is outside the rendering area.
The coordinates may be out of date if the pointer is not located on the
video rendering area. libVLC does not track the pointer if it is outside
of the video widget. Also, libVLC does not support multiple cursors.

func (*Player) EnableVideoAdjustments added in v3.1.6

func (p *Player) EnableVideoAdjustments(enable bool) error

EnableVideoAdjustments enables or disables video adjustments. By default, video adjustments are not enabled.

func (*Player) EventManager

func (p *Player) EventManager() (*EventManager, error)

EventManager returns the event manager responsible for the media player.

func (*Player) Gamma added in v3.1.6

func (p *Player) Gamma() (float64, error)

Gamma returns the gamma set to be used when rendering videos. The returned gamma is a value between 0.01 and 10.0. Default: 1.0.

func (*Player) HWND added in v3.0.2

func (p *Player) HWND() (uintptr, error)

HWND returns the handle of the Windows API window the media player is configured to render its video output to, or 0 if no window is set. The window can be set using the SetHWND method.

NOTE: The window handle is returned even if the player is not currently
using it (for instance if it is playing an audio-only input).

func (*Player) Hue added in v3.1.6

func (p *Player) Hue() (float64, error)

Hue returns the hue set to be used when rendering videos. The returned hue is a value between -180.0 and 180.0. Default: 0.0.

func (*Player) IsFullScreen

func (p *Player) IsFullScreen() (bool, error)

IsFullScreen returns the fullscreen status of the player.

func (*Player) IsMuted added in v3.0.8

func (p *Player) IsMuted() (bool, error)

IsMuted returns a boolean value that specifies whether the audio output of the player is muted.

func (*Player) IsPlaying

func (p *Player) IsPlaying() bool

IsPlaying returns a boolean value specifying if the player is currently playing.

func (*Player) IsScrambled added in v3.0.5

func (p *Player) IsScrambled() bool

IsScrambled returns true if the media player is in a scrambled state.

func (*Player) IsSeekable added in v3.0.5

func (p *Player) IsSeekable() bool

IsSeekable returns true if the current media is seekable.

func (*Player) LoadMediaFromPath

func (p *Player) LoadMediaFromPath(path string) (*Media, error)

LoadMediaFromPath loads the media located at the specified path and sets it as the current media of the player.

func (*Player) LoadMediaFromReadSeeker added in v3.0.9

func (p *Player) LoadMediaFromReadSeeker(r io.ReadSeeker) (*Media, error)

LoadMediaFromReadSeeker loads the media from the provided read seeker and sets it as the current media of the player.

func (*Player) LoadMediaFromURL

func (p *Player) LoadMediaFromURL(url string) (*Media, error)

LoadMediaFromURL loads the media located at the specified URL and sets it as the current media of the player.

func (p *Player) Logo() *Logo

Logo returns the logo of the player.

func (*Player) Marquee added in v3.1.6

func (p *Player) Marquee() *Marquee

Marquee returns the marquee of the player.

func (*Player) Media

func (p *Player) Media() (*Media, error)

Media returns the current media of the player, if one exists.

func (*Player) MediaLength

func (p *Player) MediaLength() (int, error)

MediaLength returns media length in milliseconds.

func (*Player) MediaPosition

func (p *Player) MediaPosition() (float32, error)

MediaPosition returns media position as a float percentage between 0.0 and 1.0.

func (*Player) MediaState

func (p *Player) MediaState() (MediaState, error)

MediaState returns the state of the current media.

func (*Player) MediaTime

func (p *Player) MediaTime() (int, error)

MediaTime returns media time in milliseconds.

func (*Player) NSObject added in v3.0.2

func (p *Player) NSObject() (uintptr, error)

NSObject returns the handler of the NSView the media player is configured to render its video output to, or 0 if no view is set. See SetNSObject.

func (*Player) Navigate added in v3.1.5

func (p *Player) Navigate(action NavigationAction) error

Navigate executes the specified action in order to navigate menus of VCDs, DVDs and BDs.

func (*Player) NextChapter added in v3.1.5

func (p *Player) NextChapter() error

NextChapter sets the next chapter to be played, if applicable to the current player media instance.

NOTE: The method has no effect if the current player media has no chapters.

func (*Player) NextFrame added in v3.0.8

func (p *Player) NextFrame() error

NextFrame displays the next video frame, if supported.

func (*Player) Play

func (p *Player) Play() error

Play plays the current media.

func (*Player) PlaybackRate added in v3.0.5

func (p *Player) PlaybackRate() float32

PlaybackRate returns the playback rate of the media player.

NOTE: Depending on the underlying media, the returned rate may be
different from the real playback rate.

func (*Player) PreviousChapter added in v3.1.5

func (p *Player) PreviousChapter() error

PreviousChapter sets the previous chapter to be played, if applicable to the current player media instance.

NOTE: The method has no effect if the current player media has no chapters.

func (*Player) Release

func (p *Player) Release() error

Release destroys the media player instance.

func (*Player) Role added in v3.1.4

func (p *Player) Role() (PlayerRole, error)

Role returns the role of the player.

func (*Player) Saturation added in v3.1.6

func (p *Player) Saturation() (float64, error)

Saturation returns the saturation set to be used when rendering videos. The returned saturation is a value between 0.0 and 3.0. Default: 1.0.

func (*Player) Scale added in v3.0.8

func (p *Player) Scale() (float64, error)

Scale returns the scaling factor of the current video. A scaling factor of zero means the video is configured to fit in the available space.

func (*Player) SetAspectRatio added in v3.0.8

func (p *Player) SetAspectRatio(aspectRatio string) error

SetAspectRatio sets the aspect ratio of the current video (e.g. `16:9`).

NOTE: Invalid aspect ratios are ignored.

func (*Player) SetAudioDelay added in v3.1.1

func (p *Player) SetAudioDelay(d time.Duration) error

SetAudioDelay delays the current audio track according to the specified duration, with microsecond precision. The delay can be either positive (the audio track is played later) or negative (the audio track is played earlier), and it defaults to zero.

NOTE: The audio delay is set to zero each time the player media changes.

func (*Player) SetAudioOutput

func (p *Player) SetAudioOutput(output string) error

SetAudioOutput sets the audio output to be used by the player. Any change will take effect only after playback is stopped and restarted. The audio output cannot be changed while playing.

func (*Player) SetAudioOutputDevice added in v3.1.4

func (p *Player) SetAudioOutputDevice(device, output string) error

SetAudioOutputDevice sets the audio output device to be used by the media player. The list of available devices can be obtained using the Player.AudioOutputDevices method. Pass in an empty string as the `output` parameter in order to move the current audio output to the specified device immediately. This is the recommended usage.

NOTE: The syntax for the `device` parameter depends on the audio output.
Some audio output modules require further parameters.
Due to a design bug in libVLC, the method does not return an error if the
passed in device cannot be set. Use the Player.AudioOutputDevice method
to check if the device has been set.

func (*Player) SetAudioTrack added in v3.1.1

func (p *Player) SetAudioTrack(trackID int) error

SetAudioTrack sets the track identified by the specified ID as the current audio track of the player.

func (*Player) SetBrightness added in v3.1.6

func (p *Player) SetBrightness(brightness float64) error

SetBrightness sets the brightness to be used when rendering videos. The specified brightness must be a value between 0.0 and 2.0.

NOTE: this method has no effect if video adjustments are not enabled. The
adjustments can be enabled using the Player.EnableVideoAdjustments method.

func (*Player) SetChapter added in v3.1.5

func (p *Player) SetChapter(chapterIndex int) error

SetChapter sets the chapter with the specified index to be played, if applicable to the current player media instance.

NOTE: The method has no effect if the current player media has no chapters.

func (*Player) SetContrast added in v3.1.6

func (p *Player) SetContrast(contrast float64) error

SetContrast sets the contrast to be used when rendering videos. The specified contrast must be a value between 0.0 and 2.0.

NOTE: this method has no effect if video adjustments are not enabled. The
adjustments can be enabled using the Player.EnableVideoAdjustments method.

func (*Player) SetDeinterlaceMode added in v3.1.6

func (p *Player) SetDeinterlaceMode(mode DeinterlaceMode) error

SetDeinterlaceMode sets the deinterlace mode to use when rendering videos.

NOTE: pass in `vlc.DeinterlaceModeDisable` to disable deinterlacing.

func (*Player) SetEqualizer added in v3.1.2

func (p *Player) SetEqualizer(e *Equalizer) error

SetEqualizer sets an equalizer for the player. The equalizer can be applied at any time (whether media playback is started or not) and it will be used for subsequently played media instances as well. In order to revert to the default equalizer, pass in `nil` as the equalizer parameter.

func (*Player) SetFullScreen

func (p *Player) SetFullScreen(fullscreen bool) error

SetFullScreen sets the fullscreen state of the media player. Pass in `true` to enable fullscreen, or `false` to disable it.

func (*Player) SetGamma added in v3.1.6

func (p *Player) SetGamma(gamma float64) error

SetGamma sets the gamma to be used when rendering videos. The specified gamma must be a value between 0.01 and 10.0.

NOTE: this method has no effect if video adjustments are not enabled. The
adjustments can be enabled using the Player.EnableVideoAdjustments method.

func (*Player) SetHWND added in v3.0.2

func (p *Player) SetHWND(hwnd uintptr) error

SetHWND sets a Windows API window handle where the media player can render its video output. If libVLC was built without Win32/Win64 API output support, calling this method has no effect.

NOTE: By default, libVLC captures input events on the video rendering area.
Use the SetMouseInput and SetKeyInput methods if you want to handle input
events in your application.

func (*Player) SetHue added in v3.1.6

func (p *Player) SetHue(hue float64) error

SetHue sets the hue to be used when rendering videos. The specified hue must be a value between -180.0 and 180.0.

NOTE: this method has no effect if video adjustments are not enabled. The
adjustments can be enabled using the Player.EnableVideoAdjustments method.

func (*Player) SetKeyInput added in v3.0.2

func (p *Player) SetKeyInput(enable bool) error

SetKeyInput enables or disables key press event handling, according to the libVLC hotkeys configuration. By default, keyboard events are handled by the libVLC video widget.

NOTE: This method works only for X11 and Win32 at the moment.
NOTE: On X11, there can be only one subscriber for key press and mouse
click events per window. If your application has subscribed to these
events for the X window ID of the video widget, then libVLC will not be
able to handle key presses and mouse clicks.

func (*Player) SetMedia

func (p *Player) SetMedia(m *Media) error

SetMedia sets the provided media as the current media of the player.

func (*Player) SetMediaPosition

func (p *Player) SetMediaPosition(pos float32) error

SetMediaPosition sets media position as percentage between 0.0 and 1.0. Some formats and protocols do not support this.

func (*Player) SetMediaTime

func (p *Player) SetMediaTime(t int) error

SetMediaTime sets the media time in milliseconds. Some formats and protocols do not support this.

func (*Player) SetMouseInput added in v3.0.2

func (p *Player) SetMouseInput(enable bool) error

SetMouseInput enables or disables mouse click event handling. By default, mouse events are handled by the libVLC video widget. This is needed for DVD menus to work, as well as for a few video filters, such as "puzzle".

NOTE: This method works only for X11 and Win32 at the moment.
NOTE: On X11, there can be only one subscriber for key press and mouse
click events per window. If your application has subscribed to these
events for the X window ID of the video widget, then libVLC will not be
able to handle key presses and mouse clicks.

func (*Player) SetMute added in v3.0.8

func (p *Player) SetMute(mute bool) error

SetMute mutes or unmutes the audio output of the player.

NOTE: If there is no active audio playback stream, the mute status might
not be available. If digital pass-through (S/PDIF, HDMI, etc.) is in use,
muting may not be applicable.
Some audio output plugins do not support muting.

func (*Player) SetNSObject added in v3.0.2

func (p *Player) SetNSObject(drawable uintptr) error

SetNSObject sets a NSObject handler where the media player can render its video output. Use the vout called "macosx". The object can be a NSView or a NSObject following the VLCVideoViewEmbedding protocol.

@protocol VLCVideoViewEmbedding <NSObject>
- (void)addVoutSubview:(NSView *)view;
- (void)removeVoutSubview:(NSView *)view;
@end

func (*Player) SetPause

func (p *Player) SetPause(pause bool) error

SetPause sets the pause state of the media player. Pass in `true` to pause the current media, or `false` to resume it.

func (*Player) SetPlaybackRate added in v3.0.5

func (p *Player) SetPlaybackRate(rate float32) error

SetPlaybackRate sets the playback rate of the media player.

NOTE: Depending on the underlying media, changing the playback rate
might not be supported.

func (*Player) SetRenderer added in v3.1.0

func (p *Player) SetRenderer(r *Renderer) error

SetRenderer sets a renderer for the player media (e.g. Chromecast).

NOTE: This method must be called before starting media playback in order
to take effect.

func (*Player) SetRole added in v3.1.4

func (p *Player) SetRole(role PlayerRole) error

SetRole sets the role of the player.

func (*Player) SetSaturation added in v3.1.6

func (p *Player) SetSaturation(saturation float64) error

SetSaturation sets the saturation to be used when rendering videos. The specified saturation must be a value between 0.0 and 3.0.

NOTE: this method has no effect if video adjustments are not enabled. The
adjustments can be enabled using the Player.EnableVideoAdjustments method.

func (*Player) SetScale added in v3.0.8

func (p *Player) SetScale(scale float64) error

SetScale sets the scaling factor of the current video. The scaling factor is the ratio of the number of pixels displayed on the screen to the number of pixels in the original decoded video. A scaling factor of zero adjusts the video to fit in the available space.

NOTE: Not all video outputs support scaling.

func (*Player) SetStereoMode added in v3.1.2

func (p *Player) SetStereoMode(mode StereoMode) error

SetStereoMode sets the stereo mode of the audio output used by the player.

NOTE: The audio output might not support all stereo modes.

func (*Player) SetSubtitleDelay added in v3.1.1

func (p *Player) SetSubtitleDelay(d time.Duration) error

SetSubtitleDelay delays the current subtitle track according to the specified duration, with microsecond precision. The delay can be either positive (the subtitle track is displayed later) or negative (the subtitle track is displayed earlier), and it defaults to zero.

NOTE: The subtitle delay is set to zero each time the player media changes.

func (*Player) SetSubtitleTrack added in v3.1.1

func (p *Player) SetSubtitleTrack(trackID int) error

SetSubtitleTrack sets the track identified by the specified ID as the current subtitle track of the player.

func (*Player) SetTitle added in v3.1.5

func (p *Player) SetTitle(titleIndex int) error

SetTitle sets the title with the specified index to be played, if applicable to the current player media instance.

NOTE: The method has no effect if the current player media has no titles.

func (*Player) SetTitleDisplayMode added in v3.1.5

func (p *Player) SetTitleDisplayMode(position Position, timeout time.Duration) error

SetTitleDisplayMode configures if and how the video title will be displayed. Pass in `vlc.PositionDisable` in order to prevent the video title from being displayed. The title is displayed after the specified `timeout`.

func (*Player) SetVideoTrack added in v3.1.1

func (p *Player) SetVideoTrack(trackID int) error

SetVideoTrack sets the track identified by the specified ID as the current video track of the player.

func (*Player) SetVolume

func (p *Player) SetVolume(volume int) error

SetVolume sets the volume of the player.

func (*Player) SetXWindow

func (p *Player) SetXWindow(windowID uint32) error

SetXWindow sets an X Window System drawable where the media player can render its video output. The call takes effect when the playback starts. If it is already started, it might need to be stopped before changes apply. If libVLC was built without X11 output support, calling this method has no effect.

NOTE: By default, libVLC captures input events on the video rendering area.
Use the SetMouseInput and SetKeyInput methods if you want to handle input
events in your application. By design, the X11 protocol delivers input
events to only one recipient.

func (*Player) StereoMode added in v3.1.2

func (p *Player) StereoMode() (StereoMode, error)

StereoMode returns the stereo mode of the audio output used by the player.

func (*Player) Stop

func (p *Player) Stop() error

Stop cancels the currently playing media, if there is one.

func (*Player) SubtitleDelay added in v3.1.1

func (p *Player) SubtitleDelay() (time.Duration, error)

SubtitleDelay returns the delay of the current subtitle track, with microsecond precision.

func (*Player) SubtitleTrackCount added in v3.1.1

func (p *Player) SubtitleTrackCount() (int, error)

SubtitleTrackCount returns the number of subtitle tracks available in the current media of the player.

func (*Player) SubtitleTrackDescriptors added in v3.1.1

func (p *Player) SubtitleTrackDescriptors() ([]*MediaTrackDescriptor, error)

SubtitleTrackDescriptors returns a descriptor list of the available subtitle tracks for the current player media.

func (*Player) SubtitleTrackID added in v3.1.1

func (p *Player) SubtitleTrackID() (int, error)

SubtitleTrackID returns the ID of the current subtitle track of the player.

NOTE: The method returns -1 if there is no active subtitle track.

func (*Player) TakeSnapshot added in v3.1.5

func (p *Player) TakeSnapshot(outputPath string, width, height uint) error

TakeSnapshot takes a snapshot of the current video and saves it at the specified output path. If the specified width is 0, the snapshot width will be calculated based on the specified height in order to preserve the original aspect ratio. Similarly, if the specified height is 0, the snapshot height will be calculated based on the specified width in order to preserve the original aspect ratio. If both the width and height values are 0, the original video size dimensions are used for the snapshot.

func (*Player) TitleChapterCount added in v3.1.5

func (p *Player) TitleChapterCount(titleIndex int) (int, error)

TitleChapterCount returns the number of chapters available within the media title with the specified index.

NOTE: The method returns -1 if the player does not have a media instance.

func (*Player) TitleChapters added in v3.1.5

func (p *Player) TitleChapters(titleIndex int) ([]*ChapterInfo, error)

TitleChapters returns the list of chapters available within the media title with the specified index.

NOTE: The method returns -1 if the player does not have a media instance.

func (*Player) TitleCount added in v3.1.5

func (p *Player) TitleCount() (int, error)

TitleCount returns the number of titles in the currently playing media.

NOTE: The method returns -1 if the player does not have a media instance.

func (*Player) TitleIndex added in v3.1.5

func (p *Player) TitleIndex() (int, error)

TitleIndex returns the index of the currently playing media title.

NOTE: The method returns -1 if the player does not have a media instance.

func (*Player) Titles added in v3.1.5

func (p *Player) Titles() ([]*TitleInfo, error)

Titles returns the list of titles available within the currently playing media instance, if any. DVD and Blu-ray formats have their content split into titles.

func (*Player) ToggleFullScreen

func (p *Player) ToggleFullScreen() error

ToggleFullScreen toggles the fullscreen status of the player, on non-embedded video outputs.

func (*Player) ToggleMute added in v3.0.8

func (p *Player) ToggleMute() error

ToggleMute mutes or unmutes the audio output of the player, depending on the current status.

NOTE: If there is no active audio playback stream, the mute status might
not be available. If digital pass-through (S/PDIF, HDMI, etc.) is in use,
muting may not be applicable.
Some audio output plugins do not support muting.

func (*Player) TogglePause

func (p *Player) TogglePause() error

TogglePause pauses or resumes the player, depending on its current status. Calling this method has no effect if there is no media.

func (*Player) UpdateVideoViewpoint added in v3.1.4

func (p *Player) UpdateVideoViewpoint(vp *VideoViewpoint, absolute bool) error

UpdateVideoViewpoint updates the viewpoint of the current media of the player. This method only works with 360° videos. If `absolute` is true, the passed in viewpoint replaces the current one. Otherwise, the current viewpoint is updated using the specified viewpoint values.

NOTE: It is safe to call this method before media playback is started.

func (*Player) VideoAdjustmentsEnabled added in v3.1.6

func (p *Player) VideoAdjustmentsEnabled(enable bool) (bool, error)

VideoAdjustmentsEnabled returns true if video adjustments are enabled. By default, video adjustments are not enabled.

func (*Player) VideoDimensions added in v3.1.4

func (p *Player) VideoDimensions() (uint, uint, error)

VideoDimensions returns the width and height of the current media of the player, in pixels.

NOTE: The dimensions can only be obtained for parsed media instances.
Either play the media or call one of the media parsing methods first.

func (*Player) VideoOutputCount added in v3.0.5

func (p *Player) VideoOutputCount() int

VideoOutputCount returns the number of video outputs the media player has.

func (*Player) VideoTrackCount added in v3.1.1

func (p *Player) VideoTrackCount() (int, error)

VideoTrackCount returns the number of video tracks available in the current media of the player.

func (*Player) VideoTrackDescriptors added in v3.1.1

func (p *Player) VideoTrackDescriptors() ([]*MediaTrackDescriptor, error)

VideoTrackDescriptors returns a descriptor list of the available video tracks for the current player media.

func (*Player) VideoTrackID added in v3.1.1

func (p *Player) VideoTrackID() (int, error)

VideoTrackID returns the ID of the current video track of the player.

NOTE: The method returns -1 if there is no active video track.

func (*Player) Volume

func (p *Player) Volume() (int, error)

Volume returns the volume of the player.

func (*Player) WillPlay

func (p *Player) WillPlay() bool

WillPlay returns true if the current media is not in a finished or error state.

func (*Player) XWindow added in v3.0.2

func (p *Player) XWindow() (uint32, error)

XWindow returns the identifier of the X window the media player is configured to render its video output to, or 0 if no window is set. The window can be set using the SetXWindow method.

NOTE: The window identifier is returned even if the player is not
currently using it (for instance if it is playing an audio-only input).

type PlayerRole added in v3.1.4

type PlayerRole uint

PlayerRole defines the intended usage of a media player.

const (
	// No role has been set.
	PlayerRoleNone PlayerRole = iota

	// Music (or radio) playback.
	PlayerRoleMusic

	// Video playback.
	PlayerRoleVideo

	// Speech, real-time communication.
	PlayerRoleCommunication

	// Video games.
	PlayerRoleGame

	// User interaction feedback.
	PlayerRoleNotification

	// Embedded animations (e.g. in a web page).
	PlayerRoleAnimation

	// Editing or production.
	PlayerRoleProduction

	// Accessibility.
	PlayerRoleAccessibility

	// Testing.
	PlayerRoleTest
)

Player roles.

type Position added in v3.1.5

type Position int

Position defines locations of entities relative to a container.

const (
	PositionDisable Position = iota - 1
	PositionCenter
	PositionLeft
	PositionRight
	PositionTop
	PositionTopLeft
	PositionTopRight
	PositionBottom
	PositionBottomLeft
	PositionBottomRight
)

Positions.

type Renderer added in v3.1.0

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer represents a medium capable of rendering media files.

func (*Renderer) Flags added in v3.1.0

func (r *Renderer) Flags() (*RendererFlags, error)

Flags returns the flags of the renderer.

func (*Renderer) IconURI added in v3.1.0

func (r *Renderer) IconURI() (string, error)

IconURI returns the icon URI of the renderer.

func (*Renderer) Name added in v3.1.0

func (r *Renderer) Name() (string, error)

Name returns the name of the renderer.

func (*Renderer) Type added in v3.1.0

func (r *Renderer) Type() (RendererType, error)

Type returns the type of the renderer.

type RendererDiscoverer added in v3.1.0

type RendererDiscoverer struct {
	// contains filtered or unexported fields
}

RendererDiscoverer represents a renderer discovery service. Discovery services use different discovery protocols (e.g. mDNS) in order to find available media renderers (e.g. Chromecast).

func NewRendererDiscoverer added in v3.1.0

func NewRendererDiscoverer(name string) (*RendererDiscoverer, error)

NewRendererDiscoverer instantiates the renderer discovery service identified by the specified name. Use the ListRendererDiscoverers method to obtain the list of available discovery service descriptors.

NOTE: Call the Release method on the discovery service instance in
order to free the allocated resources.

func (*RendererDiscoverer) Release added in v3.1.0

func (rd *RendererDiscoverer) Release() error

Release stops and destroys the renderer discovery service along with all the renderers found by the instance.

func (*RendererDiscoverer) Start added in v3.1.0

Start starts the renderer discovery service and reports discovery events through the specified callback function.

NOTE: The Stop and Release methods should not be called from the callback
function. Doing so will result in undefined behavior.

func (*RendererDiscoverer) Stop added in v3.1.0

func (rd *RendererDiscoverer) Stop() error

Stop stops the discovery service.

type RendererDiscovererDescriptor added in v3.1.0

type RendererDiscovererDescriptor struct {
	Name     string
	LongName string
}

RendererDiscovererDescriptor contains information about a renderer discovery service. Pass the `Name` field to the NewRendererDiscoverer method in order to create a new discovery service instance.

func ListRendererDiscoverers added in v3.1.0

func ListRendererDiscoverers() ([]*RendererDiscovererDescriptor, error)

ListRendererDiscoverers returns a list of descriptors identifying the available renderer discovery services.

type RendererDiscoveryCallback added in v3.1.0

type RendererDiscoveryCallback func(Event, *Renderer)

RendererDiscoveryCallback is used by renderer discovery services to report discovery events.

The available events are:

  • RendererDiscovererItemAdded
  • RendererDiscovererItemDeleted

type RendererFlags added in v3.1.0

type RendererFlags struct {
	AudioEnabled bool
	VideoEnabled bool
}

RendererFlags contains flags describing a renderer (e.g. capabilities).

type RendererType added in v3.1.0

type RendererType string

RendererType represents the type of a renderer.

const (
	RendererChromecast RendererType = "chromecast"
)

Renderer types.

type StereoMode added in v3.1.2

type StereoMode int

StereoMode defines stereo modes which can be used by an audio output.

const (
	StereoModeError StereoMode = iota - 1
	StereoModeNotSet
	StereoModeNormal
	StereoModeReverse
	StereoModeLeft
	StereoModeRight
	StereoModeDolbySurround
	StereoModeHeadphones
)

Stereo modes.

type TitleFlag added in v3.1.5

type TitleFlag uint

TitleFlag defines properties of media titles. DVD and Blu-ray formats have their content split into titles.

const (
	// Title item is a menu.
	TitleFlagMenu TitleFlag = iota + 0x01

	// Title item content is interactive.
	TitleFlagInteractive
)

Title flags.

type TitleInfo added in v3.1.5

type TitleInfo struct {
	Name     string        // Name of the title.
	Duration time.Duration // Duration of the title.
	Flags    TitleFlag     // Flags describing title properties.
}

TitleInfo contains information regarding a media title. DVD and Blu-ray formats have their content split into titles.

type VersionInfo

type VersionInfo struct {
	Major uint
	Minor uint
	Patch uint
	Extra uint
}

VersionInfo contains details regarding the version of the libVLC module.

func Version

func Version() VersionInfo

Version returns details regarding the version of the libVLC module.

func (VersionInfo) Changeset added in v3.0.4

func (v VersionInfo) Changeset() string

Changeset returns the changeset identifier for the current libVLC build.

func (VersionInfo) Compiler added in v3.0.4

func (v VersionInfo) Compiler() string

Compiler returns information regarding the compiler used to build libVLC.

func (VersionInfo) Runtime added in v3.0.4

func (v VersionInfo) Runtime() string

Runtime returns the runtime version of libVLC, usually including the codename of the build.

NOTE: Due to binary backward compatibility, the runtime version may be
more recent than the build version.

func (VersionInfo) String

func (v VersionInfo) String() string

String returns a string representation of the version.

type VideoOrientation added in v3.0.7

type VideoOrientation int

VideoOrientation represents the orientation of a video media track.

const (
	// Normal.
	OrientationTopLeft VideoOrientation = iota

	// Flipped horizontally.
	OrientationTopRight

	// Flipped vertically.
	OrientationBottomLeft

	// Rotated 180 degrees.
	OrientationBottomRight

	// Transposed.
	OrientationLeftTop

	// Rotated 90 degrees anti-clockwise.
	OrientationLeftBottom

	// Rotated 90 degrees clockwise.
	OrientationRightTop

	// Anti-transposed.
	OrientationRightBottom
)

Video orientations.

type VideoProjection added in v3.0.7

type VideoProjection int

VideoProjection represents the projection mode of a video media track.

const (
	ProjectionRectangular           VideoProjection = 0
	ProjectionEquirectangular       VideoProjection = 1
	ProjectionCubemapLayoutStandard VideoProjection = 0x100
)

Video projections.

type VideoViewpoint added in v3.0.7

type VideoViewpoint struct {
	Yaw   float64 // Viewpoint yaw in degrees [-180-180].
	Pitch float64 // Viewpoint pitch in degrees [-90-90].
	Roll  float64 // Viewpoint roll in degrees [-180-180].
	FOV   float64 // Viewpoint field of view in degrees [0-180]. Default: 80.
}

VideoViewpoint contains viewpoint information for a video media track.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL