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

Should we allow linking AudioSessions to each HTMLMediaElement/AudioContext object? #5

Open
youennf opened this issue Nov 8, 2022 · 7 comments
Labels

Comments

@youennf
Copy link
Contributor

youennf commented Nov 8, 2022

Is it useful to set a particular AudioSession to a particular HTMLMediaElement/AudioContext?

@jernoble
Copy link

I think it is. A site may have both alert sounds ("transient") and a music stream ("playback"). It would be convenient to allow alert sounds to duck playback the same way a system alert sound would, without requiring the page to "re-invent the wheel" and implement ducking manually.

@jernoble
Copy link

The most straightforward API design would involve monkey-patching HTML to add a .audioSession property on HTMLMediaElement and AudioContext. I don't know how this would work for navigator.mediaDevices.getUserMedia() however. Maybe navigator.mediaDevices.getUserMedia({audio: { audioSession: captureSession }})?

@jernoble
Copy link

Alternatively, the MediaStream returned by getUserMedia() could have a .audioSession property. But we'd need a the MediaStream to start out deactivated.

@youennf
Copy link
Contributor Author

youennf commented Dec 1, 2022

Right, this would require such setters/getters, plus AudioSession constructor, plus requestFocus/releaseFocus.
This seems potentially useful as a second step.

@youennf
Copy link
Contributor Author

youennf commented Dec 1, 2022

For instance

partial interface AudioSession {
  constructor();

  // Request audio focus from the platform. Resolves with true if the request was successful.
  Promise<bool> request();

  // Abandons audio focus. Rejects with an error if the session does not have audio focus.
  Promise<void> abandon();
};

@tguilbert-google
Copy link
Member

tguilbert-google commented Jan 3, 2023

A site may have both alert sounds ("transient") and a music stream ("playback").

+1 one to this question/issue/answer. I support adding a way to allow transient sounds from sites with longer playback.

@chrisn chrisn added the TPAC2024 label Aug 1, 2024
@youennf
Copy link
Contributor Author

youennf commented Sep 19, 2024

Tentative TPAC 2024 proposal: add the following abilities in the roadmap, and discuss whether V1 or not:

  • Allow setting AudioSession on HTMLMediaElement and AudioContext (maybe getUserMedia and getDisplayMedia in the future).
  • AudioSession constructor
  • AudioSession focus API

@tidoust tidoust transferred this issue from w3c/audio-session-fork Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants