diff --git a/index.bs b/index.bs index 0aa28bc..26c4218 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 = []; }; @@ -1128,7 +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, which is a sequence of type {{MediaTranscripts}}.

@@ -1143,6 +1150,7 @@ dictionary MediaMetadataInit { is 0.

  • Its chapter information length is 0.
  • +
  • Its transcripts length is 0.
  • @@ -1177,13 +1185,23 @@ dictionary MediaMetadataInit {

  • For each entry in init's {{MediaMetadataInit/chapterInfo}}, [=create a ChapterInformation=] from - entry and append it to - chapters. + entry and append it to chapters.
  • 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. +
  • +
  • + 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 [=creating a frozen array=] from transcripts.
  • Return metadata. @@ -1319,10 +1337,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 +1519,153 @@ 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 are used by user agents to provide transcription for the + media content. +

      + +

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

      + +

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

      + +

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

      +
        +
      1. + Let transcripts be a [=new=] {{MediaTranscripts}} object. +
      2. +
      3. + If init's {{MediaTranscriptsInit/language}} is not a valid + [[BCP47]] language tag defined in [[LANG-SUBTAG-REGISTRY]], throw a + TypeError and abort these steps. +
      4. +
      5. + Set transcripts's {{MediaTranscripts/language}} to + init's {{MediaTranscriptsInit/language}}. +
      6. +
      7. + Set transcripts's {{MediaTranscripts/transcripts}} to + the result of [=creating a frozen array=] from init's + {{MediaTranscriptsInit/transcripts}}. +
      8. +
      9. + Return transcripts. +
      10. +
      + +

      + 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}} dictionary

      + +
      +enum MediaTranscriptType {
      +  "subtitles",
      +  "captions",
      +  "descriptions",
      +  "metadata",
      +};
      +
      +dictionary MediaTranscript {
      +  MediaTranscriptType type = "subtitles";
      +  DOMString speaker = "";
      +  double startTime = 0;
      +  double endTime = 0;
      +  DOMString text = "";
      +};
      +
      + +

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

      + +

      +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: +

      + + +

      + 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 startTime + dictionary member is used to specify the start time of the transcript + in seconds. It should be zero or positive. +

      + +

      + The endTime + dictionary member is used to specify the end time of the transcript in + seconds. It should be larger than {{MediaTranscript/startTime}}. +

      + +

      + The text dictionary member + is used to specify the content of the transcript. It is a {{DOMString}}. +

      +

      The {{MediaPositionState}} dictionary

      @@ -1617,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"} + ]} ] });