MCPcopy Create free account
hub / github.com/dinofizz/diskplayer / Pause

Function Pause

diskplayer.go:77–102  ·  view source on GitHub ↗

Pause will pause the Spotify playback if the Diskplayer is the currently active Spotify device. An error is returned if one is encountered.

(c Client)

Source from the content-addressed store, hash-verified

75// Pause will pause the Spotify playback if the Diskplayer is the currently active Spotify device.
76// An error is returned if one is encountered.
77func Pause(c Client) error {
78 n := ConfigValue(SPOTIFY_DEVICE_NAME)
79 ds, err := c.PlayerDevices()
80 if err != nil {
81 return err
82 }
83
84 activeID := activePlayerId(&ds)
85 if activeID == "" {
86 return nil
87 }
88
89 playerID := diskplayerId(&ds, n)
90 if playerID == "" {
91 return fmt.Errorf("client identified by %s not found", n)
92 }
93
94 if activeID == playerID {
95 err := c.Pause()
96 if err != nil {
97 return err
98 }
99 }
100
101 return nil
102}
103
104// activePlayerIds iterates through the provided player devices and returns the active ID. If there is no active
105// Spotify client device the ID will be returned as a nil pointer.

Callers 6

mainFunction · 0.92
TestPauseSuccessFunction · 0.85
TestPauseDeviceNotFoundFunction · 0.85
TestPauseErrorFunction · 0.85

Calls 5

ConfigValueFunction · 0.85
activePlayerIdFunction · 0.85
diskplayerIdFunction · 0.85
PlayerDevicesMethod · 0.65
PauseMethod · 0.65

Tested by 5

TestPauseSuccessFunction · 0.68
TestPauseDeviceNotFoundFunction · 0.68
TestPauseErrorFunction · 0.68