extensions icon indicating copy to clipboard operation
extensions copied to clipboard

[Music] Add an option to toggle repeat

Open anupchavan opened this issue 1 year ago • 2 comments

Extension

https://www.raycast.com/fedevitaledev/music

Description

Hello, I don't know if I can create a pull request for extensions, but here's the code: toggle-repeat.tsx in util

import { showToast, Toast } from "@raycast/api";
import { pipe } from "fp-ts/lib/function";
import * as TE from "fp-ts/TaskEither";

import * as music from "./util/scripts";
import { handleTaskEitherError } from "./util/utils";

export default pipe(
	music.player.repeat.toggle,
	TE.chain(() => music.player.repeat.get),
	handleTaskEitherError("Failed to toggle repeat", (status) =>
		showToast(Toast.Style.Success, `Repeat ${status ? "On" : "Off"}`)
	)
);

add in play-controls:

const getRepeatStatus = pipe(tell("Music", "get song repeat"), TE.map((s) => s === "one"));
const setRepeatStatus = pipe(
	RTE.ask<boolean>(),
	RTE.chainTaskEitherK((isEnabled) => tell("Music", `set song repeat to ${isEnabled ? "one" : "off"}`))
);
export const repeat = {
	get: getRepeatStatus,
	set: setRepeatStatus,
	toggle: pipe(getRepeatStatus, TE.chain((enabled) => setRepeatStatus(!enabled))),
};

Update package.json:

{
      "name": "toggle-repeat",
      "title": "Toggle Repeat",
      "subtitle": "Apple Music",
      "description": "Toggle Repeat",
      "disabledByDefault": false,
      "mode": "no-view"
    },

Who will benefit from this feature?

Anyone who would want to quickly change the repeat mode to on -- to listen to a song on loop.

Anything else?

No response

anupchavan avatar Feb 23 '25 15:02 anupchavan

Thank you for opening this issue!

🔔 @Rawnly @peterdev22 @danpalmer @octoxan @Shpigford @urwrstkn8mare @michalzuch @validatedev you might want to have a look.

💡 Author and Contributors commands

The author and contributors of fedevitaledev/music can trigger bot actions by commenting:

  • @raycastbot close this issue Closes the issue.
  • @raycastbot close as not planned Closes the issue as not planned.
  • @raycastbot rename this issue to "Awesome new title" Renames the issue.
  • @raycastbot reopen this issue Reopens the issue.
  • @raycastbot assign me Assigns yourself to the issue.
  • @raycastbot good first issue Adds the "Good first issue" label to the issue.
  • @raycastbot keep this issue open Make sure the issue won't go stale and will be kept open by the bot.

raycastbot avatar Feb 23 '25 15:02 raycastbot

ofc you can create a PR! I'd be happy to review it and approve!

rawnly avatar Feb 23 '25 15:02 rawnly