player

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2021 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package player contains all logic for jellycli. This includes queue (history) management, low-level audio and audio controls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio added in v0.3.0

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

Audio manages playing song and implements interfaces.Player

func (*Audio) AddStatusCallback added in v0.3.0

func (a *Audio) AddStatusCallback(cb func(status interfaces.AudioStatus))

AddStatusCallback adds a callback that gets called every time audio status is changed, or after certain time.

func (*Audio) Continue added in v0.3.0

func (a *Audio) Continue()

Continue continues paused audio. If audio is already playing, do nothing.

func (*Audio) Next added in v0.3.0

func (a *Audio) Next()

Next plays next track. If there's no next song to play, do nothing.

func (*Audio) Pause added in v0.3.0

func (a *Audio) Pause()

Pause pauses audio. If audio is already paused, do nothing.

func (*Audio) PlayPause added in v0.3.0

func (a *Audio) PlayPause()

PlayPause toggles pause.

func (*Audio) Previous added in v0.3.0

func (a *Audio) Previous()

Previous plays previous track. If previous track does not exist, do nothing.

func (*Audio) Seek added in v0.3.0

func (a *Audio) Seek(ticks interfaces.AudioTick)

Seek seeks given ticks. If there is no audio, do nothing.

func (*Audio) SetMute added in v0.3.0

func (a *Audio) SetMute(muted bool)

SetMute mutes and un-mutes audio

func (*Audio) SetShuffle added in v0.9.0

func (a *Audio) SetShuffle(shuffle bool)

func (*Audio) SetVolume added in v0.3.0

func (a *Audio) SetVolume(volume interfaces.AudioVolume)

SetVolume sets volume to given level.

func (*Audio) StopMedia added in v0.3.0

func (a *Audio) StopMedia()

StopMedia stops music. If there is no audio to play, do nothing.

func (*Audio) ToggleMute added in v0.9.0

func (a *Audio) ToggleMute()

type Items added in v0.3.0

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

Items implements interfaces.ItemController

func (*Items) GetAlbumArtist added in v0.5.0

func (i *Items) GetAlbumArtist(album *models.Album) (*models.Artist, error)

func (*Items) GetAlbumArtists added in v0.3.0

func (i *Items) GetAlbumArtists(paging interfaces.Paging) ([]*models.Artist, int, error)

func (*Items) GetAlbumSongs added in v0.3.0

func (i *Items) GetAlbumSongs(album models.Id) ([]*models.Song, error)

func (*Items) GetAlbums added in v0.3.0

func (i *Items) GetAlbums(opts *interfaces.QueryOpts) ([]*models.Album, int, error)

func (*Items) GetArtistAlbums added in v0.3.0

func (i *Items) GetArtistAlbums(artist models.Id) ([]*models.Album, error)

func (*Items) GetArtists added in v0.3.0

func (i *Items) GetArtists(opts *interfaces.QueryOpts) ([]*models.Artist, int, error)

func (*Items) GetFavoriteAlbums added in v0.3.0

func (i *Items) GetFavoriteAlbums(paging interfaces.Paging) ([]*models.Album, int, error)

func (*Items) GetFavoriteArtists added in v0.3.0

func (i *Items) GetFavoriteArtists() ([]*models.Artist, error)

func (*Items) GetGenreAlbums added in v0.4.0

func (i *Items) GetGenreAlbums(genre models.IdName) ([]*models.Album, error)

func (*Items) GetGenres added in v0.4.0

func (i *Items) GetGenres(paging interfaces.Paging) ([]*models.IdName, int, error)

func (*Items) GetInstantMix added in v0.5.0

func (i *Items) GetInstantMix(item models.Item) ([]*models.Song, error)

func (*Items) GetLatestAlbums added in v0.3.0

func (i *Items) GetLatestAlbums() ([]*models.Album, error)
func (i *Items) GetLink(item models.Item) string

func (*Items) GetPlaylistSongs added in v0.3.0

func (i *Items) GetPlaylistSongs(playlist *models.Playlist) error

func (*Items) GetPlaylists added in v0.3.0

func (i *Items) GetPlaylists() ([]*models.Playlist, error)

func (*Items) GetRecentlyPlayed added in v0.5.0

func (i *Items) GetRecentlyPlayed(paging interfaces.Paging) ([]*models.Song, int, error)

func (*Items) GetSimilarAlbums added in v0.4.0

func (i *Items) GetSimilarAlbums(album models.Id) ([]*models.Album, error)

func (*Items) GetSimilarArtists added in v0.4.0

func (i *Items) GetSimilarArtists(artist models.Id) ([]*models.Artist, error)

func (*Items) GetSongArtistAlbum added in v0.5.0

func (i *Items) GetSongArtistAlbum(song *models.Song) (*models.Album, *models.Artist, error)

func (*Items) GetSongs added in v0.3.0

func (i *Items) GetSongs(page, pageSize int) ([]*models.Song, int, error)

func (*Items) GetStatistics added in v0.3.0

func (i *Items) GetStatistics() models.Stats

func (*Items) Search added in v0.7.0

func (i *Items) Search(itemType models.ItemType, query string) ([]models.Item, error)

func (*Items) UpdateLocalAlbums added in v0.9.0

func (i *Items) UpdateLocalAlbums(limit int) error

UpdateLocalAlbums pulls latest info on albums from server and stores/updates on local database.

func (*Items) UpdateLocalArtists added in v0.9.0

func (i *Items) UpdateLocalArtists(limit int) error

UpdateLocalArtists pulls latest info on artists from server and stores/updates on local database.

func (*Items) UpdateLocalSongs added in v0.9.0

func (i *Items) UpdateLocalSongs(limit int) error

func (*Items) UpdatePlaylists added in v0.9.0

func (i *Items) UpdatePlaylists() error

type Player

type Player struct {
	task.Task
	*Audio
	*Queue
	*Items
	// contains filtered or unexported fields
}

Player wraps all controllers and implements interfaces.QueueController, interfaces.Player and interfaces.ItemController.

func NewPlayer

func NewPlayer(browser api.MediaServer) (*Player, error)

initialize new player. This also initializes faiface.Speaker, which should be initialized only once.

func (*Player) Next added in v0.3.0

func (p *Player) Next()

Next plays next song from queue. Override Audio next to ensure there is track to play and download it

func (*Player) Previous added in v0.3.0

func (p *Player) Previous()

Previous plays previous track. Override Audio previous to ensure there is track to play and download it

func (*Player) Reorder added in v0.4.0

func (p *Player) Reorder(index int, left bool) bool

func (*Player) SetShuffle added in v0.9.0

func (p *Player) SetShuffle(enabled bool)

type Queue added in v0.3.0

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

Queue implements interfaces.QueueController

func (*Queue) AddQueueChangedCallback added in v0.3.0

func (q *Queue) AddQueueChangedCallback(cb func(content []*models.Song))

AddQueueChangedCallback adds function that is called every time queue changes.

func (*Queue) AddSongs added in v0.3.0

func (q *Queue) AddSongs(songs []*models.Song)

AddSongs adds songs to the end of queue. Adding songs calls QueueChangedCallback.

func (*Queue) ClearQueue added in v0.3.0

func (q *Queue) ClearQueue(first bool)

ClearQueue clears queue. This also calls QueueChangedCallback.

func (*Queue) GetHistory added in v0.3.0

func (q *Queue) GetHistory(n int) []*models.Song

GetHistory get's n past songs that has been played.

func (*Queue) GetQueue added in v0.3.0

func (q *Queue) GetQueue() []*models.Song

GetQueue gets currently ongoing queue of items with complete info for each song.

func (*Queue) PlayNext added in v0.4.0

func (q *Queue) PlayNext(songs []*models.Song)

func (*Queue) RemoveSong added in v0.4.0

func (q *Queue) RemoveSong(index int)

func (*Queue) Reorder added in v0.3.0

func (q *Queue) Reorder(index int, down bool) bool

Reorder sets item in index currentIndex to newIndex. If either currentIndex or NewIndex is not valid, do nothing. On successful order QueueChangedCallback gets called.

func (*Queue) SetHistoryChangedCallback added in v0.3.0

func (q *Queue) SetHistoryChangedCallback(cb func([]*models.Song))

SetHistoryChangedCallback sets a function that gets called every time history items update.

func (*Queue) SetShuffle added in v0.9.0

func (q *Queue) SetShuffle(enabled bool)

Jump to

Keyboard shortcuts

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