From ac4010ffd8833fa5189dd39cc1c8adbbb8e53b83 Mon Sep 17 00:00:00 2001 From: Yiren Wang Date: Wed, 25 Mar 2026 14:52:27 -0700 Subject: [PATCH 1/2] Add MediaTranscripts to MediaMetadata (#370) --- index.bs | 279 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 277 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index 0aa28bc..97b5e6a 100644 --- a/index.bs +++ b/index.bs @@ -1090,6 +1090,7 @@ interface MediaMetadata { attribute DOMString album; attribute FrozenArray<object> artwork; [SameObject] readonly attribute FrozenArray<ChapterInformation> chapterInfo; + [SameObject] readonly attribute FrozenArray<MediaTranscripts> transcripts; }; dictionary MediaMetadataInit { @@ -1098,6 +1099,7 @@ dictionary MediaMetadataInit { DOMString album = ""; sequence<MediaImage> artwork = []; sequence<ChapterInformationInit> chapterInfo = []; + sequence<MediaTranscriptsInit> transcripts = []; }; @@ -1131,6 +1133,11 @@ dictionary MediaMetadataInit { chapter information.

+

+ A {{MediaMetadata}} has an associated list of + transcripts. +

+

A {{MediaMetadata}} is said to be an empty metadata if it is equal to `null` or all the following conditions are true: @@ -1143,6 +1150,7 @@ dictionary MediaMetadataInit { is 0.

  • Its chapter information length is 0.
  • +
  • Its transcripts length is 0.
  • @@ -1185,6 +1193,19 @@ dictionary MediaMetadataInit { to the result of [=Create a frozen array|creating a frozen array=] from chapters. +

  • + Let transcripts be an empty list of type {{MediaTranscripts}}. +
  • +
  • + For each entry in init's + {{MediaMetadataInit/transcripts}}, [=create a MediaTranscripts=] from + entry and append it to transcripts. +
  • +
  • + Set metadata's transcripts + to the result of [=Create a frozen array|creating a frozen array=] from + transcripts. +
  • Return metadata.
  • @@ -1319,10 +1340,29 @@ user agent MUST run the following steps: +

    + The chapterInfo attribute reflects + the {{MediaMetadata}}'s chapter information. + On getting, it MUST return the {{MediaMetadata}}'s + chapter information. On setting, it MUST set the + {{MediaMetadata}}'s chapter information to the given + value. +

    + +

    + The transcripts attribute reflects + the {{MediaMetadata}}'s transcripts. On getting, + it MUST return the {{MediaMetadata}}'s transcripts. + On setting, it MUST set the {{MediaMetadata}}'s + transcripts to the given value. +

    +

    When {{MediaMetadata}}'s title, artist, album or artwork images are modified, the user agent MUST run the + for=MediaMetadata>artist, album, + artwork images, + chapter information or + transcripts are modified, the user agent MUST run the following steps:

      @@ -1482,6 +1522,241 @@ used to specify the {{MediaImage}} object's MIME type. It is a hint as to 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. +

      The {{MediaTranscripts}} interface

      + +
      +[Exposed=Window]
      +interface MediaTranscripts {
      +  readonly attribute DOMString language;
      +  [SameObject] readonly attribute FrozenArray<MediaTranscript> transcripts;
      +};
      +
      +dictionary MediaTranscriptsInit {
      +  DOMString language = "en-US";
      +  sequence<MediaTranscript> transcripts = [];
      +};
      +
      + +

      + A {{MediaTranscripts}} object is a representation of transcripts for a + language, which can be used by user agents to provide transcription for the + media content. +

      + +

      + A {{MediaTranscripts}} has an associated + language which is DOMString of a BCP 47 + language tag. +

      + +

      + A {{MediaTranscripts}} has an associated list of + transcripts for the language. +

      + +

      + To create a {{MediaTranscripts}} with init, run the + following steps: +

      +
        +
      1. + Let transcripts be a new {{MediaTranscripts}} object. +
      2. +
      3. + If init's {{MediaTranscripts/language}} is not a valid BCP 47 + language tag, throw a TypeError and abort these steps. +
      4. +
      5. + Set transcripts's {{MediaTranscripts/language}} to + init's {{MediaTranscripts/language}}. +
      6. +
      7. + Let transcriptList be an empty list of type {{MediaTranscript}}. +
      8. +
      9. + For each entry in init's + {{MediaTranscriptsInit/transcripts}}, [=create a MediaTranscript=] from + entry and append it to transcriptList. +
      10. +
      11. + Set transcripts's transcripts to + the result of [=Create a frozen array|creating a frozen array=] from + transcriptList. +
      12. +
      13. + Return transcripts. +
      14. +
      + +

      + The language attribute reflects + the {{MediaTranscripts}}'s language. On getting, + it MUST return the {{MediaTranscripts}}'s + language. +

      + +

      + The transcripts attribute + reflects the {{MediaTranscripts}}'s transcripts. + On getting, it MUST return the {{MediaTranscripts}}'s + transcripts. +

      + +

      The {{MediaTranscript}} interface

      + +
      +enum MediaTranscriptType {
      +    "subtitles",
      +    "captions",
      +    "descriptions",
      +    "metadata",
      +};
      +
      +[Exposed=Window]
      +interface MediaTranscript {
      +    readonly attribute MediaTranscriptType type;
      +    readonly attribute DOMString speaker;
      +    readonly attribute double startTime;
      +    readonly attribute double endTime;
      +    readonly attribute DOMString text;
      +};
      +
      +dictionary MediaTranscriptInit {
      +  MediaTranscriptType type = "subtitles";
      +  DOMString speaker = "";
      +  double startTime = 0;
      +  double endTime = 0;
      +  DOMString text = "";
      +};
      +
      + +

      + A {{MediaTranscript}} object is a representation of a single piece of + transcript information. +

      + +

      + A {{MediaTranscript}} has an associated type + which is an enum of {{MediaTranscriptType}} to indicate the purpose of the + transcript. {{MediaTranscriptType}} can have one of the following values: +

      + + +

      + A {{MediaTranscript}} has an associated + speaker which is a DOMString of the name or + character identifier for the speaker. +

      + +

      + A {{MediaTranscript}} has an associated + startTime which is double. +

      + +

      + A {{MediaTranscript}} has an associated + endTime which is double. +

      + +

      + A {{MediaTranscript}} has an associated text + which is a DOMString of content for the transcript. +

      + +

      + To create a {{MediaTranscript}} with init, run the + following steps: +

      +
        +
      1. + Let transcript be a new {{MediaTranscript}} object. +
      2. +
      3. + Set transcript's {{MediaTranscript/type}} to init's + {{MediaTranscript/type}}. +
      4. +
      5. + Set transcript's {{MediaTranscript/speaker}} to init's + {{MediaTranscript/speaker}}. +
      6. +
      7. + If init's {{MediaTranscript/startTime}} is negative, throw a + TypeError and abort these steps. +
      8. +
      9. + Set transcript's {{MediaTranscript/startTime}} to + init's {{MediaTranscript/startTime}}. +
      10. +
      11. + If init's {{MediaTranscript/endTime}} is negative or smaller than + init's {{MediaTranscript/startTime}}, throw a + TypeError and abort these steps. +
      12. +
      13. + Set transcript's {{MediaTranscript/endTime}} to init's + {{MediaTranscript/endTime}}. +
      14. +
      15. + Set transcript's {{MediaTranscript/text}} to init's + {{MediaTranscript/text}}. +
      16. +
      17. + Return transcript. +
      18. +
      + +

      + The type attribute reflects + the {{MediaTranscript}}'s type. On getting, + it MUST return the {{MediaTranscript}}'s type. +

      + +

      + The speaker attribute reflects + the {{MediaTranscript}}'s speaker. On getting, + it MUST return the {{MediaTranscript}}'s speaker. +

      + +

      + The startTime attribute reflects + the {{MediaTranscript}}'s startTime in seconds. + On getting, it MUST return the {{MediaTranscript}}'s + startTime. +

      + +

      + The endTime attribute reflects + the {{MediaTranscript}}'s endTime in seconds. + On getting, it MUST return the {{MediaTranscript}}'s + endTime. +

      + +

      + The text attribute reflects + the {{MediaTranscript}}'s text. On getting, + it MUST return the {{MediaTranscript}}'s text. +

      +

      The {{MediaPositionState}} dictionary

      From f72e2e97276bbbe185249ab4a0fba2fb36d5c75d Mon Sep 17 00:00:00 2001 From: Yiren Wang Date: Wed, 1 Apr 2026 17:32:51 -0700 Subject: [PATCH 2/2] Update MediaTranscript to be a dictionary --- index.bs | 194 ++++++++++++++++--------------------------------------- 1 file changed, 57 insertions(+), 137 deletions(-) diff --git a/index.bs b/index.bs index 97b5e6a..26c4218 100644 --- a/index.bs +++ b/index.bs @@ -1130,12 +1130,12 @@ dictionary MediaMetadataInit {

      A {{MediaMetadata}} has an associated list of - chapter information. + chapter information, which is a sequence of type {{ChapterInformation}}.

      A {{MediaMetadata}} has an associated list of - transcripts. + transcripts, which is a sequence of type {{MediaTranscripts}}.

      @@ -1185,13 +1185,11 @@ dictionary MediaMetadataInit {

    1. For each entry in init's {{MediaMetadataInit/chapterInfo}}, [=create a ChapterInformation=] from - entry and append it to - chapters. + entry and append it to chapters.
    2. Set metadata's chapter information - to the result of [=Create a frozen array|creating a frozen array=] from - chapters. + to the result of [=creating a frozen array=] from chapters.
    3. Let transcripts be an empty list of type {{MediaTranscripts}}. @@ -1203,8 +1201,7 @@ dictionary MediaMetadataInit {
    4. Set metadata's transcripts - to the result of [=Create a frozen array|creating a frozen array=] from - transcripts. + to the result of [=creating a frozen array=] from transcripts.
    5. Return metadata. @@ -1343,8 +1340,8 @@ user agent MUST run the following steps:

      The chapterInfo attribute reflects the {{MediaMetadata}}'s chapter information. - On getting, it MUST return the {{MediaMetadata}}'s - chapter information. On setting, it MUST set the + On getting, it must return the {{MediaMetadata}}'s + chapter information. On setting, it must set the {{MediaMetadata}}'s chapter information to the given value.

      @@ -1352,8 +1349,8 @@ user agent MUST run the following steps:

      The transcripts attribute reflects the {{MediaMetadata}}'s transcripts. On getting, - it MUST return the {{MediaMetadata}}'s transcripts. - On setting, it MUST set the {{MediaMetadata}}'s + it must return the {{MediaMetadata}}'s transcripts. + On setting, it must set the {{MediaMetadata}}'s transcripts to the given value.

      @@ -1362,7 +1359,7 @@ user agent MUST run the following steps: for=MediaMetadata>artist, album, artwork images, chapter information or - transcripts are modified, the user agent MUST run the + transcripts are modified, the user agent must run the following steps:

        @@ -1539,14 +1536,14 @@ dictionary MediaTranscriptsInit {

        A {{MediaTranscripts}} object is a representation of transcripts for a - language, which can be used by user agents to provide transcription for the + language, which are used by user agents to provide transcription for the media content.

        A {{MediaTranscripts}} has an associated - language which is DOMString of a BCP 47 - language tag. + language which is {{DOMString}} of a + [[BCP47]] language tag.

        @@ -1555,33 +1552,26 @@ dictionary MediaTranscriptsInit {

        - To create a {{MediaTranscripts}} with init, run the - following steps: + To create a {{MediaTranscripts}} given a {{MediaTranscriptsInit}} + init, run the following steps:

        1. - Let transcripts be a new {{MediaTranscripts}} object. + Let transcripts be a [=new=] {{MediaTranscripts}} object.
        2. - If init's {{MediaTranscripts/language}} is not a valid BCP 47 - language tag, throw a TypeError and abort these steps. + If init's {{MediaTranscriptsInit/language}} is not a valid + [[BCP47]] language tag defined in [[LANG-SUBTAG-REGISTRY]], throw a + TypeError and abort these steps.
        3. Set transcripts's {{MediaTranscripts/language}} to - init's {{MediaTranscripts/language}}. -
        4. -
        5. - Let transcriptList be an empty list of type {{MediaTranscript}}. -
        6. -
        7. - For each entry in init's - {{MediaTranscriptsInit/transcripts}}, [=create a MediaTranscript=] from - entry and append it to transcriptList. + init's {{MediaTranscriptsInit/language}}.
        8. - Set transcripts's transcripts to - the result of [=Create a frozen array|creating a frozen array=] from - transcriptList. + Set transcripts's {{MediaTranscripts/transcripts}} to + the result of [=creating a frozen array=] from init's + {{MediaTranscriptsInit/transcripts}}.
        9. Return transcripts. @@ -1591,37 +1581,28 @@ dictionary MediaTranscriptsInit {

          The language attribute reflects the {{MediaTranscripts}}'s language. On getting, - it MUST return the {{MediaTranscripts}}'s + it must return the {{MediaTranscripts}}'s language.

          The transcripts attribute reflects the {{MediaTranscripts}}'s transcripts. - On getting, it MUST return the {{MediaTranscripts}}'s + On getting, it must return the {{MediaTranscripts}}'s transcripts.

          -

          The {{MediaTranscript}} interface

          +

          The {{MediaTranscript}} dictionary

           enum MediaTranscriptType {
          -    "subtitles",
          -    "captions",
          -    "descriptions",
          -    "metadata",
          +  "subtitles",
          +  "captions",
          +  "descriptions",
          +  "metadata",
           };
           
          -[Exposed=Window]
          -interface MediaTranscript {
          -    readonly attribute MediaTranscriptType type;
          -    readonly attribute DOMString speaker;
          -    readonly attribute double startTime;
          -    readonly attribute double endTime;
          -    readonly attribute DOMString text;
          -};
          -
          -dictionary MediaTranscriptInit {
          +dictionary MediaTranscript {
             MediaTranscriptType type = "subtitles";
             DOMString speaker = "";
             double startTime = 0;
          @@ -1631,14 +1612,14 @@ dictionary MediaTranscriptInit {
           

          - A {{MediaTranscript}} object is a representation of a single piece of + The {{MediaTranscript}} dictionary is a representation of a single piece of transcript information.

          - A {{MediaTranscript}} has an associated type - which is an enum of {{MediaTranscriptType}} to indicate the purpose of the - transcript. {{MediaTranscriptType}} can have one of the following values: +The type dictionary member +is used to specify the purpose of the transcript. It is an enum of +{{MediaTranscriptType}} which has one of the following values:

          • @@ -1663,98 +1644,26 @@ dictionary MediaTranscriptInit {

          - A {{MediaTranscript}} has an associated - speaker which is a DOMString of the name or - character identifier for the speaker. -

          - -

          - A {{MediaTranscript}} has an associated - startTime which is double. -

          - -

          - A {{MediaTranscript}} has an associated - endTime which is double. -

          - -

          - A {{MediaTranscript}} has an associated text - which is a DOMString of content for the transcript. -

          - -

          - To create a {{MediaTranscript}} with init, run the - following steps: -

          -
            -
          1. - Let transcript be a new {{MediaTranscript}} object. -
          2. -
          3. - Set transcript's {{MediaTranscript/type}} to init's - {{MediaTranscript/type}}. -
          4. -
          5. - Set transcript's {{MediaTranscript/speaker}} to init's - {{MediaTranscript/speaker}}. -
          6. -
          7. - If init's {{MediaTranscript/startTime}} is negative, throw a - TypeError and abort these steps. -
          8. -
          9. - Set transcript's {{MediaTranscript/startTime}} to - init's {{MediaTranscript/startTime}}. -
          10. -
          11. - If init's {{MediaTranscript/endTime}} is negative or smaller than - init's {{MediaTranscript/startTime}}, throw a - TypeError and abort these steps. -
          12. -
          13. - Set transcript's {{MediaTranscript/endTime}} to init's - {{MediaTranscript/endTime}}. -
          14. -
          15. - Set transcript's {{MediaTranscript/text}} to init's - {{MediaTranscript/text}}. -
          16. -
          17. - Return transcript. -
          18. -
          - -

          - The type attribute reflects - the {{MediaTranscript}}'s type. On getting, - it MUST return the {{MediaTranscript}}'s type. + The speaker + dictionary member is used to specify the speaker of the transcript. + It is a {{DOMString}} of the name or character identifier of the speaker.

          - The speaker attribute reflects - the {{MediaTranscript}}'s speaker. On getting, - it MUST return the {{MediaTranscript}}'s speaker. + The startTime + dictionary member is used to specify the start time of the transcript + in seconds. It should be zero or positive.

          - The startTime attribute reflects - the {{MediaTranscript}}'s startTime in seconds. - On getting, it MUST return the {{MediaTranscript}}'s - startTime. + The endTime + dictionary member is used to specify the end time of the transcript in + seconds. It should be larger than {{MediaTranscript/startTime}}.

          - The endTime attribute reflects - the {{MediaTranscript}}'s endTime in seconds. - On getting, it MUST return the {{MediaTranscript}}'s - endTime. -

          - -

          - The text attribute reflects - the {{MediaTranscript}}'s text. On getting, - it MUST return the {{MediaTranscript}}'s text. + The text dictionary member + is used to specify the content of the transcript. It is a {{DOMString}}.

          The {{MediaPositionState}} @@ -1892,6 +1801,17 @@ media session. chapterInfo: [ {title: "Chapter 1", startTime: 0, artwork: [{src: "chapter1.jpg"}]}, {title: "Chapter 2", startTime: 120, artwork: [{src: "chapter2.jpg"}]} + ], + transcripts: [ + {language: "en-US", transcripts: [ + {type: "subtitles", speaker: "Podcast Host", startTime: 0, + endTime: 1, text: "Subtitles 1"}, + {type: "subtitles", speaker: "Podcast Guest", startTime: 1, + endTime: 2, text: "Subtitles 2"} + ]}, + {language: "en-GB", transcripts: [ + {type: "captions", startTime: 0, text: "Captions 1"} + ]} ] });