Audio playedProperty

Audio 对象参考手册Audio Object

Example

Get the first played range (in seconds) of the audio:

var x = document.getElementById("myAudio");
document.getElementById("demo").innerHTML = "Start: " + x.played.start(0)
+ " End: " + x.played.end(0)

xThe output is:

Start: 0 End: 2.162583

Try it Yourself »

Definition and Usage

The played property returns a TimeRanges object.

The TimeRanges object represents the audio ranges that the user has played or seen.

The played range refers to the time ranges of the audio that have been played. If the user jumps around in the audio, multiple played ranges will be obtained.

Note:This property is read-only.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the played property.

Note:Internet Explorer 8 and earlier IE versions do not support this property.


Syntax

audioObject.played

Return Value

Type Description
TimeRanges object

Represents the played ranges of the audio.

Properties of the TimeRanges object:

  • length - Gets the number of played ranges in the audio
  • start(indexstart(index) - Gets the start position of a played range
  • end(indexend(index) - Gets the end position of a played range

Note:The index of the first played range is 0.



Audio 对象参考手册Audio Object Other Extensions