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
Specification | Status | Comment |
---|---|---|
Media Session Standard The definition of 'MediaPositionState.playbackRate' in that specification. | Draft | Initial definition. |
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论