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

Proposal: audible notifications (play a sound with a notification) #349

Open
hanguokai opened this issue Feb 4, 2023 · 2 comments
Open
Labels
enhancement Enhancement or change to an existing feature neutral: chrome Not opposed or supportive from Chrome neutral: firefox Not opposed or supportive from Firefox neutral: safari Not opposed or supportive from Safari proposal Proposal for a change or new feature

Comments

@hanguokai
Copy link
Member

Overview

When send a notification, play a sound at the same time by specifying an audio file which length is usually about a second. Typical application scenarios like alarms, reminders, notifications, and battery level changes, etc.

This is a strong functional requirement from developers. You can search for "play sound" or "audio notification" in extension developers forum, StackoverFlow, browser's bug trackers and this project, there are many related discussions. So, I don't need to prove the usefulness of this feature.

API

browser.notifications.create(
  id,
  {
    type: "basic",
    iconUrl: "icon.png",
    audio: "notification-sound.mp3", // a new field in NotificationOptions
    title,
    message
  }
)

Web Notification API vs Extension Notification API

Although the functions of these two APIs are similar, the application scenarios of web and extension are obviously different (extensions are more like native apps), which leads to the fact that Web API will be more conservative, while extension API can be more aggressive. So, I think the extension API should support this feature.

Workaround

Note: This api is mainly used from background.

In MV2, event page or background page can play sound directly and easily, i.e. new Audio('sound.mp3').play().

In MV3, service worker can't play sound directly, Chrome supplies the offscreen api as a temporary workaround for general purpose DOM functions.

Because playing a sound with a notification is a very common and highly demanded feature, I think extension notification API should have built-in support for it.

@hanguokai hanguokai added enhancement Enhancement or change to an existing feature agenda Discuss in future meetings proposal Proposal for a change or new feature and removed needs-triage labels Feb 4, 2023
@Rob--W Rob--W added neutral: chrome Not opposed or supportive from Chrome neutral: safari Not opposed or supportive from Safari neutral: firefox Not opposed or supportive from Firefox and removed agenda Discuss in future meetings labels Mar 2, 2023
@Rob--W
Copy link
Member

Rob--W commented Mar 2, 2023

As noted in today's meeting (#357 , will be published at https://github.com/w3c/webextensions/blob/main/_minutes/2023-03-02-wecg.md), the browser vendors are neutral towards this feature, provided that the flag is advisory and not mandatory. Advisory, in case the platform does not support audio notifications or if the user has chosen to disable/mute audio notifications.

@hanguokai
Copy link
Member Author

The issue claims that the feature is common and highly demanded. Does anyone have data that backs this claim? - A question in the meeting note.

Let me give some links that can reflect the needs of developers and users.

Stackoverflow:

Developers Forum:

Issue Trackers:

Extensions in Web Stores:

  • Email Checker Extensions
  • Battery Level Reminder Extensions
  • Alarm Extensions

Real user reviews from Web Stores:

  • Would be extra brilliant if it comes with audible notifications.
  • I don't know yet if this extension gives an audible notification, but if it does, I'll be even more in love with it.

If you expand the audio notification feature from the web platform to mobile and desktop platforms, you will find more developer and user needs and instances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or change to an existing feature neutral: chrome Not opposed or supportive from Chrome neutral: firefox Not opposed or supportive from Firefox neutral: safari Not opposed or supportive from Safari proposal Proposal for a change or new feature
Projects
None yet
Development

No branches or pull requests

2 participants