start of new simplified player interface

This commit is contained in:
Drew Weymouth
2023-12-21 20:25:52 -08:00
parent 4c3d638aed
commit 0cd58cb51b
2 changed files with 46 additions and 0 deletions
+13
View File
@@ -193,6 +193,19 @@ func (p *Player) ClearPlayQueue() error {
return p.mpv.Command([]string{"playlist-clear"})
}
func (p *Player) SetFile(url string) error {
if !p.initialized {
return ErrUnitialized
}
if err := p.mpv.Command([]string{"stop"}); err != nil {
return err
}
if err := p.mpv.Command([]string{"playlist-clear"}); err != nil {
return err
}
return p.mpv.Command([]string{"loadfile", url, "append"})
}
// Seeks within the currently playing track.
// See MPV seek command documentation for more details.
func (p *Player) SeekSeconds(secs float64) error {
+33
View File
@@ -7,11 +7,23 @@ type URLPlayer interface {
AppendFile(url string) error
}
type URLPlayerNew interface {
BasePlayer
SetFile(url string)
SetNextFile(url string)
}
type TrackPlayer interface {
BasePlayer
AppendTrack(track *mediaprovider.Track) error
}
type TrackPlayerNew interface {
BasePlayer
SetTrack(track *mediaprovider.Track) error
SetNextTrack(track *mediaprovider.Track) error
}
type BasePlayer interface {
// Transport
PlayTrackAt(idx int) error
@@ -42,6 +54,27 @@ type BasePlayer interface {
OnTrackChange(func(int))
}
type BasePlayerNew interface {
Continue() error
Pause() error
Stop() error
SeekSeconds(secs float64) error
IsSeeking() bool
SetVolume(int) error
GetVolume() int
GetStatus() Status
// Event API
OnPaused(func())
OnStopped(func())
OnPlaying(func())
OnSeek(func())
OnTrackChange(func(int))
}
type ReplayGainPlayer interface {
SetReplayGainOptions(ReplayGainOptions) error
}