Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Music] Add an option to toggle repeat #17261

Open
emotional-emf opened this issue Feb 23, 2025 · 2 comments
Open

[Music] Add an option to toggle repeat #17261

emotional-emf opened this issue Feb 23, 2025 · 2 comments
Labels
extension: music Issues related to the music extension extension Issues related to one of the extensions in the Store feature request New feature or improvement

Comments

@emotional-emf
Copy link

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

@emotional-emf emotional-emf added extension Issues related to one of the extensions in the Store feature request New feature or improvement labels Feb 23, 2025
@raycastbot raycastbot added the extension: music Issues related to the music extension label Feb 23, 2025
@raycastbot
Copy link
Collaborator

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.

@rawnly
Copy link
Contributor

rawnly commented Feb 23, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension: music Issues related to the music extension extension Issues related to one of the extensions in the Store feature request New feature or improvement
Projects
None yet
Development

No branches or pull requests

3 participants