player

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrAnyCode uint8 = iota
	ErrTooMuchTimePausedCode
	ErrVoiceConnectionClosedCode
	ErrTrackSearchFailedCode
	ErrTrackSearchInvalidUrlCode
	ErrTrackSearchUnsuportedCode
	ErrTrackNotFoundInQueueCode
	ErrNoActivePlayerCode
	ErrSpotifyPlaylistsNotSupportedCode
)

Variables

View Source
var (
	ErrTooMuchTimePaused     = errors.New("muito tempo de pausa")
	ErrVoiceConnectionClosed = errors.New("desconectado do canal de voz")
	ErrTrackSearchFailed     = errors.New("não foi possível encontrar a música")
	ErrTrackSearchInvalidUrl = errors.New("a url fornecida é inválida")
	ErrTrackSearchUnsuported = errors.New("a url fornecida é de uma plataforma não suportada")

	ErrTrackNotFoundInQueue = errors.New("não foi possível achar a música na fila")
	ErrNoActivePlayer       = errors.New("o servidor não tem um player ativo")

	ErrSpotifyPlaylistsNotSupported = errors.New("playlists e álbuns do spotify não são suportados")
)

Functions

This section is empty.

Types

type AddTrackData

type AddTrackData struct {
	UserId        string `json:"user_id" validate:"required,number"`
	ChannelId     string `json:"channel_id" validate:"required,number"`
	TextChannelId string `json:"text_channel_id" validate:"required,number"`

	Data []TrackData `json:"data" validate:"required"`
}

type GetTracksData added in v0.1.0

type GetTracksData struct {
	TotalSize     int           `json:"total_size"`
	TotalDuration time.Duration `json:"total_duration"`

	Playing *Track  `json:"playing"`
	Tracks  []Track `json:"tracks"`
}

type HttpClient

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

func NewHttpClient

func NewHttpClient(client *http.Client, baseUrl string, password string) *HttpClient

func (*HttpClient) AddTrack

func (h *HttpClient) AddTrack(guildId string, data AddTrackData) ([]Track, error)

func (*HttpClient) EnableLoop

func (h *HttpClient) EnableLoop(guildId string, enable bool) (bool, error)

func (*HttpClient) FetchTrack

func (h *HttpClient) FetchTrack(query string) ([]TrackData, error)

func (*HttpClient) GetPlayingTrack

func (h *HttpClient) GetPlayingTrack(guildId string) (*Track, error)

func (*HttpClient) GetTrackById

func (h *HttpClient) GetTrackById(guildId string, id uuid.UUID) (*Track, error)

func (*HttpClient) GetTracks

func (h *HttpClient) GetTracks(guildId string, offset, limit int) (*GetTracksData, error)

func (*HttpClient) Pause

func (h *HttpClient) Pause(guildId string) (bool, error)

func (*HttpClient) RemoveTrack

func (h *HttpClient) RemoveTrack(guildId string, id uuid.UUID) (*Track, error)

func (*HttpClient) SetVolume

func (h *HttpClient) SetVolume(guildId string, volume uint8) (bool, error)

func (*HttpClient) Skip

func (h *HttpClient) Skip(guildId string) (*Track, error)

func (*HttpClient) Stop

func (h *HttpClient) Stop(guildId string) error

func (*HttpClient) Unpause

func (h *HttpClient) Unpause(guildId string) (bool, error)

type Track

type Track struct {
	ID          uuid.UUID `json:"id" validate:"required"`
	RequestedAt time.Time `json:"requested_at" validate:"required"`
	UserId      uint64    `json:"user_id" validate:"required"`
	ChannelId   uint64    `json:"channel_id" validate:"required"`

	State *TrackState `json:"state"`
	Data  *TrackData  `json:"data" validate:"required"`
}

func NewTrack

func NewTrack(userId, channelId uint64, data *TrackData) Track

type TrackData

type TrackData struct {
	Name      string        `json:"name" validate:"required"`
	URL       string        `json:"url" validate:"required"`
	PlayQuery string        `json:"play_query" validate:"required"`
	Thumbnail string        `json:"thumbnail" validate:"required"`
	Duration  time.Duration `json:"duration" validate:"required"`
}

type TrackState

type TrackState struct {
	Progress     *atomic.Duration `json:"progress"`
	PlayingStart time.Time        `json:"play_start" validate:"required"`
	Looping      bool             `json:"looping"`
}

Jump to

Keyboard shortcuts

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