player

package
v0.0.0-...-ad2a5af Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MaxNextSongs = 20
View Source
const MaxPlaylistSize = 100

Variables

View Source
var (
	ErrNoFormat      = errors.New("no format found")
	ErrEmpty         = errors.New("empty playlist")
	ErrPlaying       = errors.New("the playlist is already playing")
	ErrStopped       = errors.New("the playlist is already stopped")
	ErrVolumeRange   = errors.New("the volume level is incorrect")
	ErrEmptyPlaylist = errors.New("playlist empty")
	ErrIncorrectURL  = errors.New("incorrect url")
)
View Source
var ErrThumbDownload = errors.New("could not get thumbnail")

Functions

This section is empty.

Types

type Player

type Player struct {
	SongList []string
	// contains filtered or unexported fields
}

func New

func New(default_volume uint8) *Player

Creates and returns a Player instance

func (*Player) AddToQueue

func (p *Player) AddToQueue(c *gumble.Client, url *url.URL) ([]*Track, error)

Add the song from the URL to the playlist Returns the track that is added.

func (*Player) ClearQueue

func (p *Player) ClearQueue()

Clears the tracks from the playlist

func (*Player) GetCurrentSong

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

Returns info about the current song

func (*Player) GetNextSongs

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

Get songs that are going to play next

func (*Player) GetVolume

func (p *Player) GetVolume() float32

Returns the current volume in float (Range: 0 - 1)

func (*Player) SearchAndAdd

func (p *Player) SearchAndAdd(c *gumble.Client, apiKey, query string) (*Track, error)

Searches youtube using the query argument and adds the first result to the playlist. Returns the track that is added.

func (*Player) SetVolume

func (p *Player) SetVolume(vol int) error

Receives an integer between 0-100 and sets the volume to that value. Returns an error if the number is not in the correct range

func (*Player) Skip

func (p *Player) Skip() error

Skips a song from the playlist

func (*Player) Start

func (p *Player) Start(c *gumble.Client) error

Starts the playlist

func (*Player) Stop

func (p *Player) Stop() error

Stops the playlist

type Thumbnail

type Thumbnail struct {
	Data     []byte
	MimeType string
	URL      string
}

func NewThumbnail

func NewThumbnail(url string) (*Thumbnail, error)

Initializes a new thumbail from a give url string

type Track

type Track struct {
	Stream    *gumbleffmpeg.Stream
	Duration  time.Duration
	StreamURL string
	PublicURL string
	Title     string
	Artist    string
	Thumbnail *Thumbnail
}

func YoutubePlaylistToTracks

func YoutubePlaylistToTracks(gc *gumble.Client, yc *youtube.Client, p *youtube.Playlist) ([]*Track, error)

Returns a slice of tracks from a playlist

func YoutubeVideoToTrack

func YoutubeVideoToTrack(gc *gumble.Client, yc *youtube.Client, video *youtube.Video) (*Track, error)

Receives a youtube video and returns a track struct

func (*Track) String

func (t *Track) String() string

Returns the string for displaying the track

Jump to

Keyboard shortcuts

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