vlc

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: MIT Imports: 10 Imported by: 11

README

libvlc-go logo
libvlc-go

Go bindings for libVLC version 2.X/3.X/4.X.

GoDoc Go Report Card

The package can be useful for adding multimedia capabilities to applications through the provided player interfaces.
Full documentation can be found at: https://godoc.org/github.com/adrg/libvlc-go

Prerequisites

The libVLC development files are required. Instructions for installing the VLC SDK on multiple operating systems can be found on the wiki pages of this project.

Installation

go get github.com/adrg/libvlc-go

Build for libVLC < v3.0.0.

go build -tags legacy

Usage

package main

import (
    "log"

    vlc "github.com/adrg/libvlc-go"
)

func main() {
    // 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()

    // 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()

    // Start playing the media.
    err = player.Play()
    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.MediaPlayerEndReached, eventCallback, nil)
    if err != nil {
        log.Fatal(err)
    }
    defer manager.Detach(eventID)

    <-quit
}

Examples

Stargazers over time

Stargazers over time

Contributing

Contributions in the form of pull requests, issues or just general feedback, are always welcome. See CONTRIBUTING.MD.

Contributors: adrg, fenimore, tarrsalah, danielpellon, patknight, sndnvaps.

References

For more information see the libVLC documentation.

License

Copyright (c) 2018 Adrian-George Bostan.

This project is licensed under the MIT license. See LICENSE for more details.

Documentation

Overview

Package vlc provides golang bindings for libVLC version 2.X/3.X/4.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()

// Start playing the media.
if err = player.Play(); 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.MediaPlayerEndReached, eventCallback, nil)
if err != nil {
	log.Fatal(err)
}
defer manager.Detach(eventID)

<-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("https://example.com/test2.mp4")
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/test3.mp3")
if err != nil {
	log.Fatal(err)
}

// Start playing the media list.
if err = player.Play(); 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)

<-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 player media from path.
media, err := player.LoadMediaFromPath("localpath/test.mp3")
if err != nil {
	log.Fatal(err)
}
defer media.Release()

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

// 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)
	}
}()

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

Module errors.

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

Player errors.

View Source
var (
	ErrMediaCreate             = errors.New("could not create media")
	ErrMediaNotInitialized     = errors.New("media not initialized")
	ErrMediaListCreate         = errors.New("could not create 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")
	ErrMediaMetaSave           = errors.New("could not save media metadata")
)

Media 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")
)

Audio errors.

Functions

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.

Types

type AudioOutput

type AudioOutput struct {
	Name        string
	Description string
}

AudioOutput is an abstraction for rendering decoded (or pass-through) audio samples.

func AudioOutputList

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

AudioOutputList returns a list of audio output devices that can be used with an instance of a player.

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(eventID 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 an instance of a multi-media player.

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) 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 ListPlayer.

func (*ListPlayer) Release

func (lp *ListPlayer) Release() error

Release destroys the media 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 ListPlayer.

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 Media instance from the provided path.

func NewMediaFromURL

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

NewMediaFromURL creates a Media instance from the provided 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) EventManager

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

EventManager returns the event manager responsible for the media.

func (*Media) IsParsed

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

IsParsed returns true if the media was parsed. NOTE: deprecated in libVLC v3.0.0+.

func (*Media) Location

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

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

func (*Media) Meta

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

Meta reads the value of the specified media metadata key.

func (*Media) Parse

func (m *Media) Parse() error

Parse fetches local art, metadata and track information synchronously. NOTE: deprecated in libVLC v3.0.0+.

func (*Media) ParseAsync

func (m *Media) ParseAsync() error

ParseAsync fetches local art, metadata and track information asynchronously. Listen to MediaParsedChanged event on the media event manager the track when the parsing has finished. However, if the media was already parsed, the event will not be sent. NOTE: deprecated in libVLC v3.0.0+.

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

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

Stats returns playback statistics for the media.

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) 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) 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 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 bitrate.

	// Demux statistics.
	DemuxReadBytes     int     // demux bytes read (demuxed data size).
	DemuxBitRate       float64 // demux bitrate (content bitrate).
	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 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) EventManager

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

EventManager returns the event manager responsible for the media player.

func (*Player) IsFullScreen

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

IsFullScreen gets the fullscreen status of the current player.

func (*Player) IsPlaying

func (p *Player) IsPlaying() bool

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

func (*Player) LoadMediaFromPath

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

LoadMediaFromPath loads the media from the specified path and adds it as the current media of the player.

func (*Player) LoadMediaFromURL

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

LoadMediaFromURL loads the media from the specified URL and adds 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) Play

func (p *Player) Play() error

Play plays the current media.

func (*Player) Release

func (p *Player) Release() error

Release destroys the media player instance.

func (*Player) SetAudioOutput

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

SetAudioOutput selects an audio output module. Any change will take be effect only after playback is stopped and restarted. Audio output cannot be changed while playing.

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) 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 protocals do not support this.

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) 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 the X window to play on.

func (*Player) Stop

func (p *Player) Stop() error

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

func (*Player) ToggleFullScreen

func (p *Player) ToggleFullScreen() error

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

func (*Player) TogglePause

func (p *Player) TogglePause() error

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

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.

type VersionInfo

type VersionInfo struct {
	Major uint
	Minor uint
	Patch 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) String

func (v VersionInfo) String() string

String returns a string representation of the version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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