MediaPositionState
dictionary's
duration
property is used when calling the
MediaSession
方法
setPositionState()
to provide the
用户代理
with the overall total duration in seconds of the media currently being performed.
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 = { duration: durationInSeconds };
let durationInSeconds = positionState.duration;
A floating-point value indicating the overall duration, in seconds, of the media being performed. This value should always be positive. To indicate media of unknown or indeterminate length, such as an ongoing live stream, specify a value of positive infinity (
Infinity
).
In this example, an app performing a live stream provides information to the browser by preparing a
MediaPositionState
object and submitting it by calling
navigator.mediaSession.setPositionState()
.
let positionState = {
duration: Infinity;
playbackRate: 1.0;
position: 0.0;
};
navigator.mediaSession.setPositionState(positionState);
| 规范 | 状态 | 注释 |
|---|---|---|
|
Media Session Standard
The definition of 'MediaPositionState.duration' 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.duration" (depth: 1) to the MDN 兼容性数据存储库 .
MediaPositionState
duration
playbackRate
位置