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
- Variables
- func EqualizerBandCount() uint
- func EqualizerBandFrequencies() []float64
- func EqualizerBandFrequency(index uint) float64
- func EqualizerPresetCount() uint
- func EqualizerPresetName(index uint) string
- func EqualizerPresetNames() []string
- func Init(args ...string) error
- func Release() error
- func SetAppID(id, version, icon string) error
- func SetAppName(name, userAgent string) error
- func StartUserInterface(name string) error
- type AudioOutput
- type AudioOutputDevice
- type ChapterInfo
- type Equalizer
- type Event
- type EventCallback
- type EventID
- type EventManager
- type ListPlayer
- func (lp *ListPlayer) EventManager() (*EventManager, error)
- func (lp *ListPlayer) IsPlaying() bool
- func (lp *ListPlayer) MediaList() *MediaList
- func (lp *ListPlayer) MediaState() (MediaState, error)
- func (lp *ListPlayer) Play() error
- func (lp *ListPlayer) PlayAtIndex(index uint) error
- func (lp *ListPlayer) PlayItem(m *Media) error
- func (lp *ListPlayer) PlayNext() error
- func (lp *ListPlayer) PlayPrevious() error
- func (lp *ListPlayer) Player() (*Player, error)
- func (lp *ListPlayer) Release() error
- func (lp *ListPlayer) SetMediaList(ml *MediaList) error
- func (lp *ListPlayer) SetPause(pause bool) error
- func (lp *ListPlayer) SetPlaybackMode(mode PlaybackMode) error
- func (lp *ListPlayer) SetPlayer(player *Player) error
- func (lp *ListPlayer) Stop() error
- func (lp *ListPlayer) TogglePause() error
- type Media
- func (m *Media) AddOptions(options ...string) error
- func (m *Media) Duplicate() (*Media, error)
- func (m *Media) Duration() (time.Duration, error)
- func (m *Media) EventManager() (*EventManager, error)
- func (m *Media) IsParsed() (bool, error)
- func (m *Media) Location() (string, error)
- func (m *Media) Meta(key MediaMetaKey) (string, error)
- func (m *Media) Parse() error
- func (m *Media) ParseAsync() error
- func (m *Media) ParseStatus() (MediaParseStatus, error)
- func (m *Media) ParseWithOptions(timeout int, opts ...MediaParseOption) error
- func (m *Media) Release() error
- func (m *Media) SaveMeta() error
- func (m *Media) SetMeta(key MediaMetaKey, val string) error
- func (m *Media) SetUserData(userData interface{}) error
- func (m *Media) State() (MediaState, error)
- func (m *Media) Stats() (*MediaStats, error)
- func (m *Media) StopParse() error
- func (m *Media) SubItems() (*MediaList, error)
- func (m *Media) Tracks() ([]*MediaTrack, error)
- func (m *Media) Type() (MediaType, error)
- func (m *Media) UserData() (interface{}, error)
- type MediaAudioTrack
- type MediaDiscoverer
- type MediaDiscovererDescriptor
- type MediaDiscoveryCallback
- type MediaDiscoveryCategory
- type MediaList
- func (ml *MediaList) AddMedia(m *Media) error
- func (ml *MediaList) AddMediaFromPath(path string) error
- func (ml *MediaList) AddMediaFromReadSeeker(r io.ReadSeeker) error
- func (ml *MediaList) AddMediaFromURL(url string) error
- func (ml *MediaList) AssociateMedia(m *Media) error
- func (ml *MediaList) AssociatedMedia() (*Media, error)
- func (ml *MediaList) Count() (int, error)
- func (ml *MediaList) EventManager() (*EventManager, error)
- func (ml *MediaList) IndexOfMedia(m *Media) (int, error)
- func (ml *MediaList) InsertMedia(m *Media, index uint) error
- func (ml *MediaList) InsertMediaFromPath(path string, index uint) error
- func (ml *MediaList) InsertMediaFromReadSeeker(r io.ReadSeeker, index uint) error
- func (ml *MediaList) InsertMediaFromURL(url string, index uint) error
- func (ml *MediaList) IsReadOnly() (bool, error)
- func (ml *MediaList) Lock() error
- func (ml *MediaList) MediaAtIndex(index uint) (*Media, error)
- func (ml *MediaList) Release() error
- func (ml *MediaList) RemoveMediaAtIndex(index uint) error
- func (ml *MediaList) Unlock() error
- type MediaMetaKey
- type MediaParseOption
- type MediaParseStatus
- type MediaScreenOptions
- type MediaState
- type MediaStats
- type MediaSubtitleTrack
- type MediaTrack
- type MediaTrackDescriptor
- type MediaTrackType
- type MediaType
- type MediaVideoTrack
- type ModuleDescription
- type NavigationAction
- type PlaybackMode
- type Player
- func (p *Player) AspectRatio() (string, error)
- func (p *Player) AudioDelay() (time.Duration, error)
- func (p *Player) AudioOutputDevice() (string, error)
- func (p *Player) AudioOutputDevices() ([]*AudioOutputDevice, error)
- func (p *Player) AudioTrackCount() (int, error)
- func (p *Player) AudioTrackDescriptors() ([]*MediaTrackDescriptor, error)
- func (p *Player) AudioTrackID() (int, error)
- func (p *Player) CanPause() bool
- func (p *Player) ChapterCount() (int, error)
- func (p *Player) ChapterIndex() (int, error)
- func (p *Player) CursorPosition() (int, int, error)
- func (p *Player) EventManager() (*EventManager, error)
- func (p *Player) HWND() (uintptr, error)
- func (p *Player) IsFullScreen() (bool, error)
- func (p *Player) IsMuted() (bool, error)
- func (p *Player) IsPlaying() bool
- func (p *Player) IsScrambled() bool
- func (p *Player) IsSeekable() bool
- func (p *Player) LoadMediaFromPath(path string) (*Media, error)
- func (p *Player) LoadMediaFromReadSeeker(r io.ReadSeeker) (*Media, error)
- func (p *Player) LoadMediaFromURL(url string) (*Media, error)
- func (p *Player) Media() (*Media, error)
- func (p *Player) MediaLength() (int, error)
- func (p *Player) MediaPosition() (float32, error)
- func (p *Player) MediaState() (MediaState, error)
- func (p *Player) MediaTime() (int, error)
- func (p *Player) NSObject() (uintptr, error)
- func (p *Player) Navigate(action NavigationAction) error
- func (p *Player) NextChapter() error
- func (p *Player) NextFrame() error
- func (p *Player) Play() error
- func (p *Player) PlaybackRate() float32
- func (p *Player) PreviousChapter() error
- func (p *Player) Release() error
- func (p *Player) Role() (PlayerRole, error)
- func (p *Player) Scale() (float64, error)
- func (p *Player) SetAspectRatio(aspectRatio string) error
- func (p *Player) SetAudioDelay(d time.Duration) error
- func (p *Player) SetAudioOutput(output string) error
- func (p *Player) SetAudioOutputDevice(device, output string) error
- func (p *Player) SetAudioTrack(trackID int) error
- func (p *Player) SetChapter(chapterIndex int) error
- func (p *Player) SetEqualizer(e *Equalizer) error
- func (p *Player) SetFullScreen(fullscreen bool) error
- func (p *Player) SetHWND(hwnd uintptr) error
- func (p *Player) SetKeyInput(enable bool) error
- func (p *Player) SetMedia(m *Media) error
- func (p *Player) SetMediaPosition(pos float32) error
- func (p *Player) SetMediaTime(t int) error
- func (p *Player) SetMouseInput(enable bool) error
- func (p *Player) SetMute(mute bool) error
- func (p *Player) SetNSObject(drawable uintptr) error
- func (p *Player) SetPause(pause bool) error
- func (p *Player) SetPlaybackRate(rate float32) error
- func (p *Player) SetRenderer(r *Renderer) error
- func (p *Player) SetRole(role PlayerRole) error
- func (p *Player) SetScale(scale float64) error
- func (p *Player) SetStereoMode(mode StereoMode) error
- func (p *Player) SetSubtitleDelay(d time.Duration) error
- func (p *Player) SetSubtitleTrack(trackID int) error
- func (p *Player) SetTitle(titleIndex int) error
- func (p *Player) SetTitleDisplayMode(position Position, timeout time.Duration) error
- func (p *Player) SetVideoTrack(trackID int) error
- func (p *Player) SetVolume(volume int) error
- func (p *Player) SetXWindow(windowID uint32) error
- func (p *Player) StereoMode() (StereoMode, error)
- func (p *Player) Stop() error
- func (p *Player) SubtitleDelay() (time.Duration, error)
- func (p *Player) SubtitleTrackCount() (int, error)
- func (p *Player) SubtitleTrackDescriptors() ([]*MediaTrackDescriptor, error)
- func (p *Player) SubtitleTrackID() (int, error)
- func (p *Player) TakeSnapshot(outputPath string, width, height uint) error
- func (p *Player) TitleChapterCount(titleIndex int) (int, error)
- func (p *Player) TitleChapters(titleIndex int) ([]*ChapterInfo, error)
- func (p *Player) TitleCount() (int, error)
- func (p *Player) TitleIndex() (int, error)
- func (p *Player) Titles() ([]*TitleInfo, error)
- func (p *Player) ToggleFullScreen() error
- func (p *Player) ToggleMute() error
- func (p *Player) TogglePause() error
- func (p *Player) UpdateVideoViewpoint(vp *VideoViewpoint, absolute bool) error
- func (p *Player) VideoDimensions() (uint, uint, error)
- func (p *Player) VideoOutputCount() int
- func (p *Player) VideoTrackCount() (int, error)
- func (p *Player) VideoTrackDescriptors() ([]*MediaTrackDescriptor, error)
- func (p *Player) VideoTrackID() (int, error)
- func (p *Player) Volume() (int, error)
- func (p *Player) WillPlay() bool
- func (p *Player) XWindow() (uint32, error)
- type PlayerRole
- type Position
- type Renderer
- type RendererDiscoverer
- type RendererDiscovererDescriptor
- type RendererDiscoveryCallback
- type RendererFlags
- type RendererType
- type StereoMode
- type TitleFlag
- type TitleInfo
- type VersionInfo
- type VideoOrientation
- type VideoProjection
- type VideoViewpoint
Constants ¶
const ( MediaListViewItemAdded = 0x300 + iota MediaListViewWillAddItem MediaListViewItemDeleted MediaListViewWillDeleteItem )
Deprecated events.
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 ¶
var ( ErrModuleInitialize = errors.New("could not initialize module") ErrModuleNotInitialized = errors.New("module not initialized") ErrUserInterfaceStart = errors.New("could not start user interface") )
Module errors.
var ( ErrPlayerCreate = errors.New("could not create player") ErrPlayerNotInitialized = errors.New("player not initialized") 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.
var ( ErrListPlayerCreate = errors.New("could not create list player") ErrListPlayerNotInitialized = errors.New("list player not initialized") )
List player errors.
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") ErrMediaParse = errors.New("could not parse media") )
Media errors.
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.
var ( ErrMissingEventManager = errors.New("could not get event manager instance") ErrInvalidEventCallback = errors.New("invalid event callback") )
Event manager errors.
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.
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.
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.
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 ¶
func EqualizerBandCount() uint
EqualizerBandCount returns the number of distinct equalizer frequency bands.
func EqualizerBandFrequencies ¶
func EqualizerBandFrequencies() []float64
EqualizerBandFrequencies returns the frequencies of all available equalizer bands, sorted by their indices in ascending order.
func EqualizerBandFrequency ¶
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 ¶
func EqualizerPresetCount() uint
EqualizerPresetCount returns the number of available equalizer presets.
func EqualizerPresetName ¶
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 ¶
func EqualizerPresetNames() []string
EqualizerPresetNames returns the names of all available equalizer presets, sorted by their indices in ascending order.
func Init ¶
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 SetAppName ¶
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 ¶
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 ¶
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 ¶
AudioOutputDevice contains information regarding an audio output device.
func ListAudioOutputDevices ¶
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 ¶
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 Equalizer ¶
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 ¶
NewEqualizer returns a new equalizer with all frequency values set to zero.
func NewEqualizerFromPreset ¶
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 ¶
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 ¶
PreampValue returns the pre-amplification value of the equalizer in Hz.
func (*Equalizer) SetAmpValueAtIndex ¶
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 ¶
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 ( // 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 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) PlayAtIndex ¶
func (lp *ListPlayer) PlayAtIndex(index uint) error
PlayAtIndex plays the media at the specified index from the current media list.
func (*ListPlayer) PlayItem ¶
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 ¶
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 Media ¶
type Media struct {
// contains filtered or unexported fields
}
Media is an abstract representation of a playable media file.
func NewMediaFromPath ¶
NewMediaFromPath creates a new media instance based on the media located at the specified path.
func NewMediaFromReadSeeker ¶
func NewMediaFromReadSeeker(r io.ReadSeeker) (*Media, error)
NewMediaFromReadSeeker creates a new media instance based on the provided read seeker.
func NewMediaFromScreen ¶
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 ¶
NewMediaFromURL creates a new media instance based on the media located at the specified URL.
func (*Media) AddOptions ¶
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 ¶
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 ¶
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 ¶
IsParsed returns true if the media was parsed.
NOTE: Deprecated in libVLC v3.0.0+. Use ParseStatus instead.
func (*Media) Location ¶
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 ¶
Parse fetches local art, metadata and track information synchronously.
NOTE: Deprecated in libVLC v3.0.0+. Use ParseWithOptions instead.
func (*Media) ParseAsync ¶
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 ¶
func (m *Media) ParseStatus() (MediaParseStatus, error)
ParseStatus returns the parsing status of the media.
func (*Media) ParseWithOptions ¶
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) 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 ¶
SetUserData associates the passed in user data with the media instance. The data can be retrieved by using the UserData method.
func (*Media) State ¶
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 ¶
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 ¶
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 ¶
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.
type MediaAudioTrack ¶
type MediaAudioTrack struct { Channels uint // number of audio channels. Rate uint // audio sample rate. }
MediaAudioTrack contains information specific to audio media tracks.
type MediaDiscoverer ¶
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 ¶
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 ¶
func (md *MediaDiscoverer) IsRunning() bool
IsRunning returns true if the media discovery service is running.
func (*MediaDiscoverer) MediaList ¶
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 ¶
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 ¶
func (md *MediaDiscoverer) Start(cb MediaDiscoveryCallback) error
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 ¶
func (md *MediaDiscoverer) Stop() error
Stop stops the discovery service.
type MediaDiscovererDescriptor ¶
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 ¶
func ListMediaDiscoverers(category MediaDiscoveryCategory) ([]*MediaDiscovererDescriptor, error)
ListMediaDiscoverers returns a list of descriptors identifying the available media discovery services of the specified category.
type MediaDiscoveryCallback ¶
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 ¶
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 ¶
NewMediaList creates an empty media list.
func (*MediaList) AddMedia ¶
AddMedia adds the provided Media instance at the end of the media list.
func (*MediaList) AddMediaFromPath ¶
AddMediaFromPath loads the media file at the specified path and adds it at the end of the media list.
func (*MediaList) AddMediaFromReadSeeker ¶
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 ¶
AddMediaFromURL loads the media file at the specified URL and adds it at the end of the the media list.
func (*MediaList) AssociateMedia ¶
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 ¶
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) EventManager ¶
func (ml *MediaList) EventManager() (*EventManager, error)
EventManager returns the event manager responsible for the media list.
func (*MediaList) IndexOfMedia ¶
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 ¶
InsertMedia inserts the provided Media instance in the list, at the specified index.
func (*MediaList) InsertMediaFromPath ¶
InsertMediaFromPath loads the media file at the provided path and inserts it in the list, at the specified index.
func (*MediaList) InsertMediaFromReadSeeker ¶
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 ¶
InsertMediaFromURL loads the media file at the provided URL and inserts it in the list, at the specified index.
func (*MediaList) IsReadOnly ¶
IsReadOnly specifies if the media list can be modified.
func (*MediaList) MediaAtIndex ¶
MediaAtIndex returns the media item at the specified index from the list.
func (*MediaList) RemoveMediaAtIndex ¶
RemoveMediaAtIndex removes the media item at the specified index from the 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 ¶
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 ¶
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 ¶
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 ¶
type MediaSubtitleTrack struct {
Encoding string // character encoding of the subtitle.
}
MediaSubtitleTrack contains information specific to subtitle media tracks.
type MediaTrack ¶
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 ¶
func (mt *MediaTrack) CodecDescription() (string, error)
CodecDescription returns the description of the codec used by the media track.
type MediaTrackDescriptor ¶
type MediaTrackDescriptor struct { ID int // Media track identifier. Description string // Description of the media track. }
MediaTrackDescriptor contains information about a media track.
type MediaTrackType ¶
type MediaTrackType int
MediaTrackType represents the type of a media track.
const ( MediaTrackUnknown MediaTrackType = iota - 1 MediaTrackAudio MediaTrackVideo MediaTrackText )
Media track types.
type MediaVideoTrack ¶
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 ¶
ModuleDescription contains information about a libVLC module.
func ListAudioFilters ¶
func ListAudioFilters() ([]*ModuleDescription, error)
ListAudioFilters returns the list of available audio filters.
func ListVideoFilters ¶
func ListVideoFilters() ([]*ModuleDescription, error)
ListVideoFilters returns the list of available video filters.
type NavigationAction ¶
type NavigationAction uint
NavigationAction defines actions for navigating menus of VCDs, DVDs and BDs.
const ( NavigationAction = iota NavigationActionUp NavigationActionDown NavigationActionLeft NavigationActionRight NavigationActionPopup )NavigationActionActivate
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 (*Player) AspectRatio ¶
AspectRatio returns the aspect ratio of the current video.
func (*Player) AudioDelay ¶
AudioDelay returns the delay of the current audio track, with microsecond precision.
func (*Player) AudioOutputDevice ¶
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 ¶
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 ¶
AudioTrackCount returns the number of audio tracks available in the current media of the player.
func (*Player) AudioTrackDescriptors ¶
func (p *Player) AudioTrackDescriptors() ([]*MediaTrackDescriptor, error)
AudioTrackDescriptors returns a descriptor list of the available audio tracks for the current player media.
func (*Player) AudioTrackID ¶
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) ChapterCount ¶
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 ¶
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 ¶
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 ¶
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 ¶
IsFullScreen returns the fullscreen status of the player.
func (*Player) IsMuted ¶
IsMuted returns a boolean value that specifies whether the audio output of the player is muted.
func (*Player) IsPlaying ¶
IsPlaying returns a boolean value specifying if the player is currently playing.
func (*Player) IsScrambled ¶
IsScrambled returns true if the media player is in a scrambled state.
func (*Player) IsSeekable ¶
IsSeekable returns true if the current media is seekable.
func (*Player) LoadMediaFromPath ¶
LoadMediaFromPath loads the media located at the specified path and sets it as the current media of the player.
func (*Player) LoadMediaFromReadSeeker ¶
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 ¶
LoadMediaFromURL loads the media located at the specified URL and sets it as the current media of the player.
func (*Player) MediaLength ¶
MediaLength returns media length in milliseconds.
func (*Player) MediaPosition ¶
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) NSObject ¶
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 ¶
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 ¶
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) PlaybackRate ¶
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 ¶
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) Role ¶
func (p *Player) Role() (PlayerRole, error)
Role returns the role of the player.
func (*Player) Scale ¶
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 ¶
SetAspectRatio sets the aspect ratio of the current video (e.g. `16:9`).
NOTE: Invalid aspect ratios are ignored.
func (*Player) SetAudioDelay ¶
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 ¶
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 ¶
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 ¶
SetAudioTrack sets the track identified by the specified ID as the current audio track of the player.
func (*Player) SetChapter ¶
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 ¶
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 ¶
SetFullScreen sets the fullscreen state of the media player. Pass in true to enable fullscreen, or false to disable it.
func (*Player) SetHWND ¶
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 ¶
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) SetMediaPosition ¶
SetMediaPosition sets media position as percentage between 0.0 and 1.0. Some formats and protocols do not support this.
func (*Player) SetMediaTime ¶
SetMediaTime sets the media time in milliseconds. Some formats and protocols do not support this.
func (*Player) SetMouseInput ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (p *Player) SetRole(role PlayerRole) error
SetRole sets the role of the player.
func (*Player) SetScale ¶
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 ¶
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 ¶
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 ¶
SetSubtitleTrack sets the track identified by the specified ID as the current subtitle track of the player.
func (*Player) SetTitle ¶
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 ¶
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 ¶
SetVideoTrack sets the track identified by the specified ID as the current video track of the player.
func (*Player) SetXWindow ¶
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 ¶
func (p *Player) StereoMode() (StereoMode, error)
StereoMode returns the stereo mode of the audio output used by the player.
func (*Player) SubtitleDelay ¶
SubtitleDelay returns the delay of the current subtitle track, with microsecond precision.
func (*Player) SubtitleTrackCount ¶
SubtitleTrackCount returns the number of subtitle tracks available in the current media of the player.
func (*Player) SubtitleTrackDescriptors ¶
func (p *Player) SubtitleTrackDescriptors() ([]*MediaTrackDescriptor, error)
SubtitleTrackDescriptors returns a descriptor list of the available subtitle tracks for the current player media.
func (*Player) SubtitleTrackID ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
ToggleFullScreen toggles the fullscreen status of the player, on non-embedded video outputs.
func (*Player) ToggleMute ¶
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 ¶
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 ¶
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) VideoDimensions ¶
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 ¶
VideoOutputCount returns the number of video outputs the media player has.
func (*Player) VideoTrackCount ¶
VideoTrackCount returns the number of video tracks available in the current media of the player.
func (*Player) VideoTrackDescriptors ¶
func (p *Player) VideoTrackDescriptors() ([]*MediaTrackDescriptor, error)
VideoTrackDescriptors returns a descriptor list of the available video tracks for the current player media.
func (*Player) VideoTrackID ¶
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) WillPlay ¶
WillPlay returns true if the current media is not in a finished or error state.
func (*Player) XWindow ¶
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 ¶
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 Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer represents a medium capable of rendering media files.
func (*Renderer) Flags ¶
func (r *Renderer) Flags() (*RendererFlags, error)
Flags returns the flags of the renderer.
func (*Renderer) Type ¶
func (r *Renderer) Type() (RendererType, error)
Type returns the type of the renderer.
type RendererDiscoverer ¶
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 ¶
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 ¶
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 ¶
func (rd *RendererDiscoverer) Start(cb RendererDiscoveryCallback) error
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 ¶
func (rd *RendererDiscoverer) Stop() error
Stop stops the discovery service.
type RendererDiscovererDescriptor ¶
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 ¶
func ListRendererDiscoverers() ([]*RendererDiscovererDescriptor, error)
ListRendererDiscoverers returns a list of descriptors identifying the available renderer discovery services.
type RendererDiscoveryCallback ¶
RendererDiscoveryCallback is used by renderer discovery services to report discovery events.
The available events are:
- RendererDiscovererItemAdded
- RendererDiscovererItemDeleted
type RendererFlags ¶
RendererFlags contains flags describing a renderer (e.g. capabilities).
type RendererType ¶
type RendererType string
RendererType represents the type of a renderer.
const (
RendererChromecast RendererType = "chromecast"
)
Renderer types.
type StereoMode ¶
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 ¶
type TitleFlag uint
TitleFlag defines properties of media titles. DVD and Blu-ray formats have their content split into titles.
type TitleInfo ¶
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 ¶
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 ¶
func (v VersionInfo) Changeset() string
Changeset returns the changeset identifier for the current libVLC build.
func (VersionInfo) Compiler ¶
func (v VersionInfo) Compiler() string
Compiler returns information regarding the compiler used to build libVLC.
func (VersionInfo) Runtime ¶
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 ¶
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 ¶
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 ¶
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.