Clock icon indicating copy to clipboard operation
Clock copied to clipboard

Integrate external music sources for usage as alarms.

Open 0009-0009-1013-986X opened this issue 2 years ago • 15 comments

Checklist

  1. [X] I made sure that there are no existing issues - open or closed - to which I could contribute my information.
  2. [X] I made sure that there are no existing discussions - open or closed - to which I could contribute my information.
  3. [X] I have read the FAQs inside the app (Menu -> About -> FAQs) and my problem isn't listed.
  4. [X] I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
  5. [X] This issue contains only one feature request.
  6. [X] I have read and understood the contribution guidelines.
  7. [ ] I optionally donated to support the Fossify mission.

Feature description

I want a way to play a different (random) song of my choice every day. If Clock invoked com.android.documentsui (the File Picker) I could use something like stable-3.28.1 to provide a directory of musical files (with a playlist file). Although I'd prefer integration with Spotify and YouTube, I expect that that is infeasible or undesirable (despite the public API of at least the former).

Why do you want this feature?

I sleep through every alarm if they repeat each day. They must be different each day for me to wake.

Additional information

As newsroom.spotify.com/2018-07-31/wake-up-to-the-perfect-soundtrack-with-spotify-and-clock-app-from-google explains, google-clock-7-7-602251855-3 provides the ability to choose a random music track from YouTube Music or Spotify. I use it every day. I won't want to utilise Fossify Clock without an alternative.

0009-0009-1013-986X avatar Mar 27 '24 00:03 0009-0009-1013-986X

Hi! I am Rocco, a student from the Netherlands, and I would like to work on this feature!

Roccovdberg avatar May 30 '24 11:05 Roccovdberg

@Roccovdberg

image.png

Aga-C avatar May 30 '24 12:05 Aga-C

Oh okay thankyou

Roccovdberg avatar May 30 '24 13:05 Roccovdberg

No use for Spotify or Youtube here, but I would love to wake up listening to a randomly generated playlist from my locally stored music files. In fact, I'm now searching for years for an app which can do this and is still in development.

Would be willing to contribute financially for this feature.

drhirn avatar Dec 12 '24 10:12 drhirn

Integrating with Spotify or Youtube directly might be tricky (I mean, it's actually not because both apps offer a protocol that makes it easy to command them to play music) but to make this both easier for the devs and more versatile for power users, it would be sufficient to simply allow this app to send a custom Intent when an alarm rings, is snoozed, and is dismissed. It would be the user's responsibility to correctly format the intent to command Spotify (or any music app of their choice, really) to start/stop playing.

e-t-l avatar Jun 18 '25 19:06 e-t-l

https://github.com/FossifyOrg/Clock/issues/43#issuecomment-2985495437

@e-t-l, that's more what Tasker's for. Copying how Muntashirakon's App Manager allows the user to customise intents would be rather an unnecessary duplication of effort, considering that even if that were the approach, integrating the correct intent would be trivial for the developer – they're adequately stable. I don't know whether this functionality is exposed as an intent, though.

0009-0009-1013-986X avatar Jun 18 '25 20:06 0009-0009-1013-986X

integrating the correct intent would be trivial for the developer – they're adequately stable.

True, I was thinking in terms of providing maximum versatility. As it's often power users who prefer Fossify and degoogling, folks may not be satisfied with an implementation that copies the current Google Clock app—i.e. choosing to play music from Spotify, Youtube, or a limited list of other apps—and would prefer the ability to configure alarms to trigger ANY music app (or any other app, really) to their hearts' desire.

I don't know whether this functionality is exposed as an intent, though.

It is!

e-t-l avatar Nov 14 '25 02:11 e-t-l

folks may not be satisfied with an implementation that copies the current Google Clock app—i.e. choosing to play music from Spotify, Youtube, or a limited list of other apps—and would prefer the ability to configure alarms to trigger ANY music app

@e-t-l, I certainly agree. Originally, I thought that a method of achieving this via com.android.intentresolver.ChooserActivity would be ideal. However, in retrospect, there's no standard URN for specific tracks (that AOSP music clients adhere to). Perhaps, because intents can be formed as URIs, a single intent: URI input form would be suitable:

  1. intent:#Intent;action=android.intent.action.SEND;type=text/plain;launchFlags=0x1b080000;S.android.intent.extra.TEXT=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0l9pS6L9cVg;end

  2. intent:#Intent;action=android.intent.action.SEND;type=text/plain;launchFlags=0x1b080000;S.android.intent.extra.TEXT=https%3A%2F%2Fopen.spotify.com%2Ftrack%2F1VMhYYqe38ytNUaPMGpCJ0;end

One unfortunate problem with this, however, is that ChooserActivity doesn't enumerate com.spotify.music for HTTP[S] URIs containing open.spotify.com as their domain. Instead, the process for acquiring an intent is quite involved, per MuntashirAkon/AppManager/issues/1822, when possible... I'm no AOSP developer, but would that use case thus require that Clock directly integrate with a receiver of Spotify's? (That's not ideal, for ideologically FOSS software.)

0009-0009-1013-986X avatar Nov 14 '25 12:11 0009-0009-1013-986X

I don't think ChooserActivity or a HTTPS calls (to youtube.com, open.spotify.com, etc) would work well, because this is something most users would likely want their alarm sound to happen without launching a new app, and with the phone locked.

I'm no developer either, ~~but if you look at the SDK I linked~~, I believe the Spotify app registers an actual spotify: URI protocol, which has a straightforward syntax for specifying what track/playlist to play. I imagine the Youtube Music app does something similar.

EDIT: I actually misremembered, the Spotify SDK is not what we would want to use. All we need is the Spotify URI scheme: https://developer.spotify.com/documentation/android/tutorials/content-linking

e-t-l avatar Nov 14 '25 20:11 e-t-l

@e-t-l, yes, I'm aware of that, but I hoped a more generic implementation might be possible. Do we need to special-case Spotify (and/or YT Music, although that's less probable)? If we do, someone shall inevitably request SoundCloud support, etcetera…

Directly invoking intents of external packages, versus invoking the ChooserActivity, is like calling example.com as an argument to firefox, versus xdg-open or Start-Process.

0009-0009-1013-986X avatar Nov 14 '25 20:11 0009-0009-1013-986X

I'm confused by what you're asking. It's an intent, there's nothing more generic than that. There's no "special case" involved. Did you read the links I shared?

e-t-l avatar Nov 14 '25 22:11 e-t-l

@e-t-l, yes, albeit not as well as I should have.

Mostly, I explained myself poorly: I hoped that a URN might exist to identify a track across services, rather than a URI with a custom schema. [^2] However, I don't see any record labels registering a URN for tracks, so it doesn't appear to exist. [^3]

[^3]: svrooij/sonos-api-docs/blob/09b87e2508d758b26f5e7723ac7a6bccc9d63c5f/docs/metadata.md?plain=1#L27-L32 wouldn't need to be nearly as complex if they did.

[^2]: reddit.com/r/shortcuts/comments/1jn2hzn almost provides a more comprehensive overview than the official documentation.

0009-0009-1013-986X avatar Nov 15 '25 14:11 0009-0009-1013-986X

Ohhh I understand. No, I do not believe there is a universal schema for identifying tracks or playlists. Having Fossify Clock trigger launch an intent would allow users to craft intents to trigger playback on whatever service they like, including Spotify or Youtube or others. But yes, they would have to craft an intent specific to that service.

I was under the impression that the main debate was: Should Fossify Clock only expose a customizable intent interface (and leave it up to the users to figure out the URI schemes), or should it come "pre-loaded" with some popular intents (Spotify, Youtube, Pandora) like how the Google Clock app does? Or should it offer both?

e-t-l avatar Nov 15 '25 17:11 e-t-l

@e-t-l, both would be ideal! However, I know that some maintainers want to ensure that they don't depart far from the original “simple” philosophy of its predecessor.

0009-0009-1013-986X avatar Nov 16 '25 11:11 0009-0009-1013-986X

That's a valid concern! I don't know whether the philosophy of Fossify focuses more on "simple" backend design to keep the app small and easy to maintain, or "simple" frontend to give straightforward, minimalist interfaces. Having just a customizable intent action would definitely be simpler backend. Having pre-configured actions for specific music apps would be simpler frontend. If simpler frontend is the goal, maybe we could still expose a fully customizable intent action behind an "Advanced" sub-setting, or an "I know what I'm doing" checkbox?

e-t-l avatar Nov 16 '25 19:11 e-t-l