Documentation ¶
Index ¶
- Variables
- type Config
- type PathReplacement
- type PlaylistFile
- type PluginApi
- type PluginServer
- type Server
- func (s *Server) AddDirectory(dir directories.Entry) error
- func (s *Server) AddRootDirectories(rootDirectories []directories.Entry)
- func (s *Server) ChangeAudio(audioId string) error
- func (s *Server) ChangeChapter(idx int64) error
- func (s *Server) ChangeChaptersOrder(chapters []int64, force bool) error
- func (s *Server) ChangeFullscreen(fullscreen bool) error
- func (s *Server) ChangePause(paused bool) error
- func (s *Server) ChangeSubtitle(subtitleID string) error
- func (s *Server) DefaultPlaylistSelected() bool
- func (s *Server) LoadFile(filePath string, append bool) error
- func (s *Server) LoadFileByUuid(uuid string, append bool) error
- func (s *Server) LoadPlaylist(uuid string, append bool) error
- func (s *Server) LoopFile(looped bool) error
- func (s *Server) PlaylistPlayIndex(idx int) error
- func (s *Server) Serve() error
- func (s *Server) StopPlayback() error
- func (s *Server) StopServing(reason string) error
- func (s *Server) TakeDirectory(path string) (directories.Entry, error)
- func (s *Server) WaitUntilMediaFileByPath(mediaFilePath string) error
- func (s *Server) WaitUntilMediaFileByUuid(uuid string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrResponseDataNotString occurs when observe response data is not a string. ErrResponseDataNotString = errors.New("response data is not a string") // ErrResponseDataNotInt occurs when observe response data is not an integer. ErrResponseDataNotInt = errors.New("response data is not an integer") // ErrResponseDataNotExpectedFormatNode occurs when observe response data is not expected MPV_FORMAT_NODE type. ErrResponseDataNotExpectedFormatNode = errors.New("response data is not of expected MPV_FORMAT_NODE type") // ErrPlaybackTimeNotFloat occurs when playback time is not a correct decimal number. ErrPlaybackTimeNotFloat = errors.New("playback time could not be converted to a float number") // ErrPlaybackPathNotServed occurs when playback path is set to file that is not being served by api. ErrPlaybackPathNotServed = errors.New("playback path is not served") // ErrPlaylistMapDataNotParsable occurs when data being sent during observation of MPV's "playlist" property is not a correct JSON. ErrPlaylistMapDataNotParsable = errors.New("could not parse playlist map data as JSON") )
var (
ErrJSONFileNotAPlaylistFile = errors.New("a JSON file is not a valid playlist file - 'mpvWebApiPlaylist' either not specified or false")
)
var ( // ErrPathNotDirectory occurs when provided path is not pointing to a directory. ErrPathNotDirectory = errors.New("path does not point to a directory") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Address string AllowCORS bool ErrWriter io.Writer MpvSocketPath string PathReplacements []PathReplacement PlaylistFilesPrefixes []string OutWriter io.Writer SocketConnectionTimeout time.Duration StartMpvInstance bool StatesRepository state.Repository PluginServers map[string]PluginServer }
Config controls behaviour of the api server.
type PathReplacement ¶
type PlaylistFile ¶
type PlaylistFile struct { CurrentEntryIdx int `json:"CurrentEntryIdx"` DirectoryContentsAsEntries bool `json:"DirectoryContentsAsEntries"` Entries []playlists.Entry `json:"Entries"` MpvWebApiPlaylist bool `json:"MpvWebApiPlaylist"` Name string `json:"Name"` Description string `json:"Description"` }
type PluginApi ¶
type PluginApi interface { AddRootDirectories(directories []directories.Entry) ChangeChaptersOrder(chapters []int64, force bool) error TakeDirectory(path string) (directories.Entry, error) LoadPlaylist(uuid string, append bool) error LoadFile(filePath string, append bool) error LoadFileByUuid(uuid string, append bool) error ChangeFullscreen(fullscreen bool) error ChangeAudio(audioId string) error ChangeChapter(idx int64) error ChangeSubtitle(subtitleId string) error LoopFile(looped bool) error ChangePause(paused bool) error PlaylistPlayIndex(idx int) error StopPlayback() error WaitUntilMediaFileByPath(mediaFilePath string) error WaitUntilMediaFileByUuid(uuid string) error }
type PluginServer ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is used to serve API and hold state accessible to the API.
func (*Server) AddDirectory ¶
func (s *Server) AddDirectory(dir directories.Entry) error
func (*Server) AddRootDirectories ¶
func (s *Server) AddRootDirectories(rootDirectories []directories.Entry)
AddRootDirectories adds root directories with media files to be handled by the server. If the Directory entries are already present, they are overwritten along with their properties (watched, recursive, etc.). TODO2: at the moment no error is being returned from the directories adding, however some information about unsuccessful attempts should be returned in addition to just printing it in server (for example for REST responses).
func (*Server) ChangeAudio ¶
func (*Server) ChangeChapter ¶
func (*Server) ChangeChaptersOrder ¶
func (*Server) ChangeFullscreen ¶
func (*Server) ChangePause ¶
func (*Server) ChangeSubtitle ¶
func (*Server) DefaultPlaylistSelected ¶
func (*Server) LoadPlaylist ¶
LoadPlaylist instructs mpv to add entries of a playlist to the mpv internal playlist. UUID is a key of a playlist that is unique in the scope of a server's instance. Append specifies whether the playlist should be added to the end of the currently played playlist. When append is false, the new playlist overwrites current playlist and starts playing it immediately. When append is true, a default playlist will be selected and updated with entries from both previously selected playlist and a new appended one (mpv will emit change to playlist property which will set the entries on the default playlist).
func (*Server) PlaylistPlayIndex ¶
func (*Server) Serve ¶
Serve starts handling plugin API servers passed to the server. It also starts mpv manager and (if neccessary). Blocks until either mpv manager or http server stops serving (with error or nil).
func (*Server) StopPlayback ¶
func (*Server) StopServing ¶
StopServing instructs server to close API servers & mpv manager with a provided reason.
func (*Server) TakeDirectory ¶
func (s *Server) TakeDirectory(path string) (directories.Entry, error)