matrix-react-sdk icon indicating copy to clipboard operation
matrix-react-sdk copied to clipboard

Prevent Element appearing in system media controls

Open SuperKenVery opened this issue 2 years ago • 10 comments

Use WebAudio API to play notification sound, so that it won't appear in system media control.

For now, if I leave element web in the background, it would have an <audio> element for playing notification sound, and there will be an entry in system media controls, making it impossible to control other music with media keys on the keyboard. This pr aims to fix that.

Before: image

After: image

Checklist

  • [ ] Tests written for new code (and old code if feasible)
  • [x] Linter and other CI checks pass
  • [x] Sign-off given on the changes (see CONTRIBUTING.md)

Signed-off-by: 许煜恒 [email protected]

Type: defect


Here's what your changelog entry will look like:

🐛 Bug Fixes

  • Prevent Element appearing in system media controls (#10995). Contributed by @SuperKenVery.

SuperKenVery avatar May 26 '23 11:05 SuperKenVery

Ah, it seems that the latest commit of develop branch is broken... The page won't start on my machine. So I based my work on an earlier commit.

SuperKenVery avatar May 26 '23 11:05 SuperKenVery

Corresponding element-web pr: https://github.com/vector-im/element-web/pull/25477

TODOs are now done 😄

SuperKenVery avatar May 30 '23 10:05 SuperKenVery

It seems that Jest doesn't support WebAudio API, which means it won't be possible for me to pass the tests 🤣

https://github.com/jsdom/jsdom/issues/2900#issuecomment-599795854

SuperKenVery avatar May 31 '23 00:05 SuperKenVery

Phew, now I've got (almost, see below) all <audio> tags removed and use WebAudioAPI, and the sounds work normally.

However, as I'm not familiar with the project, there's probably more to be cleaned up or even my code can be organized better... Tell me if any!

There's still one <audio id="remoteAudio"></audio>. I'm not sure what it does, and it seems that it's only used in tests, so I don't know what to do with it. However it's never played so I think even leaving it there wouldn't be a problem.

SuperKenVery avatar Jun 27 '23 04:06 SuperKenVery

Does this also fix https://github.com/vector-im/element-web/issues/18643?

t3chguy avatar Jul 14 '23 13:07 t3chguy

Does this also fix vector-im/element-web#18643?

I believe so, it should also fix that issue. Actually I'm doing this because of that issue 🤣 But I didn't find that one and just filed a pr 😃

SuperKenVery avatar Jul 15 '23 13:07 SuperKenVery

This looks sane but needs some mocks created to pass tests, are you interested in getting this over the line?

t3chguy avatar Jun 20 '24 16:06 t3chguy

I have zero experience in writing UI tests and mocks, and unfortunately I’m quite busy recently so :( No quite interested, sorry😮‍💨在 2024年6月21日,上午12:28,Michael Telatynski @.***> 写道: This looks sane but needs some mocks created to pass tests, are you interested in getting this over the line?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

SuperKenVery avatar Jun 21 '24 00:06 SuperKenVery

I think we'll close this for now as it will need to pass the testing bar to get merged. If someone else wants to pick it up, they can always open a fresh PR. Ideally it would convert the various uses of audio separately to make smaller PRs. It will obviously need serious testing.

dbkr avatar Jun 27 '24 09:06 dbkr

This is on my plate to get over the line

t3chguy avatar Jul 01 '24 08:07 t3chguy