Skip to content

Commit 9837d30

Browse files
Add "Audio/Video Updates in Chrome 73" article (google#7205)
* Add Audio/Video Updates in Chrome 73" article * Squoosh images * Address mlamouri's feedback
1 parent dad9c17 commit 9837d30

File tree

4 files changed

+271
-8
lines changed

4 files changed

+271
-8
lines changed

src/content/en/updates/2018/08/chrome-69-media-updates.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ project_path: /web/_project.yaml
22
book_path: /web/updates/_book.yaml
33
description: A round up of the audio/video updates in Chrome 69: AV1 and HDCP policy check.
44

5-
{# wf_updated_on: 2018-10-03 #}
5+
{# wf_updated_on: 2019-02-06 #}
66
{# wf_published_on: 2018-08-01 #}
77
{# wf_tags: news,chrome69,media,removals #}
88
{# wf_featured_image: /web/updates/images/generic/play-outline.png #}
@@ -152,7 +152,7 @@ to try out all versions of HDCP.
152152
.then(mediaKeys => {
153153

154154
// Get status for HDCP 2.2
155-
return mediaKeys.getStatusForPolicy({ minHdcpVersion: 'hdcp-2.2' })
155+
return mediaKeys.getStatusForPolicy({ minHdcpVersion: '2.2' })
156156
.then(status => {
157157
if (status !== 'usable')
158158
return Promise.reject(status);
@@ -167,12 +167,10 @@ to try out all versions of HDCP.
167167

168168
### Available for Origin Trials
169169

170-
To get feedback from web developers, the HDCP Policy Check API is available as
171-
an [Origin Trial] in Chrome 69 for Desktop (Chrome OS, Linux, Mac, and
172-
Windows). You will need to [request a token], so that the feature is
173-
automatically enabled for your origin for a limited period of time, without the
174-
need to enable the experimental "Web Platform Features" flag at
175-
`chrome://flags/#enable-experimental-web-platform-features`.
170+
To get feedback from web developers, we've previously added the HDCP Policy
171+
Check API feature in Chrome 69 for Desktop (Chrome OS, Linux, Mac, and Windows).
172+
173+
The trial has successfully ended in November 2018.
176174

177175
[Intent to Experiment](https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/ITzZ_yx4bF8) |
178176
[Chromestatus Tracker](https://www.chromestatus.com/feature/5652917147140096) |
Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
project_path: /web/_project.yaml
2+
book_path: /web/updates/_book.yaml
3+
description: A round up of the audio/video updates in Chrome 73: Hardware media keys support, HDCP policy check, Picture-in-Picture origin trials, and more.
4+
5+
{# wf_updated_on: 2019-02-06 #}
6+
{# wf_published_on: 2019-02-06 #}
7+
{# wf_tags: news,chrome73,media #}
8+
{# wf_featured_image: /web/updates/images/generic/play-outline.png #}
9+
{# wf_featured_snippet: A round up of the audio/video updates in Chrome 73: Hardware media keys support, HDCP policy check, Picture-in-Picture origin trials, and more. #}
10+
{# wf_blink_components: Blink>Media #}
11+
12+
# Audio/Video Updates in Chrome 73 {: .page-title }
13+
14+
{% include "web/_shared/contributors/beaufortfrancois.html" %}
15+
16+
In this article, I'll discuss Chrome 73 new media features which include:
17+
18+
- [Hardware media keys](#media-keys) are now supported to control media playback
19+
on desktop.
20+
- Web developers can [query whether a certain HDCP policy can be
21+
enforced](#hdcp).
22+
- [Auto Picture-in-Picture](#auto-pip) in desktop PWAs and [“Skip Ad” in
23+
Picture-in-Picture](#skipad) are coming to origin trials.
24+
- Desktop PWAs are granted [autoplay with sound](#autoplay-pwa).
25+
26+
## Hardware Media Keys support {: #media-keys}
27+
28+
Many keyboards nowadays have keys to control basic media playback functions such
29+
as play/pause, previous and next track. Headsets have them too. Until now,
30+
desktop users couldn’t use these media keys to control audio and video playback
31+
in Chrome. This changes today!
32+
33+
<figure>
34+
<img src="/web/updates/images/2019/02/media-keys.jpg"
35+
alt="Keyboard media keys">
36+
<figcaption>
37+
<b>Figure 1.</b>
38+
Keyboard media keys
39+
</figcaption>
40+
</figure>
41+
42+
If user presses the pause key, the active media element playing in Chrome will
43+
be paused and receive a "paused" media event. If the play key is pressed, the
44+
previously paused media element will be resumed and receive a "play" media
45+
event. It works whether Chrome is in foreground or background.
46+
47+
In Chrome OS, Android apps using [audio focus] will now tell Chrome to pause and
48+
resume audio to create a seamless media experience between websites on Chrome,
49+
Chrome Apps and Android Apps. This is currently supported only on Chrome OS
50+
device running Android P.
51+
52+
In short, it’s a good practice to always listen to these media events and act
53+
accordingly.
54+
55+
video.addEventListener('pause', function() {
56+
// Video is now paused.
57+
// TODO: Let's update UI accordingly.
58+
});
59+
60+
video.addEventListener('play', function() {
61+
// Video is now playing.
62+
// TODO: Let's update UI accordingly.
63+
});
64+
65+
But wait, there’s more! With the [Media Session API] now available on desktop
66+
(it was supported on mobile only before), web developers can handle media
67+
related events such as track changing that are triggered by media keys. The
68+
events `previoustrack`, `nexttrack`, `seekbackward`, and `seekforward` are
69+
currently supported.
70+
71+
navigator.mediaSession.setActionHandler('previoustrack', function() {
72+
// User hit "Previous Track" key.
73+
});
74+
75+
navigator.mediaSession.setActionHandler('nexttrack', function() {
76+
// User hit "Next Track" key.
77+
});
78+
79+
navigator.mediaSession.setActionHandler('seekbackward', function() {
80+
// User hit "Seek Backward" key.
81+
});
82+
83+
navigator.mediaSession.setActionHandler('seekforward', function() {
84+
// User hit "Seek Forward" key.
85+
});
86+
87+
Play and pause keys are handled automatically by Chrome. However if the default
88+
behavior doesn't work out for you, you can still set some action handlers for
89+
"play" and "pause" to prevent this.
90+
91+
navigator.mediaSession.setActionHandler('play', function() {
92+
// User hit "Play" key.
93+
});
94+
95+
navigator.mediaSession.setActionHandler('pause', function() {
96+
// User hit "Pause" key.
97+
});
98+
99+
Hardware Media Keys support is available on Chrome OS, macOS, and Windows. Linux
100+
will come later.
101+
102+
Note: Setting some media session metadata such as the title, artist, album name,
103+
and artwork with the Media Session API is available but not hooked up to desktop
104+
notifications yet. It will come in supported platforms later.
105+
106+
Check out our existing [developer documentation] and try out the [official Media
107+
Session samples].
108+
109+
[Chromestatus Tracker](https://www.chromestatus.com/feature/5639924124483584) &#124;
110+
[Chromium Bug](hhttps://bugs.chromium.org/p/chromium/issues/detail?id=497735)
111+
112+
## Encrypted Media: HDCP Policy Check {: #hdcp }
113+
114+
Thanks to the [HDCP Policy Check API], web developers can now query whether a
115+
specific policy, e.g. [HDCP] requirement, can be enforced **before** requesting
116+
Widevine licenses, and loading media.
117+
118+
const status = await video.mediaKeys.getStatusForPolicy({ minHdcpVersion: '2.2' });
119+
120+
if (status == 'usable')
121+
console.log('HDCP 2.2 can be enforced.');
122+
123+
The API is available on all platforms. However, the actual policy checks might
124+
not be available on certain platforms. For example, HDCP policy check promise
125+
will reject with `NotSupportedError` on Android and Android WebView.
126+
127+
Check out our [previous developer documentation] and give a try to the [official
128+
sample] to see all HDCP versions that are supported.
129+
130+
[Intent to Ship](https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/w0jNaAhyTV0/3oDkR_ASAQAJ) &#124;
131+
[Chromestatus Tracker](https://www.chromestatus.com/feature/5652917147140096) &#124;
132+
[Chromium Bug](https://bugs.chromium.org/p/chromium/issues/detail?id=709348)
133+
134+
## Origin Trial for Auto Picture-in-Picture for installed PWAs {: #auto-pip }
135+
136+
Some pages may want to automatically enter and leave [Picture-in-Picture] for a
137+
video element; for example, video conferencing web apps would benefit from some
138+
automatic Picture-in-Picture behavior when user switches back and forth between
139+
the web app and other applications or tabs. This is sadly not possible with the
140+
[user gesture requirement]. So here comes Auto Picture-in-Picture!
141+
142+
<video autoplay loop muted playsinline src="https://storage.googleapis.com/webfundamentals-assets/videos/pwa-auto-pip.mp4"></video>
143+
144+
To support these tab and app switching, a new `autopictureinpicture` attribute
145+
is added to the `<video>` element.
146+
147+
<video autopictureinpicture></video>
148+
149+
Here’s roughly how it works:
150+
151+
- When document becomes hidden, the video element whose `autopictureinpicture`
152+
attribute was set most recently automatically enters Picture-in-Picture, if
153+
allowed.
154+
- When document becomes visible, the video element in Picture-in-Picture
155+
automatically leaves it.
156+
157+
And that’s it! Note that the Auto Picture-in-Picture feature applies only to
158+
[Progressive Web Apps] (PWAs) that users have installed on [desktop].
159+
160+
Check out the [spec] for more details and try out using the [official PWA
161+
sample].
162+
163+
Dogfood: To get feedback from web developers, the Auto Picture-in-Picture
164+
feature is available as an [Origin Trial] in Chrome 73 for desktop (Chrome OS,
165+
Linux, Mac, and Windows). You will need to [request a token], so that the
166+
feature is automatically enabled for your origin for a limited period of time.
167+
This will eliminate the need to enable the "Web Platform Features" flag.
168+
169+
[Intent to Experiment](https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/eFZ3h_A3VTY) &#124;
170+
[Chromestatus Tracker](https://www.chromestatus.com/feature/5317876315586560) &#124;
171+
[Chromium Bug](https://bugs.chromium.org/p/chromium/issues/detail?id=917303)
172+
173+
## Origin Trial for Skip Ad in Picture-in-Picture window {: #skipad }
174+
175+
The video advertisement model usually consists of pre-roll ads. Content
176+
providers often provide the ability to skip the ad after a few seconds. Sadly,
177+
as the Picture-in-Picture window is not interactive, users watching a video in
178+
Picture-in-Picture can’t do this today.
179+
180+
With the [Media Session API] now available on desktop (it was supported on
181+
mobile only before), a new `skipad` media session action may be used to offer this
182+
option in [Picture-in-Picture].
183+
184+
<figure>
185+
<img src="/web/updates/images/2019/02/skip-ad.png"
186+
alt="Skip Ad button in Picture-in-Picture window">
187+
<figcaption>
188+
<b>Figure 2.</b>
189+
"Skip Ad" button in Picture-in-Picture window
190+
</figcaption>
191+
</figure>
192+
193+
To provide this feature pass a function with `skipad` when calling
194+
`setActionHandler()`. To hide it pass `null`. As you can read below, it is
195+
pretty straightforward.
196+
197+
try {
198+
navigator.mediaSession.setActionHandler('skipad', null);
199+
showSkipAdButton();
200+
} catch(error) {
201+
// The "Skip Ad" media session action is not supported.
202+
}
203+
204+
function showSkipAdButton() {
205+
// The Picture-in-Picture window will show a "Skip Ad" button.
206+
navigator.mediaSession.setActionHandler('skipad', onSkipAdButtonClick);
207+
}
208+
209+
function onSkipAdButtonClick() {
210+
// User clicked "Skip Ad" button, let's hide it now.
211+
navigator.mediaSession.setActionHandler('skipad', null);
212+
213+
// TODO: Stop ad and play video.
214+
}
215+
216+
Note: Media session action handlers will persist. I’d suggest always reseting
217+
them when media playback starts and ends to avoid showing an unexpected "Skip
218+
Ad" button.
219+
220+
Try out the [official "Skip Ad" sample] and [let us know] how this feature can
221+
be improved.
222+
223+
Dogfood: To get feedback from web developers, the Skip Ad in Picture-in-Picture
224+
window feature is available as an [Origin Trial] in Chrome 73 for desktop
225+
(Chrome OS, Linux, Mac, and Windows). You will need to [request a token], so
226+
that the feature is automatically enabled for your origin for a limited period
227+
of time. This will eliminate the need to enable the "Web Platform Features"
228+
flag.
229+
230+
[Intent to Experiment](https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/l6sW0G4jzhE) &#124;
231+
[Chromestatus Tracker](https://www.chromestatus.com/feature/4749278882824192) &#124;
232+
[Chromium Bug](https://bugs.chromium.org/p/chromium/issues/detail?id=910436)
233+
234+
## Autoplay granted for Desktop PWAs {: #autoplay-pwa }
235+
236+
Now that [Progressive Web Apps] (PWAs) are available on all desktop platforms,
237+
we are extending the rule that we had on mobile to desktop: [autoplay] with
238+
sound is now allowed for installed PWAs. Note that it only applies to pages in
239+
the [scope] of the web app manifest.
240+
241+
[Chromium Bug](https://bugs.chromium.org/p/chromium/issues/detail?id=794874)
242+
243+
{% include "web/_shared/rss-widget-updates.html" %}
244+
245+
[audio focus]: https://developer.android.com/guide/topics/media-apps/audio-focus
246+
[Media Session API]: /web/updates/2017/02/media-session
247+
[developer documentation]: /web/updates/2017/02/media-session
248+
[official Media Session samples]: https://googlechrome.github.io/samples/media-session/
249+
[HDCP Policy Check API]: https://wicg.github.io/hdcp-detection/
250+
[HDCP]: https://en.wikipedia.org/wiki/High-bandwidth_Digital_Content_Protection
251+
[previous developer documentation]: /web/updates/2018/08/chrome-69-media-updates#hdcp
252+
[official sample]: https://googlechrome.github.io/samples/hdcp-detection/
253+
[Picture-in-Picture]: /web/updates/2018/10/watch-video-using-picture-in-picture
254+
[user gesture requirement]: /web/updates/2018/10/watch-video-using-picture-in-picture#enter_picture-in-picture_enter-pip
255+
[Progressive Web Apps]: /web/progressive-web-apps/
256+
[desktop]: /web/progressive-web-apps/desktop
257+
[spec]: https://wicg.github.io/picture-in-picture/#auto-pip
258+
[official PWA sample]: https://googlechrome.github.io/samples/auto-picture-in-picture/index.html
259+
[Origin Trial]: https://github.com/GoogleChrome/OriginTrials/blob/gh-pages/developer-guide.md
260+
[request a token]: https://developers.chrome.com/origintrials
261+
[official "Skip Ad" sample]: https://googlechrome.github.io/samples/picture-in-picture/skip-ad.html
262+
[let us know]: https://github.com/WICG/picture-in-picture/issues
263+
[autoplay]: /web/updates/2017/09/autoplay-policy-changes
264+
[scope]: /web/fundamentals/web-app-manifest/#scope
265+
Loading
Loading

0 commit comments

Comments
 (0)