Add toggle_playback mapping

This commit is contained in:
aditya-K2
2023-04-16 12:58:35 +05:30
parent d69719389c
commit 93f8bd1c65
4 changed files with 31 additions and 1 deletions

View File

@@ -33,3 +33,20 @@ func PlayContext(context *spotify.URI) error {
PlaybackContext: context,
})
}
func TogglePlayback() error {
p, err := Client.PlayerCurrentlyPlaying(ctx())
if err != nil {
return err
}
if p.Playing {
if err := Client.Pause(ctx()); err != nil {
return err
}
} else {
if err := Client.Play(ctx()); err != nil {
return err
}
}
return nil
}