-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/addConfig
- Loading branch information
Showing
5 changed files
with
191 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { IClientContext } from "./main"; | ||
import chalk from "chalk"; | ||
import { pause, next, previous, shuffle, getPlaybackState} from "./endpoints"; | ||
|
||
export async function pauseHandler(clientContext: IClientContext) { | ||
if (clientContext.deviceId) { | ||
await pause(clientContext.service, clientContext.deviceId); | ||
} | ||
} | ||
|
||
export async function nextHandler(clientContext: IClientContext) { | ||
if (clientContext.deviceId) { | ||
await next(clientContext.service, clientContext.deviceId); | ||
} | ||
} | ||
|
||
export async function previousHandler(clientContext: IClientContext) { | ||
if (clientContext.deviceId) { | ||
await previous(clientContext.service, clientContext.deviceId); | ||
} | ||
} | ||
|
||
export async function shuffleHandler(clientContext: IClientContext) { | ||
const playbackState = await getPlaybackState(clientContext.service); | ||
|
||
if (playbackState) { | ||
const oldShuffleState = playbackState.shuffle_state; | ||
|
||
if (clientContext.deviceId) { | ||
console.log(chalk.cyanBright(`Toggling shuffle ${oldShuffleState ? chalk.redBright("off") : chalk.greenBright("on") }`)); | ||
await shuffle(clientContext.service, clientContext.deviceId, !oldShuffleState); | ||
} | ||
} | ||
} |