HTMLMediaElement.duration

This translation is incomplete. Please help translate this article from English

HTMLMediaElement.duration 属性以秒为单位给出媒体的长度,如果没有媒体数据可用,则为零。

语法

var myDuration = audioOrVideo.duration

 如果媒体数据可用但长度未知,则此值为NaN。 如果媒体流式传输且没有预定义长度,则值为Inf。

例子

var obj = document.createElement('video');
console.log(obj.duration); // NaN

规范

规范 状态 注释
HTML Living Standard
HTMLMediaElement.duration
Living Standard No change from HTML5
HTML5
HTMLMediaElement.duration
Recommendation Initial definition.

浏览器支持

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
durationChrome Full support 43Edge Full support 12Firefox Full support 3.5IE Full support 9Opera Full support YesSafari Full support 6WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 4.0

Legend

Full support  
Full support

相关内容