add interface to decouple MPV player from PlaybackManager

This commit is contained in:
Drew Weymouth
2023-12-18 20:22:24 -08:00
parent 1665281ad7
commit df6c53a3f5
6 changed files with 135 additions and 107 deletions
+48 -1
View File
@@ -1,5 +1,52 @@
package player
type URLPlayer interface {
BasePlayer
AppendFile(url string) error
PlayFile(url string) error
}
type TrackIDPlayer interface {
BasePlayer
AppendTrack(trackID string) error
PlayTrack(trackID string) error
}
type BasePlayer interface {
// Transport
PlayTrackAt(idx int) error
Continue() error
Pause() error
PlayPause() error
Stop() error
SeekPrevious() error
SeekNext() error
SeekSeconds(secs float64) error
IsSeeking() bool
SetVolume(int) error
GetVolume() int
GetStatus() Status
ClearPlayQueue() error
RemoveTrackAt(idx int) error
SetLoopMode(LoopMode) error
GetLoopMode() LoopMode
// Event API
OnPaused(func())
OnStopped(func())
OnPlaying(func())
OnSeek(func())
OnTrackChange(func(int))
}
type ReplayGainPlayer interface {
SetReplayGainOptions(ReplayGainOptions) error
}
// The playback state (Stopped, Paused, or Playing).
type State int
@@ -15,7 +62,7 @@ type Status struct {
State State
TimePos float64
Duration float64
PlaylistPos int64
PlaylistPos int
}
// The playback loop mode (LoopNone, LoopAll, LoopOne).