controller

package
v0.0.0-...-e53a3c9 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int
const (
	ActionSearch Action = 0
)

type Content

type Content struct {
	task.Task
	// contains filtered or unexported fields
}

func NewContent

func NewContent(a *api.Api, p *player.Player) (*Content, error)

func (*Content) AddSongs

func (c *Content) AddSongs(songs []*models.Song)

func (*Content) ClearQueue

func (c *Content) ClearQueue()

func (*Content) Continue

func (c *Content) Continue()

func (*Content) GetChildren

func (c *Content) GetChildren(parent models.Id, parentType models.ItemType)

func (*Content) GetDefault

func (c *Content) GetDefault() []models.Item

func (*Content) GetHistory

func (c *Content) GetHistory(n int) []*models.SongInfo

func (*Content) GetItem

func (c *Content) GetItem(id models.Id, itemType models.ItemType)

func (*Content) GetItems

func (c *Content) GetItems(ids []models.Id, itemType models.ItemType)

func (*Content) GetParent

func (c *Content) GetParent(child models.Id, childType models.ItemType)

func (*Content) GetQueue

func (c *Content) GetQueue() []*models.SongInfo

func (*Content) GetView

func (c *Content) GetView(view View)

func (*Content) Next

func (c *Content) Next()

func (*Content) Pause

func (c *Content) Pause()

func (*Content) Previous

func (c *Content) Previous()

func (*Content) QueueDuration

func (c *Content) QueueDuration() int

func (*Content) RemoveItemsCallback

func (c *Content) RemoveItemsCallback()

func (*Content) RemoveQueueChangedCallback

func (c *Content) RemoveQueueChangedCallback()

func (*Content) Reorder

func (c *Content) Reorder(currentIndex, newIndex int)

func (*Content) Search

func (c *Content) Search(q string)

Search performs search query

func (*Content) SearchCompleteChan

func (c *Content) SearchCompleteChan() chan Action

func (*Content) SearchResults

func (c *Content) SearchResults() *api.SearchResult

SearchResults returns latest search results from index to index.

func (*Content) Seek

func (c *Content) Seek(seconds int)

func (*Content) SeekBackwards

func (c *Content) SeekBackwards(seconds int)

func (*Content) SetItemsCallback

func (c *Content) SetItemsCallback(cb func([]models.Item))

func (*Content) SetQueueChangedCallback

func (c *Content) SetQueueChangedCallback(cb func(content []*models.Song))

func (*Content) SetStatusCallback

func (c *Content) SetStatusCallback(cb func(state player.PlayingState))

func (*Content) SetVolume

func (c *Content) SetVolume(level int)

func (*Content) StopMedia

func (c *Content) StopMedia()

type ItemController

type ItemController interface {
	//GetItem gets item with given id. If none found or if errors, return nil
	GetItem(id models.Id, itemType models.ItemType)

	//GetItems get multiple items for given ids.
	GetItems(ids []models.Id, itemType models.ItemType)

	//GetChildren returns children for given parent id. If there are none, returns nil
	GetChildren(parent models.Id, parentType models.ItemType)
	//GetParent returns parent for child id. If there is no parent, return nil
	GetParent(child models.Id, childType models.ItemType)
	//SetItemsCallback sets callback that gets called when items are retrieved
	SetItemsCallback(func([]models.Item))
	//RemoveItemsCallback removes items callback if there's any
	RemoveItemsCallback()

	//GetView shows one of predefined views
	GetView(view View)
}

ItemController retrieves children and returns them with ItemsCallback Manages item metadata and not the files themselves. If itemsCallback is not set, no results will be retrieved.

type MediaController

type MediaController interface {
	ItemController
	QueueController
	PlaybackController
}

MusicController gathers all necessary interfaces that can control media and queue plus query item metadata

type PlaybackController

type PlaybackController interface {
	//Pause pauses media that's currently playing. If none, do nothing.
	Pause()
	//Continue continues currently paused media.
	Continue()
	//StopMedia stops playing media.
	StopMedia()
	//Next plays currently next item in queue, if any.
	Next()
	//Previous plays last played song (first in history)
	Previous()
	//Seek seeks forward given seconds
	Seek(seconds int)
	//SeekBackwards seeks backwards given seconds
	SeekBackwards(seconds int)
	//SetStatusCallback sets callback that get's called every time status has changed,
	//including playback progress
	SetStatusCallback(func(state player.PlayingState))
	//SetVolume sets volume to given level in range of [0,100]
	SetVolume(level int)
}

PlaybackController controls media playback. Current status is sent to StatusCallback, if set.

type QueueController

type QueueController interface {
	//GetQueue gets currently ongoing queue of items with complete info for each song
	GetQueue() []*models.SongInfo
	//ClearQueue clears queue. This also calls QueueChangedCallback
	ClearQueue()
	//QueueDuration gets number of queue items
	QueueDuration() int
	//AddItems adds items to the end of queue.
	//Adding items calls QueueChangedCallback
	AddSongs([]*models.Song)
	//Reorder sets item in index currentIndex to newIndex.
	//If either currentIndex or NewIndex is not valid, do nothing.
	//On successful order QueueChangedCallback gets called.
	Reorder(currentIndex, newIndex int)
	//GetHistory get's n past songs that has been played.
	GetHistory(n int) []*models.SongInfo
	//SetQueueChangedCallback sets function that is called every time queue changes.
	SetQueueChangedCallback(func(content []*models.Song))
	//RemoveQueueChangedCallback removes queue changed callback
	RemoveQueueChangedCallback()
}

QueueController controls queue and history If no queueChangedCallback is set, no queue updates will be returned

type View

type View int
const (
	ViewAllArtists View = iota
	ViewAllAlbums
	ViewAllSongs
	ViewFavoriteArtists
	ViewFavoriteAlbums
	ViewFavoriteSongs
	ViewPlaylists
	ViewLatestMusic
)

Source Files

  • content.go
  • interfaces.go
  • queue.go

Jump to

Keyboard shortcuts

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