songplayer

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2017 License: MIT Imports: 17 Imported by: 8

Documentation

Index

Constants

View Source
const (
	SEARCH_TYPE_TRACK    SearchType = iota + 1
	SEARCH_TYPE_ALBUM               = iota + 1
	SEARCH_TYPE_PLAYLIST            = iota + 1
)
View Source
const (
	DEFAULT_AUTHORISE_PORT = 5678
	DEFAULT_AUTHORISE_URL  = "http://musicbot:5678/authorise/"

	MAX_SPOTIFY_PLAYLIST_ITEMS = 1000
)
View Source
const (
	YouTubeVideoURL    = "https://www.youtube.com/watch?v=%s"
	YouTubePlaylistURL = "https://www.youtube.com/watch?v=%s&list=%s"

	MAX_YOUTUBE_PLAYLIST_ITEMS = 500
)

Variables

View Source
var ErrNotAuthorised = errors.New("Client has not been authorised yet")

Functions

func GetSpotifyAlbumImage

func GetSpotifyAlbumImage(album *spotify.SimpleAlbum) (imageURL string)

func GetSpotifyAlbumName

func GetSpotifyAlbumName(album *spotify.FullAlbum) (name string)

func GetSpotifyTrackName

func GetSpotifyTrackName(track *spotify.SimpleTrack) (name string)

func RandStringBytes

func RandStringBytes(n int) string

func SearchTypeString

func SearchTypeString(searchType SearchType) (str string)

Types

type MockPlayer added in v1.5.1

type MockPlayer struct{}

func NewMemoryPlayer

func NewMemoryPlayer() (p *MockPlayer)

func (*MockPlayer) CanPlay added in v1.5.1

func (p *MockPlayer) CanPlay(url string) (canPlay bool)

func (*MockPlayer) GetItems added in v1.5.1

func (p *MockPlayer) GetItems(url string) (items []Song, err error)

func (*MockPlayer) Name added in v1.5.1

func (p *MockPlayer) Name() (name string)

func (*MockPlayer) Pause added in v1.5.1

func (p *MockPlayer) Pause(pauseState bool) (err error)

func (*MockPlayer) Play added in v1.5.1

func (p *MockPlayer) Play(url string) (err error)

func (*MockPlayer) Seek added in v1.5.1

func (p *MockPlayer) Seek(positionSeconds int) (err error)

func (*MockPlayer) Stop added in v1.5.1

func (p *MockPlayer) Stop() (err error)

type Playable

type Playable interface {
	GetTitle() string
	GetDuration() time.Duration
	GetURL() string
	GetImageURL() string
}

type PlayableSearchResult

type PlayableSearchResult interface {
	Playable

	GetType() SearchType
}

func GetSpotifySearchResults

func GetSpotifySearchResults(spClient *spotify.Client, searchType SearchType, searchStr string, limit int) (results []PlayableSearchResult, err error)

type SearchType

type SearchType uint8

func GetSearchType

func GetSearchType(searchTypeStr string) (ok bool, searchType SearchType)

type Song

type Song struct {
	Title    string
	Duration time.Duration
	URL      string
	ImageURL string
}

func NewSong

func NewSong(title string, duration time.Duration, URL, imageURL string) *Song

func (*Song) GetDuration

func (i *Song) GetDuration() time.Duration

func (*Song) GetImageURL

func (i *Song) GetImageURL() string

func (*Song) GetTitle

func (i *Song) GetTitle() string

func (*Song) GetURL

func (i *Song) GetURL() string

type SongPlayer

type SongPlayer interface {
	Name() (name string)
	CanPlay(url string) (canPlay bool)
	GetSongs(url string) (songs []Playable, err error)
	Search(searchType SearchType, searchStr string, limit int) (results []PlayableSearchResult, err error)
	Play(url string) (err error)
	Seek(positionSeconds int) (err error)
	Pause(pauseState bool) (err error)
	Stop() (err error)
}

type SongResult

type SongResult struct {
	*Song

	Type SearchType
}

func NewSongResult

func NewSongResult(tp SearchType, title string, duration time.Duration, URL, imageURL string) *SongResult

func (*SongResult) GetType

func (sr *SongResult) GetType() SearchType

type SpotifyPlayer

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

func NewSpotifyPlayer

func NewSpotifyPlayer(spotifyClientID, spotifyClientSecret, tokenFilePath, authoriseRedirectURL string, authoriseHTTPPort int) (p *SpotifyPlayer, authURL string, err error)

func (*SpotifyPlayer) AddAuthorisationListener added in v1.5.1

func (p *SpotifyPlayer) AddAuthorisationListener(listener func())

func (*SpotifyPlayer) CanPlay

func (p *SpotifyPlayer) CanPlay(url string) (canPlay bool)

func (*SpotifyPlayer) GetSongs

func (p *SpotifyPlayer) GetSongs(url string) (songs []Playable, err error)

func (*SpotifyPlayer) Name

func (p *SpotifyPlayer) Name() (name string)

func (*SpotifyPlayer) Pause

func (p *SpotifyPlayer) Pause(pauseState bool) (err error)

func (*SpotifyPlayer) Play

func (p *SpotifyPlayer) Play(url string) (err error)

func (*SpotifyPlayer) Search

func (p *SpotifyPlayer) Search(searchType SearchType, searchStr string, limit int) (results []PlayableSearchResult, err error)

func (*SpotifyPlayer) Seek

func (p *SpotifyPlayer) Seek(positionSeconds int) (err error)

func (*SpotifyPlayer) ServeHTTP added in v1.5.1

func (p *SpotifyPlayer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*SpotifyPlayer) SetPlaybackDevice added in v1.6.0

func (p *SpotifyPlayer) SetPlaybackDevice(playbackDevice string)

func (*SpotifyPlayer) Stop

func (p *SpotifyPlayer) Stop() (err error)

type Type

type Type int
const (
	TYPE_TRACK Type = 1 + iota
	TYPE_ALBUM
	TYPE_PLAYLIST
)

func GetSpotifyTypeAndIDFromURL

func GetSpotifyTypeAndIDFromURL(url string) (tp Type, id, userID string, err error)

type YouTubeAPI

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

func NewYoutubeAPI

func NewYoutubeAPI(youtubeAPIKey string) (yt *YouTubeAPI)

func (*YouTubeAPI) GetPlayableForIdentifier

func (yt *YouTubeAPI) GetPlayableForIdentifier(identifier string) (playable Playable, err error)

func (*YouTubeAPI) GetPlayableForURL

func (yt *YouTubeAPI) GetPlayableForURL(source string) (playable Playable, err error)

GetPlayableForURL - Get meta data for a youtube url

func (*YouTubeAPI) GetPlayablesForPlaylistIdentifier

func (yt *YouTubeAPI) GetPlayablesForPlaylistIdentifier(identifier string, limit int) (items []Playable, err error)

func (*YouTubeAPI) GetPlayablesForPlaylistURL

func (yt *YouTubeAPI) GetPlayablesForPlaylistURL(source string) (items []Playable, err error)

func (*YouTubeAPI) Search

func (yt *YouTubeAPI) Search(searchType SearchType, searchStr string, limit int) (items []PlayableSearchResult, err error)

type YoutubePlayer

type YoutubePlayer struct {
	*util.MpvControl
	// contains filtered or unexported fields
}

func NewYoutubePlayer

func NewYoutubePlayer(youtubeAPIKey string, mpvControl *util.MpvControl) (player *YoutubePlayer, err error)

func (*YoutubePlayer) CanPlay

func (p *YoutubePlayer) CanPlay(url string) (canPlay bool)

func (*YoutubePlayer) GetSongs

func (p *YoutubePlayer) GetSongs(url string) (songs []Playable, err error)

func (*YoutubePlayer) Name

func (p *YoutubePlayer) Name() (name string)

func (*YoutubePlayer) Play

func (p *YoutubePlayer) Play(url string) (err error)

func (*YoutubePlayer) Search

func (p *YoutubePlayer) Search(searchType SearchType, searchStr string, limit int) (results []PlayableSearchResult, err error)

Jump to

Keyboard shortcuts

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