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

Mac control center support (Fixes #549) #567

Draft
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

Explosion-Scratch
Copy link

Currently only working in the web version

Only working in the web version, not sure why
Copy link

vercel bot commented Mar 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
feishin ❌ Failed (Inspect) Apr 1, 2024 3:04pm

Copy link
Collaborator

@kgarner7 kgarner7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, but I'm not really sure what this is trying to do:

  1. navigator.mediaSession already is in use, but in use-center-controls.ts. While there is some room for improvement there, it does at least work in web browsers on MacOS (Safari, Firefox, Chrome)
  2. The change as proposed is also broken:
    1. Cannot read properties of undefined (reading 'name') when the queue is empty (most likely artist metadata)
    2. More severely, I see Invalid hook call. Hooks can only be called inside the body of a function component about every second.
    3. At least on Feishin Desktop on macOS, this doesn't seem to help either (I don't personally understand why, even with mediaSession set properly MacOS doesn't show)
    4. This removes the ability for mediaSession to play/pause/etc.

I appreciate the time you spent, I would also like this to be fixed on desktop (and less janky elsewhere as well) [I did try and look why mediaSession isn't updating control center, but I haven't found any good leads thus far). But I'd much rather fix the existing implementation (or find out something macOS desktop-only that we're missing in the first place)

@Explosion-Scratch
Copy link
Author

@kgarner7 I've fixed 2.i and 2.ii just now (will push in a few), also mediaSession play pause seems to work fine for me. I'll push in just a sec

@Explosion-Scratch
Copy link
Author

🤦🏻 Didn't even see use-center-controls.ts lol

Could it maybe not be working due to the isElectron() call?

@Explosion-Scratch
Copy link
Author

The issue with electron vs web might be due to BrowserWindow instead of BrowserView:
electron/electron#31448 (comment)

@Explosion-Scratch
Copy link
Author

Explosion-Scratch commented Mar 31, 2024

Using use-center-controls isn't setting navigator.mediaSession at all =/

(I commented out my code when testing this)

@kgarner7
Copy link
Collaborator

It does look like there is an issue where the first track doesn't get metadata, but it definitely sets it otherwise. And I having the actionHandler without isElectron() doesn't seem to help either

@Explosion-Scratch
Copy link
Author

Yeah I've been looking through it - It only seems to update when you click pause and play buttons not on skipping songs. I don't have time to work on it more right now but I can later. Some improvements I want to make though:

  • Update mediaSession on skip back and forward / debug
  • Figure out why electron isn't showing it (it shows MPV when MPV player is selected but no art or anything) - I'm assuming you're using a modernish electron
  • Use Blobs for the images - This fixed a lot of errors for people on stackoverflow 🤷
  • Make sure the handlers don't conflict with media keys - We already sense media keys through global shortcuts but these also are applied to the mac control center so double pause/seek would be bad

@Explosion-Scratch
Copy link
Author

Explosion-Scratch commented Mar 31, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants