MediaPositionState.playbackRate

The MediaPositionState dictionary's playbackRate property is used when calling the MediaSession method setPositionState() to tell the user agent the rate at which media is currently being played. This information can then, in turn, be used by the user agent to provide a user interface which displays media playback information to the viewer.

For example, a browser might use this information along with the position property and the navigator.mediaSession.playbackState, as well as the session's metadata to provide an integrated common user interface showing the currently playing media as well as standard pause, play, forward, reverse, and other controls.

Syntax

let positionState = { playbackRate: rate };

let playbackRate = positionState.playbackRate;

Value

A floating-point value specifying a multiplier corresponding to the current relative rate at which the media being performed is playing. A value of 1.0 indicates the media is playing forward at normal speed, while higher values indicate that the media is being played faster than normal. Lower values indicate the media is being played more slowly. Negative values can be specified to indicate the media is playing in reverse, with decreasing values then indicating faster and faster reverse playback.

Note: A value of 0.0 is not permitted.

Example

In this example, an app is updating the browser to let it know that the user has clicked a button causing the playback to shift to a double-speed mode. It begins by creating a MediaPositionState object, then submits it to the browser it by calling navigator.mediaSession.setPositionState().

let positionState = {
  duration: myMediaDuration;
  playbackRate: 2.0;
  position: myMediaPosition;
};

navigator.mediaSession.setPositionState(positionState);

Note the value 2.0 as the playbackRate.

Specifications

Specification Status Comment
Media Session Standard
The definition of 'MediaPositionState.playbackRate' in that specification.
Draft Initial definition.

Browser compatibility

No compatibility data found. Please contribute data for "api.MediaPositionState.playbackRate" (depth: 1) to the MDN compatibility data repository.