diff --git a/index.bs b/index.bs index 8a32fbf..d025061 100644 --- a/index.bs +++ b/index.bs @@ -14,7 +14,7 @@ Abstract: notification areas and on lock screens of mobile devices. !Participate: File an issue (open issues) !Participate: IRC: #whatwg on Freenode !Version History: https://github.com/whatwg/mediasession/commits -Ignored Vars: context, media +Ignored Vars: context, media, session Boilerplate: omit conformance, omit feedback-header @@ -155,35 +155,12 @@ urlPrefix: https://heycam.github.io/webidl/ This section is non-normative. -Media is used extensively today on the web to play a variety of different types -of content. It is often used to play music, podcasts and radio content. At other -times web media is used to provide background music, sound effects, notification -sounds and to render WebRTC media stream content. - -When playing media on the web, developers are currently forced to adopt a single -default platform modality for playing all media content. On the other hand, -native applications can access much richer media integration options with an -underlying platform. On mobile devices, native application developers can -request many different forms of media integration with the platform to obtain -access to headphone buttons, lock screens and notification areas as needed. On -desktop devices, native applications have access to keyboard media key events. -Native application developers can specify the conditions in which media content -should pause or duck on audio interruptions (i.e. pause or lower the volume for -the duration of an interruption), continue playing out when application focus is -lost or the device screen is switched off and interface with internal and -external remote controllers. - -This specification provides these platform media integration features for web -media. By allowing web developers to express the intended usage of their media -content, user agents can supply the most suitable platform-level interactions -for that content and enforce logical interoperation behavior on the current -platform between any number of different sources of media. - -This specification describes the mechanism that allows web developers to specify -the most appropriate kind for their media content and for user agents to then -use these supplied hints to enforce how different sources of web media should -interact with each other, other native media content and the underlying -platform. +Media is used extensively today, and the Web is one of the primary means of +consuming media content. Many platforms can display media metadata, such as +title, artist, album and album art on various UI elements such as notification, +media control center, device lockscreen and wearable devices. This specification +aims to enable web pages to specify the media metadata to be displayed in +platform UI, which helps in improving the user experience.

Conformance

@@ -226,23 +203,20 @@ conforming IDL fragments, as described in the Web IDL specification. [[!WEBIDL]]

The {{MediaSession}} interface

-[Constructor(optional MediaSessionKind kind = "content")]
-interface MediaSession {
-  readonly attribute MediaSessionKind kind;
-  attribute MediaMetadata? metadata;
-
-  Promise<void> activate();
-  Promise<void> deactivate();
+[Exposed=(Window)]
+partial interface Navigator {
+  readonly attribute MediaSession mediaSession;
 };
 
-enum MediaSessionKind {
-  "content",
-  "transient",
-  "transient-solo",
-  "ambient"
+interface MediaSession {
+  attribute MediaMetadata? metadata;
 };
 
+The mediaSession attribute is +to retrive an instance of the {{MediaSession}} interface. The attribute MUST +return the {{MediaSession}} instance associated with the {{Navigator}} object. + {{MediaSession}} objects are simply known as media sessions. @@ -250,19 +224,6 @@ A media session has metadata, which is either a {{MediaMetadata}} object or null.
-
- session = new MediaSession([kind]) -
-
- Returns a new {{MediaSession}} object. -
-
- session . {{MediaSession/kind}} -
-
- Returns the media session's kind. -
session . {{MediaSession/metadata}}
@@ -272,865 +233,17 @@ which is either a {{MediaMetadata}} object or null. Can be set, to a {{MediaMetadata}} object or null. -
- session . {{MediaSession/activate()}} -
-
- Requests platform-level media focus and sets the media session's - state to active. - - Throws a {{NotAllowedError}} exception if the request was denied by the user - agent or the platform. -
-
- session . {{MediaSession/deactivate()}} -
-
- Releases platform-level media focus and sets the media session's - state to idle. -
-The MediaSession(kind) -constructor, when invoked, must return a new media session whose -kind is kind, and state is idle. - -The kind -attribute must return the media session's kind. - The metadata attribute, on getting, must return the media session's metadata. -The activate() method, when -invoked, must run these steps: - -
    -
  1. - Let media session be the context object. -
  2. -
  3. - Let promise be a new promise. -
  4. -
  5. - Return promise, and run the remaining steps in parallel. -
  6. -
  7. - Activate media session. -
  8. -
  9. - If activate failed, reject promise with a - {{NotAllowedError}} exception. -
  10. -
  11. - Otherwise, fulfill promise with undefined. -
  12. -
- -Note: {{activate()}} can fail if there is an ongoing high-priority activity, -e.g. a phone call. - -The deactivate() method, when -invoked, must run these steps: - -
    -
  1. - Let media session be the context object. -
  2. -
  3. - Let promise be a new promise. -
  4. -
  5. - Return promise, and run the remaining steps in parallel. -
  6. -
  7. - Deactivate media session. -
  8. -
  9. - Fulfill promise with undefined. -
  10. -
- -Note: Unlike {{activate()}}, {{deactivate()}} cannot fail. - -

States

- -A media session has a state that describes -its current status with respect to any platform-level interactions and -interactions with other media sessions. The possible values are as -follows: - -
-
- idle -
-
- The media session does not have any platform-level media focus nor is - it in a suspended state. -
-
- active -
-
- The media session currently has platform-level media focus. -
-
- interrupted -
-
- The media session is currently suspended from having platform-level - media focus and its audio-producing participants are either paused or - ducked based on the media session's kind. -
-
- -

Kinds

- -A media session has a kind which is one of -"content", "transient", -"transient-solo" and "ambient". - -
- The following table lists the available kinds, their associated - behavior, and examples of when they are appropriate to use. - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KindBehaviorExamples
- "content" - - - - Music, podcasts, radio streams. -
- "transient" - - - - Notification sounds. Spoken driving directions where playback of music - in the background is acceptable. -
- "transient-solo" - - - - Playback of driving directions. Other spoken notifications. -
- "ambient" - -
    -
  • - Does not interact with any other "content", - "transient", - "transient-solo" or - "ambient" content during playback. -
  • -
  • - Does not display lock-screen and notification area user interfaces - when playback begins. -
  • -
  • - Does not react to changes in both hardware and software-based media - key buttons when playback - begins. -
  • -
  • - Pauses itself when its top-level browsing context is - not visible (i.e. the page is placed in the background or the user - agent is minimized or the screen is switched off). Unpauses - itself when its - top-level browsing context is at least partially visible on - at least one screen again (i.e. the user agent is in the foreground - and the page is focused again). -
  • -
-
- UI sounds. In-game sound effects and background music. -
-
- -

Participants

- -An audio-producing object is any object or element that is capable of -emitting sound within the user agent and is therefore also potentially capable -of interacting with the media focus system available in different underlying -platforms. - -An audio-producing object may have a current media session, -which is a media session. - -A media session may have one or more audio-producing objects -attached to it; called its audio-producing participants. A media -session must keep a list of its audio-producing participants that -consists of zero of more audio-producing objects. - -A media session has a resume list that is used internally to -restore audio-producing participants at the end of an interruption that -were playing, or were otherwise running, when that interruption started. The -resume list may consist of zero or more audio-producing objects -that must also be present in the media session's list of -audio-producing participants. When a new media session is created -its resume list must be empty. - -When the user agent is to pause a given audio-producing -object it must run the following steps: - -
    -
  1. - If audio-producing object is an {{HTMLMediaElement}} object, then - pause media element - audio-producing object and terminate these steps. -
  2. -
  3. - If audio-producing object is an {{AudioContext}} object, then - suspend web audio object - audio-producing object and terminate these steps. -
  4. -
- -When the user agent is to indefinitely pause a given -audio-producing object, the user agent must pause -audio-producing object and, then proceed to remove it from its -current media session's list of -audio-producing participants. - -When the user agent is to unpause a given audio-producing -object it must run the following steps: - -
    -
  1. - If audio-producing object is an {{HTMLMediaElement}} object, then - unpause media element - audio-producing object and terminate these steps. -
  2. -
  3. - If audio-producing object is an {{AudioContext}} object, then - resume web audio object - audio-producing object and terminate these steps. -
  4. -
- -When an audio-producing object is to duck the user agent must -ensure its output volume is lowered. - -When an audio-producing object is to unduck the user agent -should restore its output volume to the same level that was observed prior to -the original corresponding duck request. - -

- When an audio-producing object is ducked any reduction - in volume applied by the user agent is not intended to be observable to web - pages. -

- -

Activating a media session

- -To activate a media session, run these steps: - -
    -
  1. - If media session is already active, then return success. -
  2. -
  3. - Optionally, based on platform conventions, request the most appropriate - platform-level media focus for media session based on its - kind. - - If this step is run and platform-level media focus can not be obtained for - any reason, then return failure. -
  4. -
  5. - Run these substeps: - -
    -
    - If media session's kind is - "content" -
    -
    -
      -
    1. - Optionally, based on platform conventions, the user agent may show - an ongoing media interface in the underlying platform's - notifications area and/or show an ongoing media interface in the - underlying platform's lock screen area, using any available metadata. -
    2. -
    -
    -
    - If media session's kind is - "transient" or "transient-solo" -
    -
    - The user agent should not provide user access to any hardware or - software media keys and not display any ongoing media interface in the - underlying platform's notifications area or show any ongoing media - interface in the underlying platform's lock screen area for - "transient" or - "transient-solo"-based - media sessions. -
    -
    - If media session's kind is - "ambient" -
    -
    - If media session's top-level browsing context is not - at least partially visible on at least one screen, then return failure. - -

    - The user agent should not provide user access to any hardware or - software media keys and not display any ongoing media interface in the - underlying platform's notifications area or show any ongoing media - interface in the underlying platform's lock screen area for - "ambient"-based media sessions. -

    -
    -
    -
  6. -
  7. - Set media session's resume list to an empty list. -
  8. -
  9. - Set media session's state to - active, then return - success. -
  10. -
- -

Interrupting a media session

- -An active media -session may be interrupted at any time. This typically occurs when another -application or another media session requests and is granted a level of -platform media focus that affects the media session based on its -kind. - -Interruptions can be both transient or permanent. A transient interruption means -we can either choose to duck our media content and continue playing it -out at a reduced volume for the duration of the interruption; or pause -our media content for the duration of the interruption and, then, resume -playback when that interruption ends. A permanent interruption means we must pause our media content indefinitely. - -When a start-of-interruption notification event is received from the platform, -then the user agent must run the -media session interruption algorithm against all known media -sessions, passing in each media session as media session. - -The media session interruption algorithm takes one argument, -media session, and consists of the following steps. - -
    -
  1. - If media session's state is not - active, then terminate - these steps. -
  2. -
  3. - Let interrupting kind be the kind that triggered this - interruption. - - -
  4. -
  5. - Run these substeps: - -
    -
    - If interrupting kind is "content" -
    -
    -
      -
    1. - If media session's kind is - "content" then - indefinitely pause all of media session's - audio-producing participants and set media - session's state to idle. - -

      - This implies that the next time the media session is - activated, that we will re-request media focus according to - the steps defined in that algorithm. -

      -
    2. -
    3. - Optionally, based on platform conventions, the user agent must - remove any previously established ongoing media interface in the - underlying platform's notifications area and any ongoing media - interface in the underlying platform's lock screen area for - media session, if any. -
    4. -
    5. - Optionally, based on platform conventions, the user agent must - prevent any hardware and/or software media keys from controlling - playback of - media session's audio-producing participants. -
    6. -
    -
    -
    - If interrupting kind is "transient" -
    -
    -
      -
    1. - If media session's kind is not - "content", then terminate these steps. -
    2. - -
    3. - For each audio-producing object in media - session's list of audio-producing participants: - -
        -
      1. - If audio-producing object is not currently playing, - or is not otherwise running, then terminate these substeps and - continue at the next available audio-producing - object. -
      2. -
      3. - Duck audio-producing object. -
      4. -
      5. - Add audio-producing object to media - session's resume list. -
      6. -
      -
    4. -
    5. - Set media session's state to interrupted. - -

      - This implies that the next time the media session continuation - algorithm is run for media session that we will - re-activate this media session according to the steps - defined in that algorithm. -

      -
    6. -
    -
    -
    - If interrupting kind is "transient-solo" -
    -
    -
      -
    1. - If media session's kind is not - "content", "transient" or - "transient-solo", then terminate these steps. -
    2. - -
    3. - For each audio-producing object in media - session's list of audio-producing participants: - -
        -
      1. - If audio-producing object is not currently playing, - or is not otherwise running, then terminate these substeps and - continue at the next available audio-producing - object. -
      2. -
      3. - Pause audio-producing object. -
      4. -
      5. - Add audio-producing object to media - session's resume list. -
      6. -
      -
    4. -
    5. - Set media session's state to interrupted. - -

      - This implies that the next time the media session continuation - algorithm is run for media session that we will - re-activate this media session according to the steps - defined in that algorithm. -

      -
    6. -
    -
    -
    -
  6. -
- -

 

- -When an end-of-interruption notification event is received from the platform, -then the user agent must run the media session continuation algorithm -against all known media sessions, passing in each media session as -media session. - -The media session continuation algorithm takes one argument, -media session, and consists of the following steps. - -
    -
  1. - If media session's state is not - interrupted, then - terminate these steps. -
  2. -
  3. - Let interrupting kind be the kind that initially triggered - this interruption. - - -
  4. -
  5. - Run these substeps: - -
    -
    - If interrupting kind is "transient" -
    -
    -
      -
    1. - If media session's kind is not - "content", then terminate these steps. -
    2. -
    3. - Unduck each audio-producing object in media - session's resume list. -
    4. -
    5. - Set media session's resume list to an empty list. -
    6. -
    7. - Set media session's state to active. -
    8. -
    -
    -
    - If interrupting kind is "transient-solo" -
    -
    -
      -
    1. - If media session's kind is not - "content", "transient", or - "transient-solo", then terminate these steps. -
    2. -
    3. - Unpause each audio-producing object in media - session's resume list. -
    4. -
    5. - Set media session's resume list to an empty list. -
    6. -
    7. - Set media session's state to active. -
    8. -
    -
    -
    -
  6. -
- -
- -After a {{visibilitychange}} event has been fired at a top-level browsing -context, known as the browsing context, the user agent must run -the following steps: - -
    -
  1. - If {{visibilityState}} is not "{{hidden}}" or "{{visible}}", then terminate - these steps. -
  2. -
  3. - For each media session in the browsing context with a - kind of "ambient" run the following substeps: - -
      -
    1. - Let s be the current media session. -
    2. -
    3. - If {{visibilityState}} is "{{hidden}}" and s's state - is active, then run - the following substeps: - -
        -
      1. - For each audio-producing object in s's list of - audio-producing participants, run the following substeps: - -
          -
        1. - If audio-producing object is not currently playing, - or is not otherwise running, then terminate these substeps and - continue at the next available audio-producing - object. -
        2. -
        3. - Pause audio-producing object. -
        4. -
        5. - Add audio-producing object to media - session's resume list. -
        6. -
        -
      2. -
      3. - Set s's - state to interrupted. -
      4. -
      5. - Terminate these substeps and continue at the next available - media session. -
      6. -
      -
    4. - -
    5. - If {{visibilityState}} is "{{visible}}" and s's state - is interrupted, - then run the following substeps: - -
        -
      1. - Unpause each audio-producing object in - s's resume list. -
      2. -
      3. - Set s's resume list to an empty list. -
      4. -
      5. - Set s's state to active. -
      6. -
      7. - Terminate these substeps and continue at the next available - media session. -
      8. -
      -
    6. -
    -
  4. -
- -

Deactivating a media session

- -To deactivate a media session, run these steps: - -
    -
  1. - Indefinitely pause all of media session's - audio-producing participants. -
  2. -
  3. - Set media session's resume list to an empty list. -
  4. -
  5. - Set media session's audio-producing participants - to an empty list. -
  6. -
  7. - Run the media session deactivation algorithm for media - session. -
  8. -
- -The media session deactivation algorithm takes one argument, -media session, and consists of the following steps. - -
    -
  1. - If media session's state is - idle, then terminate these - steps. -
  2. -
  3. - If media session still has one or more audio-producing - participants, then terminate these steps. -
  4. -
  5. - Optionally, based on platform conventions, the user agent must release any - currently held platform media focus for media session. -
  6. -
  7. - Optionally, based on platform conventions, the user agent must remove any - previously established ongoing media interface in the underlying platform's - notifications area and any ongoing media interface in the underlying - platform's lock screen area for media session, if any. -
  8. -
  9. - Optionally, based on platform conventions, the user agent must prevent any - hardware and/or software media keys from controlling playback of - media session's audio-producing participants. - -

    - If the algorithm reaches this step then media session can not - have any remaining audio-producing participants. -

    -
  10. -
  11. - Set media session's state to - idle. - -

    - This implies that the next time the media session is - activated, that we will re-request media focus according to the - steps defined in that algorithm. -

    -
  12. -
-

The {{MediaMetadata}} interface

 
-[Constructor(MediaMetadataInit init)]
+[Constructor(optional MediaMetadataInit init)]
 interface MediaMetadata {
   readonly attribute DOMString title;
   readonly attribute DOMString artist;
@@ -1195,54 +308,11 @@ attribute must return the {{MediaMetadata}} objects's artwork images, as a FrozenArray of {{MediaImage}}s.
 The artwork attribute can be empty.
 
-When a user agent wants to display the {{MediaSession}}'s artwork as specified
-in it's metadata, it is recommended to run the following fetch
-steps:
-
-
    - -
  1. - If metadata's artwork is empty, then terminate these - steps. -
  2. -
  3. - If the platform supports displaying media artwork, select a prefered - artwork image - from metadata's artwork. -
  4. -
  5. - Fetch prefered artwork image's - {{MediaImage/src}}. - - Then, in parallel: - -
      -
    1. - Wait for the response. -
    2. -
    3. - If the response's internal response's - type is default, attempt to decode the - resource as image. -
    4. -
    5. - If the image format is supported, use the image as the artwork for - display. Otherwise the fetch steps fail and terminate. -
    6. -
    -
  6. -
- -If no artwork images are fetched in the fetch steps, the user agent may -have fallback behavior such as displaying an default image as artwork. -

The {{MediaImage}} interface

 
-[Constructor(MediaImageInit init)]
+[Constructor(optional MediaImageInit init)]
 interface MediaImage {
   readonly attribute USVString src;
   readonly attribute DOMString sizes;
@@ -1318,205 +388,114 @@ The type attribute must return the
 media type of the image. The purpose of this attribute is to allow a user agent
 to ignore images of media types it does not support.
 
-

Extensions to the -{{HTMLMediaElement}} interface

+

Processing model

-
-partial interface HTMLMediaElement {
-  attribute MediaSession? session;
-};
-
+As there is a {{Window}} object per browsing context, the top-level +browsing context and each nested browsing context will have an +associated {{MediaSession}} object. For each tab, the user agent MUST select the +{{MediaSession}} object of the top-level browsing context to represent +the tab. The selected {{MediaSession}} object is called tab-level active media session. -
-
- media . {{HTMLMediaElement/session}} [ = - session ] -
-
- Returns the current media session for the media element, if - any, or null otherwise. - - Can be set, to change the current media session. - - Throws an {{InvalidStateError}} exception if the media element's - {{networkState}} is {{NETWORK_LOADING}} or {{NETWORK_IDLE}}. -
-
- -The session attribute on a media element, on -getting, must return the element's current media session, if any, or null -otherwise. On setting, the user agent must run the following steps: - -
    -
  1. - If the media element's {{networkState}} is {{NETWORK_LOADING}} or - {{NETWORK_IDLE}}, throw an {{InvalidStateError}} exception and abort these - steps. -
  2. -
  3. - Set the media elements's current media session to the new - value. -
  4. -
- -

Activating a -media session from an {{HTMLMediaElement}} object

+

+ It is still an open question whether an {{MediaSession}} object is allowed to + become the tab-level active media session. See the issue on GitHub. +

- +When the user agent has multiple tabs, the user agent MUST select the most +meaningful audio-producing tab and present the tab-level active media +session to the platform, which MAY be displayed in the platform UI depending +on platform conventions. The most meaningful audio-producing tab is +the tab which is producing the most meaningful audio to the user. The user agent +SHOULD select the most meaningful audio-producing tab based on platform +conventions and the preferred user experience. The most meaningful +audio-producing tab can be null. -When the {{play()}} method on a media element is invoked from script – -or a media element is otherwise played from the web page (e.g. via its -{{controls}}) – and that media element's {{paused}} attribute is true -and its {{HTMLMediaElement/readyState}} attribute has the value -{{HAVE_FUTURE_DATA}} or {{HAVE_ENOUGH_DATA}} then the user agent must run the -following steps, passing in media element as media element: +Whenever the most meaningful audio-producing tab changes or setting metadata of the most meaningful +audio-producing tab, the user agent MUST run the update metadata +algorithm, the steps are as follows:
  1. - Let media session be the value of media element's - current media session. + If the most meaningful audio-producing tab is null, unset the media + metadata presented to the platform, and terminate these steps.
  2. - If media element is not currently in media session's - list of audio-producing participants, then append media - element to this list. + If the metadata for the + tab-level active media session of the most meaningful + audio-producing tab is null, unset the media metadata presented to the + platform, and terminate these steps.
  3. - Activate media session. + Update the media metadata presented to the platform to match the metadata for the + tab-level active media session of the most meaningful + audio-producing tab.
  4. - If activate failed, pause media element. + If the user agent wants to display artwork image, it is recommended + to run the fetch image algorithm.
  5. -
- -

Interrupting a -media session from an {{HTMLMediaElement}} object

- -When the user agent is to pause a media element for a given -media element it must run that media element's internal -pause steps. - - - -When the user agent is to unpause a media element for a given -media element it must invoke that media element's {{play()}} -method. - -

Deactivating a -media session from an {{HTMLMediaElement}} object

- -When a media element's playback has ended, the -user agent must release media element from its media session. - -Any time a media element's load -algorithm is run by the user agent, it must release media element from -its media session. - -When the user agent is to release media element from its media -session for a given media element it must run the following -steps: +The recommended fetch image algorithm is as follows:
    +
  1. - Let media session be the value of media element's - current media session. -
  2. -
  3. - If media element is not currently in media session's - list of audio-producing participants, then terminate these steps. + If there are other fetch image algorithm running, cancel existing + algorithm execution instances.
  4. - If media element is in media session's resume - list then remove it from this list. + If metadata's artwork of the tab-level active + media session of the most meaningful audio-producing tab is + empty, then terminate these steps.
  5. - Remove media element from media session's list of - audio-producing participants. + If the platform supports displaying media artwork, select a prefered + artwork image + from metadata's artwork of the tab-level active + media session of the most meaningful audio-producing tab.
  6. - Run the media session deactivation algorithm for media - session. -
  7. -
- -

Extensions to the -{{AudioContext}} interface

- -
-partial interface AudioContext {
-  attribute MediaSession? session;
-};
-
- -
-
- context . {{AudioContext/session}} [ = - session ] -
-
- Returns the current media session for the {{AudioContext}} object, if - any, or null otherwise. - - Can be set, to change the current media session. - - Throws an {{InvalidStateError}} exception if the {{AudioContext}} object's - {{state}} attribute is "{{running}}". -
-
+ Fetch the prefered artwork image's + {{MediaImage/src}}. -The session -attribute on an {{AudioContext}} object, on getting, must return the object's -current media session, if any, or null otherwise. On setting, the user -agent must run the following steps: + Then, in parallel: -
    -
  1. - If the {{AudioContext}} object's {{state}} attribute is "{{running}}", throw - an {{InvalidStateError}} exception and abort these steps. -
  2. -
  3. - Set the {{AudioContext}} object's current media session to the new - value. +
      +
    1. + Wait for the response. +
    2. +
    3. + If the response's internal response's + type is default, attempt to decode the + resource as image. +
    4. +
    5. + If the image format is supported, use the image as the artwork for + display in platform UI. Otherwise the fetch image algorithm fail + and terminate. +
    6. +
-

Interrupting a -media session from an {{AudioContext}} object

- -When the user agent is to suspend a web audio object for a given -{{AudioContext}} object it must invoke that {{AudioContext}} object's -{{suspend()}} method. - -When the user agent is to resume a web audio object for a given -{{AudioContext}} object it must invoke that {{AudioContext}} object's -{{resume()}} method. +If no artwork images are fetched in the fetch image algorithm, the user +agent MAY have fallback behavior such as displaying an default image as artwork.

Examples

This section is non-normative. -
- For music or podcasts, using a media session of kind - "content" can be appropriate. +
-    var audio = document.createElement("audio");
-    audio.src = "podcast.mp3";
-    audio.session = new MediaSession(); // "content" is the default kind
-    audio.play();
-  
- - If metadata is available, providing it will allow for a richer user interface: - -
-    audio.session.metadata = new MediaMetadata({
+    window.navigator.mediaSession.metadata = new MediaMetadata({
       title: "Episode Title",
       artist: "Podcast Host",
       album: "Podcast Title",
@@ -1530,7 +509,7 @@ When the user agent is to resume a web audio object for a given
   for different screens:
 
   
-    audio.session.metadata = new MediaMetadata({
+    window.navigator.mediaSession.metadata = new MediaMetadata({
       title: "Episode Title",
       artist: "Podcast Host",
       album: "Podcast Title",
@@ -1554,7 +533,7 @@ When the user agent is to resume a web audio object for a given
 
 
-
+
For playlists or chapters of an audio book, multiple media elements can share a single media session. @@ -1565,9 +544,6 @@ When the user agent is to resume a web audio object for a given var audio2 = document.createElement("audio"); audio2.src = "chapter2.mp3"; - var sharedSession = new MediaSession(); - audio1.session = audio2.session = sharedSession; - audio1.play(); audio1.addEventListener("ended", function() { audio2.play(); @@ -1579,7 +555,7 @@ When the user agent is to resume a web audio object for a given
     function updateMetadata(event) {
-      sharedSession.metadata = new MediaMetadata({
+      window.navigator.mediaSession.metadata = new MediaMetadata({
         title: event.target == audio1 ? "Chapter 1" : "Chapter 2",
         artist: "An Author",
         album: "A Book",
@@ -1592,21 +568,6 @@ When the user agent is to resume a web audio object for a given
   
-
- For games, using a media session of kind - "ambient" can be appropriate. Because {{AudioContext}} - objects are created in the "{{running}}" state, it's necessary to suspend - before setting the session. - -
-    var context = new AudioContext();
-    context.suspend().then(function() {
-      context.session = new MediaSession("ambient");
-      context.resume();
-    });
-  
-
-

Acknowledgments

The editor would like to thank Paul Adenot, Jake Archibald, Tab Atkins, Jonathan