MediaPositionState.duration - Web APIs 编辑

The MediaPositionState dictionary's duration property is used when calling the MediaSession method setPositionState() to provide the user agent 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 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 = { duration: durationInSeconds };

let durationInSeconds = positionState.duration;

Value

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).

Example

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);

Specifications

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

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

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

发布评论

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

词条统计

浏览:114 次

字数:3471

最后编辑:6 年前

编辑次数:0 次

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