Documentation ¶
Index ¶
- Constants
- Variables
- type Backend
- type MPV
- type MediaPlayer
- func (p *MediaPlayer) ChangeVolume(delta int, volumeChan chan int)
- func (p *MediaPlayer) Pause()
- func (p *MediaPlayer) Play()
- func (p *MediaPlayer) Quit()
- func (p *MediaPlayer) RequestPlaylist(playlistChan chan PlaylistState)
- func (p *MediaPlayer) RequestVolume(volumeChan chan int)
- func (p *MediaPlayer) Seek(position time.Duration)
- func (p *MediaPlayer) SetPlaystate(playlist []string, index int, position time.Duration, listId string)
- func (p *MediaPlayer) SetVideo(videoId string, position time.Duration)
- func (p *MediaPlayer) SetVolume(volume int, volumeChan chan int)
- func (p *MediaPlayer) Stop()
- func (p *MediaPlayer) UpdatePlaylist(playlist []string, listId string)
- type PlayState
- type PlaylistState
- type State
- type StateChange
- type VideoGrabber
- type VideoURL
Constants ¶
const ( STATE_STOPPED State = 0 STATE_PLAYING = 1 STATE_PAUSED = 2 STATE_BUFFERING = 3 STATE_SEEKING = 4 // not in the YouTube API )
const INITIAL_VOLUME = 80
Variables ¶
var MPV_PROPERTY_UNAVAILABLE = errors.New("mpv: property unavailable")
var PROPERTY_UNAVAILABLE = errors.New("media player: property unavailable")
Functions ¶
This section is empty.
Types ¶
type MPV ¶
type MPV struct {
// contains filtered or unexported fields
}
MPV is an implementation of Backend, using libmpv.
type MediaPlayer ¶
type MediaPlayer struct {
// contains filtered or unexported fields
}
A generic YouTube media player using a playlist.
func New ¶
func New(stateChange chan StateChange) *MediaPlayer
func (*MediaPlayer) ChangeVolume ¶
func (p *MediaPlayer) ChangeVolume(delta int, volumeChan chan int)
ChangeVolume increases or decreases the volume by the specified delta.
func (*MediaPlayer) Quit ¶
func (p *MediaPlayer) Quit()
Quit quits the MediaPlayer. No other method may be called upon this object after this function has been called.
func (*MediaPlayer) RequestPlaylist ¶
func (p *MediaPlayer) RequestPlaylist(playlistChan chan PlaylistState)
RequestPlaylist asynchronously gets the playlist state and sends it over the channel. To make asynchronous requests work, it expects a 1-buffered channel. Before a new PlaylistState is sent over the channel, the previous is read if it's there. It ensures that only one goroutine does that at one time, so this trick should not be used elsewhere on the same channel.
func (*MediaPlayer) RequestVolume ¶
func (p *MediaPlayer) RequestVolume(volumeChan chan int)
RequestVolume asynchronously gets the volume and sends it over the channel volumeChan. See RequestPlaylist for how this works.
func (*MediaPlayer) Seek ¶
func (p *MediaPlayer) Seek(position time.Duration)
Seek jumps to the specified position
func (*MediaPlayer) SetPlaystate ¶
func (p *MediaPlayer) SetPlaystate(playlist []string, index int, position time.Duration, listId string)
SetPlaystate changes the play state to the specified arguments This function doesn't block, but changes may not be immediately applied.
func (*MediaPlayer) SetVideo ¶
func (p *MediaPlayer) SetVideo(videoId string, position time.Duration)
func (*MediaPlayer) SetVolume ¶
func (p *MediaPlayer) SetVolume(volume int, volumeChan chan int)
SetVolume sets the volume of the player to the specified value (0-100).
func (*MediaPlayer) Stop ¶
func (p *MediaPlayer) Stop()
Stop stops the currently playing sound and clears the playlist.
func (*MediaPlayer) UpdatePlaylist ¶
func (p *MediaPlayer) UpdatePlaylist(playlist []string, listId string)
type PlayState ¶
type PlayState struct { Playlist []string Index int State State ListId string Volume int // contains filtered or unexported fields }
PlayState defines the current state of the generic MediaPlayer. It is shared within the MediaPlayer and used as an access token as well: whoever holds a pointer to this structure may access it's members. That also means that a pointer to this struct should be cleared when starting a new goroutine.
type PlaylistState ¶
type StateChange ¶
type VideoGrabber ¶
type VideoGrabber struct {
// contains filtered or unexported fields
}
func NewVideoGrabber ¶
func NewVideoGrabber() *VideoGrabber
func (*VideoGrabber) GetStream ¶
func (vg *VideoGrabber) GetStream(videoId string) string
GetStream returns the stream for videoId, or an empty string if an error occured.
func (*VideoGrabber) Quit ¶
func (vg *VideoGrabber) Quit()
type VideoURL ¶
type VideoURL struct {
// contains filtered or unexported fields
}
func (*VideoURL) GetURL ¶
Gets the video stream URL, possibly waiting until that video has been fetched or an error occurs. An empty string will be returned on error.
func (*VideoURL) WillExpire ¶
WillExpire returns true if this stream will expire within an hour.