audio

package
v0.0.0-...-daa8be9 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotPaused        = errors.New("Not paused.")
	ErrNotPlaying       = errors.New("Not playing anything.")
	ErrNotLooping       = errors.New("Not looping.")
	ErrSiteNotSupported = errors.New("This website is not supported.")
)
View Source
var Advanced = advanced{}
View Source
var AdvancedLoop = advancedLoop{}
View Source
var AdvancedLoopOff = advancedLoopOff{}
View Source
var AdvancedLoopOn = advancedLoopOn{}
View Source
var AdvancedPause = advancedPause{}
View Source
var AdvancedPlay = advancedPlay{}
View Source
var AdvancedQueue = advancedQueue{}
View Source
var AdvancedResume = advancedResume{}
View Source
var AdvancedSkip = advancedSkip{}

Functions

func LoopOff

func LoopOff(place int64) error

LoopOff will turn looping off by setting the state to Play for the specified place. Returns ErrNotPlaying if the queue is empty. Returns ErrNotLooping if the current state is not Loop.

func LoopOn

func LoopOn(place int64) error

LoopOn will turn on looping by setting the state to Loop for the specified place. Returns an ErrNotPlaying if the queue is empty.

func Pause

func Pause(place int64) error

Pause will pause by setting the state to Pause in the specified place. Returns ErrNotPlaying if the queue is empty or if the state is not set to Play.

func Resume

func Resume(place int64) error

Resume will resume playback by setting the state to Play in the specified place. Returns an ErrNotPlaying if the queue is empty. Returns ErrNotPaused if the state is not set to Pause.

func Skip

func Skip(place int64) error

Skip will skip the currenly playing item by setting the state to Stop in the specified place, which will exit the currenly playing item allowing for the next one to be played. Returns ErrNotPlaying if the queue is empty.

Types

type Item

type Item struct {
	URL   string `json:"webpage_url"`
	Title string `json:"title"`
}

func GetInfo

func GetInfo(url string) (Item, error)

func Play

func Play(args []string, sp core.AudioSpeaker, place int64) (Item, error, error)

Play will:

  • Check if the first argument is a url, if yes, then will try to stream it. If not then assumes that it is a search and will query youtube to find the corresponding video.
  • Join the voice channel if necessary.
  • Adds the item in the queue, if no queue exists creates one and begins item playback.

Returns ErrSiteNotSupported if the provided URL is a website that is not supported. Also passes any potential user errors that were generated by youtube.SearchVideo if a video search was performed.

func Queue

func Queue(place int64) ([]Item, error)

Queue returns the list of items that are currenly in the queue. The first item is the one that is currenly active. Returns ErrNotPlaying if the queue is empty.

type Playing

type Playing struct {
	State *core.AudioState
	Queue *gosafe.Slice[Item]
}

Jump to

Keyboard shortcuts

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