MediaPositionState
dictionary's
playbackRate
property is used when calling the
MediaSession
方法
setPositionState()
to tell the
用户代理
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
位置
特性和
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.
let positionState = { playbackRate: rate };
let playbackRate = positionState.playbackRate;
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.
注意: A value of 0.0 is not permitted.
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
.
| 规范 | 状态 | 注释 |
|---|---|---|
|
Media Session Standard
The definition of 'MediaPositionState.playbackRate' in that specification. |
草案 | 初始定义。 |
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
No compatibility data found. Please contribute data for "api.MediaPositionState.playbackRate" (depth: 1) to the MDN 兼容性数据存储库 .
MediaPositionState