vlc

package module
Version: v2.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: MIT Imports: 11 Imported by: 12

Documentation

Overview

Package vlc provides Golang bindings for libVLC version 2.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 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 not initialized")
	ErrPlayerSetEqualizer   = errors.New("could not set player equalizer")
)

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 not initialized")
	ErrMediaListCreate         = errors.New("could not create media list")
	ErrMediaListNotFound       = errors.New("could not find media list")
	ErrMediaListNotInitialized = errors.New("media list not initialized")
	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")
)

Media errors.

View Source
var (
	ErrMediaTrackNotInitialized = errors.New("media track 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")
)

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")
	ErrFilterListMissing            = errors.New("could not get filter list")
	ErrStereoModeSet                = errors.New("could not set stereo mode")
	ErrVideoSnapshot                = errors.New("could not take video snapshot")
	ErrCursorPositionMissing        = errors.New("could not get cursor position")
)

Audio/Video 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.

Functions

func EqualizerBandCount added in v2.1.2

func EqualizerBandCount() uint

EqualizerBandCount returns the number of distinct equalizer frequency bands.

func EqualizerBandFrequencies added in v2.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 v2.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 v2.1.2

func EqualizerPresetCount() uint

EqualizerPresetCount returns the number of available equalizer presets.

func EqualizerPresetName added in v2.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 v2.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 v2.0.4

func SetAppID(id, version, icon string) error

SetAppID sets metadata for identifying the application.

func SetAppName added in v2.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 v2.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 v2.1.3

type AudioOutputDevice struct {
	Name        string
	Description string
}

AudioOutputDevice contains information regarding an audio output device.

func ListAudioOutputDevices added in v2.1.3

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 Equalizer added in v2.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 v2.1.2

func NewEqualizer() (*Equalizer, error)

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

func NewEqualizerFromPreset added in v2.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 v2.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 v2.1.2

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

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

func (*Equalizer) Release added in v2.1.2

func (e *Equalizer) Release() error

Release destroys the equalizer instance.

func (*Equalizer) SetAmpValueAtIndex added in v2.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 v2.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 v2.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) 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 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 NewMediaFromScreen added in v2.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 v2.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 v2.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.

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.

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.

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 v2.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 v2.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) SubItems added in v2.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 v2.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) UserData added in v2.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 v2.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 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) 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 v2.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 v2.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 v2.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) 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 MediaScreenOptions added in v2.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 value: 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 v2.0.7

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

MediaSubtitleTrack contains information specific to subtitle media tracks.

type MediaTrack added in v2.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.

type MediaTrackDescriptor added in v2.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 v2.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 MediaVideoTrack added in v2.0.7

type MediaVideoTrack struct {
	Width  uint // video width.
	Height uint // video height.

	// 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 v2.0.4

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

ModuleDescription contains information about a libVLC module.

func ListAudioFilters added in v2.0.4

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

ListAudioFilters returns the list of available audio filters.

func ListVideoFilters added in v2.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
)

Navigation actions.

type PlaybackMode

type PlaybackMode uint

PlaybackMode defines playback modes for a media list.

const (
	Default PlaybackMode = iota
	Loop
	Repeat
)

Playback modes.

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 v2.0.8

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

AspectRatio returns the aspect ratio of the current video.

func (*Player) AudioDelay added in v2.1.1

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

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

func (*Player) AudioOutputDevices added in v2.1.3

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 v2.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 v2.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 v2.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) CanPause added in v2.0.5

func (p *Player) CanPause() bool

CanPause returns true if the media player can be paused.

func (*Player) ChapterCount added in v2.1.4

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 v2.1.4

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) CursorPosition added in v2.1.3

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) EventManager

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

EventManager returns the event manager responsible for the media player.

func (*Player) HWND added in v2.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) IsFullScreen

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

IsFullScreen returns the fullscreen status of the player.

func (*Player) IsMuted added in v2.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 v2.0.5

func (p *Player) IsScrambled() bool

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

func (*Player) IsSeekable added in v2.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) 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 (*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 v2.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 v2.1.4

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 v2.1.4

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 v2.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 v2.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 v2.1.4

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) Scale added in v2.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 v2.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 v2.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 v2.1.3

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: Passing an empty string as the `output` parameter is only supported
for libVLC 2.2.0 or later.
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.

func (*Player) SetAudioTrack added in v2.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) SetChapter added in v2.1.4

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) SetEqualizer added in v2.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) SetHWND added in v2.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) SetKeyInput added in v2.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 v2.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 v2.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 v2.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 v2.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) SetScale added in v2.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 v2.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 v2.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 v2.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 v2.1.4

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 v2.1.4

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 v2.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 v2.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 v2.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 v2.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 v2.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 v2.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 v2.1.4

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 v2.1.4

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) TitleCount added in v2.1.4

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 v2.1.4

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) ToggleFullScreen

func (p *Player) ToggleFullScreen() error

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

func (*Player) ToggleMute added in v2.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) VideoDimensions added in v2.1.3

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 v2.0.5

func (p *Player) VideoOutputCount() int

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

func (*Player) VideoTrackCount added in v2.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 v2.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 v2.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 v2.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 Position added in v2.1.4

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 StereoMode added in v2.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
)

Stereo modes.

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 v2.0.4

func (v VersionInfo) Changeset() string

Changeset returns the changeset identifier for the current libVLC build.

func (VersionInfo) Compiler added in v2.0.4

func (v VersionInfo) Compiler() string

Compiler returns information regarding the compiler used to build libVLC.

func (VersionInfo) Runtime added in v2.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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL