This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2022.
The totalSamplesDuration property of the RTCRemoteInboundRtpStreamStats dictionary indicates the total duration of all audio samples that have been received. In other words, the current duration of the track.
This can be used with totalAudioEnergy to compute an average audio level over different intervals.
Note: The value is undefined for video streams.
An positive number, in seconds.
| Specification |
|---|
| Identifiers for WebRTC's Statistics API> # dom-rtcinboundrtpstreamstats-totalsamplesduration> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
totalSamplesDuration |
86 | 86 | 106 | 72 | 14.1 | 86 | 106 | 61 | 14.5 | 14.0 | 86 | 14.5 |
RTCAudioSourceStats.totalSamplesDuration for the audio duration of sent samples.totalSamplesReceived
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCInboundRtpStreamStats/totalSamplesDuration