MediaPositionState.playbackRate - Web APIs 编辑

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

SpecificationStatusComment
Media Session Standard
The definition of 'MediaPositionState.playbackRate' in that specification.
DraftInitial definition.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:68 次

字数:3811

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文