From 220356567656026d9392a98bffd0ad852899da88 Mon Sep 17 00:00:00 2001
From: Becca Hughes
+ A user agent MAY display the current playback position and duration + of a media session in the platform UI depending on platform conventions. The + position state is the combination of the following: +
+ The position state is represented by a {{MediaPositionState}} which MUST + always be stored with the last position updated time. This is the + time the position state was last updated. +
+ ++ The RECOMMENDED way to determine the position state is to monitor the + media elements whose node document's browsing context is the + browsing context. +
+ ++ The current playback position in seconds is computed in the following + way: +
+ The setPositionState() method, when + invoked MUST perform the following steps: + +
@@ -1016,6 +1105,34 @@ 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 {{MediaPositionState}} dictionary
+ ++ +dictionary MediaPositionState { + required unrestricted double duration; + double playbackRate = 0.0; + double position = 0.0; +}; ++ +The {{MediaPositionState}} dictionary is a representation of the current playback +position associated with a {{MediaSession}} that can be used by user agents to +provide a user interface that displays the current playback position and duration. + +The duration dictionary member +is used to specify the duration in seconds. It should always be positive +and positive infinity can be used to indicate media that is unending. + +The playbackRate dictionary member +is used to specify the playback rate. It can be positive to represent forward +playback, negative to represent backwards playback or zero to represent media that +is paused. + +The position dictionary member +is used to specify the last reported playback position in seconds. It should +always be positive. +Examples
This section is non-normative. @@ -1186,6 +1303,33 @@ agent to ignore images of media types it does not support.
+ // Media is loaded, set the duration. + navigator.mediaSession.setPositionState({ + duration: 60 + }); + + // Media starts playing at the beginning. + navigator.mediaSession.setPositionState({ + duration: 60, + playbackRate: 1, + position: 0 + }); + + // Media is paused 30 seconds in. + navigator.mediaSession.setPositionState({ + duration: 60, + playbackRate: 0, + position: 30 + }); + + // Media is reset. + navigator.mediaSession.setPositionState(null); ++