mediaplayer

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EventHandler added in v0.3.7

func EventHandler(event MediaEvent)

EventHandler sends a media event to the preset handler.

func Init

func Init(player, execpath, ytdlpath, numretries, useragent, socket string) error

Init launches the provided player.

func SetEventHandler added in v0.3.7

func SetEventHandler(handler func(e MediaEvent))

SetEventHandler sets the media event handler.

Types

type MPV

type MPV struct {
	*mpvipc.Connection
	// contains filtered or unexported fields
}

MPV describes the mpv player.

func (*MPV) BufferPercentage added in v0.3.7

func (m *MPV) BufferPercentage() int

BufferPercentage returns the cache buffered percentage.

func (*MPV) Buffering

func (m *MPV) Buffering() bool

Buffering returns if the player is buffering.

func (*MPV) Call

func (m *MPV) Call(args ...interface{}) (interface{}, error)

Call send a command to MPV.

func (*MPV) Duration

func (m *MPV) Duration() int64

Duration returns the total duration of the track.

func (*MPV) Exit

func (m *MPV) Exit()

Exit tells MPV to exit.

func (*MPV) Exited

func (m *MPV) Exited() bool

Exited returns whether MPV has exited or not.

func (*MPV) Finished

func (m *MPV) Finished() bool

Finished returns if the playback has finished.

func (*MPV) Get

func (m *MPV) Get(prop string) (interface{}, error)

Get gets a property from the mpv instance.

func (*MPV) Idle

func (m *MPV) Idle() bool

Idle returns if the player is idle.

func (*MPV) Init

func (m *MPV) Init(execpath, ytdlpath, numretries, useragent, socket string) error

Init initializes and sets up MPV.

func (*MPV) LoadFile

func (m *MPV) LoadFile(title string, duration int64, audio bool, files ...string) error

LoadFile loads the provided files into MPV. When more than one file is provided, the first file is treated as a video stream and the second file is attached as an audio stream.

func (*MPV) Muted

func (m *MPV) Muted() bool

Muted returns whether playback is muted.

func (*MPV) Paused

func (m *MPV) Paused() bool

Paused returns whether playback is paused or not.

func (*MPV) Play

func (m *MPV) Play()

Play start the playback.

func (*MPV) Position

func (m *MPV) Position() int64

Position returns the seek position.

func (*MPV) SeekBackward

func (m *MPV) SeekBackward()

SeekBackward seeks the track backward by 1s.

func (*MPV) SeekForward

func (m *MPV) SeekForward()

SeekForward seeks the track forward by 1s.

func (*MPV) SendQuit

func (m *MPV) SendQuit(socket string)

SendQuit sends a quit signal to the provided socket.

func (*MPV) Set

func (m *MPV) Set(prop string, value interface{}) error

Set sets a property in the mpv instance.

func (*MPV) SetLoopMode added in v0.3.7

func (m *MPV) SetLoopMode(mode RepeatMode)

SetLoopMode sets the loop mode.

func (*MPV) Stop

func (m *MPV) Stop()

Stop stops the playback.

func (*MPV) ToggleMuted

func (m *MPV) ToggleMuted()

ToggleMuted toggles muting of the playback.

func (*MPV) TogglePaused

func (m *MPV) TogglePaused()

TogglePaused toggles pausing the playback.

func (*MPV) Volume

func (m *MPV) Volume() int

Volume returns the volume.

func (*MPV) VolumeDecrease

func (m *MPV) VolumeDecrease()

VolumeDecrease decreases the volume by 1.

func (*MPV) VolumeIncrease

func (m *MPV) VolumeIncrease()

VolumeIncrease increments the volume by 1.

func (*MPV) WaitClosed

func (m *MPV) WaitClosed()

WaitClosed waits for MPV to exit.

type MediaEvent added in v0.3.7

type MediaEvent int
const (
	EventNone MediaEvent = iota
	EventEnd
	EventStart
	EventInProgress
	EventError
)

type MediaPlayer

type MediaPlayer interface {
	Init(execpath, ytdlpath, numretries, useragent, socket string) error
	Exit()
	Exited() bool
	SendQuit(socket string)

	LoadFile(title string, duration int64, liveaudio bool, files ...string) error

	Play()
	Stop()
	SeekForward()
	SeekBackward()
	Position() int64
	Duration() int64

	Paused() bool
	TogglePaused()

	Muted() bool
	ToggleMuted()

	SetLoopMode(mode RepeatMode)

	Idle() bool
	Finished() bool

	Buffering() bool
	BufferPercentage() int

	Volume() int
	VolumeIncrease()
	VolumeDecrease()

	WaitClosed()

	Call(args ...interface{}) (interface{}, error)
	Get(prop string) (interface{}, error)
	Set(prop string, value interface{}) error
}

MediaPlayer describes a media player.

func Player

func Player() MediaPlayer

Player returns the currently selected player.

type MediaPlayerSettings added in v0.3.7

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

MediaPlayerSettings stores the media player's settings.

type RepeatMode added in v0.3.7

type RepeatMode int
const (
	RepeatModeOff RepeatMode = iota
	RepeatModeFile
	RepeatModePlaylist
)

Jump to

Keyboard shortcuts

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