From fed64cf077e35fd3ae8afbba6a0c9ef0411f7238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20J=C3=A4genstedt?= Date: Mon, 11 Apr 2016 14:20:43 +0200 Subject: [PATCH 1/2] Reintroduce MediaMetadata artwork (a URL) This spec text is mostly written by @richtr, reverted back from commit 551bf6525dac88aa349e4305a23dca29777adc49. Fixes https://github.com/whatwg/mediasession/issues/58 --- mediasession.bs | 72 ++++++++++++++++++++-- mediasession.html | 150 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 174 insertions(+), 48 deletions(-) diff --git a/mediasession.bs b/mediasession.bs index 1c8b447..e10c185 100644 --- a/mediasession.bs +++ b/mediasession.bs @@ -1123,12 +1123,14 @@ interface MediaMetadata { readonly attribute DOMString title; readonly attribute DOMString artist; readonly attribute DOMString album; + readonly attribute USVString artwork; }; dictionary MediaMetadataInit { DOMString title = ""; DOMString artist = ""; DOMString album = ""; + USVString artwork; }; @@ -1141,16 +1143,76 @@ constructor, when invoked, must run the following steps: Let metadata be a new {{MediaMetadata}} object.
  • - Set metadata's {{MediaMetadata/title}}, {{MediaMetadata/artist}}, - and {{MediaMetadata/album}} attributes to the values of init's - {{MediaMetadataInit/title}}, {{MediaMetadataInit/artist}}, and - {{MediaMetadataInit/album}} members, respectively. + Set metadata's {{MediaMetadata/title}} to init's + title. +
  • +
  • + Set metadata's {{MediaMetadata/artist}} to init's + artist. +
  • +
  • + Set metadata's {{MediaMetadata/album}} to init's + album. +
  • +
  • + Let baseURL be the API base URL specified by the entry + settings object. +
  • +
  • + If init's artwork is present, + parse it using baseURL, and if that does + not return failure, set metadata's artwork URL to the + return value. (Otherwise artwork URL is not set.)
  • Return metadata.
  • +The fetch steps for a given {{MediaMetadata}} object +metadata are: + +
      + +
    1. + If metadata's artwork URL is empty, then terminate these + steps. +
    2. +
    3. + If the platform supports displaying media artwork, let request be + a new request whose method is "GET", + url is metadata's artwork URL, context is + "image", context frame type is + "none", origin is the current entry + settings object's origin, + force Origin header flag is set, and referrer is no + referrer. Otherwise, if the platform does not support displaying media + artwork, terminate these steps. +
    4. +
    5. + Fetch request. + + 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, set metadata's artwork + resource to the decoded resource. (Otherwise metadata has + no artwork resource.) +
      6. +
      +
    6. +
    +

    Extensions to the {{HTMLMediaElement}} interface

    @@ -1353,6 +1415,7 @@ When the user agent is to resume a web audio object for a given title: "Episode Title", artist: "Podcast Host", album: "Podcast Title", + artwork: "podcast.jpg", }); @@ -1385,6 +1448,7 @@ When the user agent is to resume a web audio object for a given title: event.target == audio1 ? "Chapter 1" : "Chapter 2", artist: "An Author", album: "A Book", + artwork: "cover.jpg", }); } diff --git a/mediasession.html b/mediasession.html index 1503cfe..b416591 100644 --- a/mediasession.html +++ b/mediasession.html @@ -2,6 +2,7 @@ + Media Session Standard @@ -72,8 +73,10 @@

    -

    Media Session

    -

    Living Standard — Last Updated

    +
    +

    Media Session

    +

    Living Standard — Last Updated

    +
    Participate: @@ -94,7 +97,6 @@