Closed Bug 1105222 Opened 9 years ago Closed 8 months ago

[meta] Support custom sound files for Web Notifications

Categories

(Core :: DOM: Notifications, defect)

defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: mikedeboer, Unassigned)

References

(Depends on 4 open bugs, )

Details

(Keywords: meta)

Attachments

(1 file)

DOM Web Notifications in Gecko sports a NotificationBehavior dictionary, which allow to specify a custom sound file to be played when the Notification is triggered.

See https://mxr.mozilla.org/mozilla-central/source/dom/webidl/Notification.webidl?rev=9712d6370c3f&mark=65,72,75#58 for the IDL definition.
Please note that this is out of date with the current state of the WHATWG spec at http://notifications.spec.whatwg.org/. We're using a proprietary `mozbehavior` object to specify sound and vibration pattern for B2G/ Gaia.

Example:
```js
new Notification("title", {
  mozbehavior: {
    soundFile: "chrome://url/to/soundFile.ogg"
  }
});
```

As such, this works for FirefoxOS, but not on the major desktop platforms.

This bug tracks that work.
Flags: qe-verify+
Flags: firefox-backlog+
Depends on: 1105225
Depends on: 1105226
Depends on: 1105229
Depends on: 1105230
Component: Widget → Notifications and Alerts
Product: Core → Toolkit
:karlt actually proposed an awesome alternative in https://bugzilla.mozilla.org/show_bug.cgi?id=1105230#c1...

For ease of implementation, I suggest to support _not_ playing a sound - which all desktop notification agents support - at first, so that Notification API consumers can start with playing a sound of their own via the <audio> element.

How does that 'sound'? (no pun intended ;) )
Attached patch WIP patchSplinter Review
This patch does the following:

1) adds an optional `sound` String argument to the `showAlertNotification` function for nsIAlertService.
2) Supports passing sound names to OSX Notification Manager to allow playing built-in sounds or the 'default' one.
3) Implements the behavior in Notification.cpp to see if the sound passed along with `mozBehavior.soundFile` contains a file that might be playable by the <audio> element.
  a) Tries to play the sound using a HTMLAudioElement instance, which crashes the browser atm. Dunno why, my skill is limited here atm.
  b) If no file is detected, pass the raw string to the alert service OS implementation. It may play a built-in sound.
  c) Pass the ASCII string 'default' to the alert service and let OS specific implementation fall back to its default behavior.
This is standardized, so we should use that API rather than invent a proprietary method: https://notifications.spec.whatwg.org/#sound-url
Summary: Support custom sound files for Web Notifications → [meta] Support custom sound files for Web Notifications
Severity: normal → S3
Component: Notifications and Alerts → DOM: Notifications
Product: Toolkit → Core

It's removed from the spec by https://github.com/whatwg/notifications/pull/127 in 2018 because of the lack of implementation. I'll close this assuming there's no active use case as this has been silent since FxOS.

Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.