Can control playlist
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
nemunaire 2024-01-07 15:01:03 +01:00
commit f7760416b9
7 changed files with 257 additions and 10 deletions

View file

@ -228,3 +228,63 @@ func (s *MPVSource) TogglePause(id string) error {
return nil
}
func (s *MPVSource) HasPlaylist() bool {
if s.ipcSocketDir == "" {
return false
}
conn := mpvipc.NewConnection(s.ipcSocket())
err := conn.Open()
if err != nil {
return false
}
defer conn.Close()
plistCount, err := conn.Get("playlist-count")
if err != nil {
return false
}
return plistCount.(float64) > 1
}
func (s *MPVSource) NextTrack() error {
if s.ipcSocketDir == "" {
return fmt.Errorf("Not supported")
}
conn := mpvipc.NewConnection(s.ipcSocket())
err := conn.Open()
if err != nil {
return err
}
defer conn.Close()
_, err = conn.Call("playlist-next", "weak")
if err != nil {
return err
}
return nil
}
func (s *MPVSource) PreviousTrack() error {
if s.ipcSocketDir == "" {
return fmt.Errorf("Not supported")
}
conn := mpvipc.NewConnection(s.ipcSocket())
err := conn.Open()
if err != nil {
return err
}
defer conn.Close()
_, err = conn.Call("playlist-prev", "weak")
if err != nil {
return err
}
return nil
}