Latest web development tutorials

HTML DOM Audio loop properties

Audio Object Reference Audio Object

Examples

Audio set to loop:

document.getElementById("myAudio").loop = true;

try it"

Definition and Usage

loop property sets or returns whether the audio should be played again at the end of play.

This property reflects the <audio> loop property.

When using this property, the audio continues to play after playing end.

Note: <audio> elements in HTML5 is new.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support loop property.

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


grammar

Back loop properties:

audioObject .loop

Set loop properties:

audioObject .loop=true|false

Property Value

描述
true|false 指示音频在结束时是否再次播放。
  • true - 指示音频在结束时再次播放。
  • false - 默认。指示音频在结束时不再播放。

technical details

return value: Boolean value that, if the audio loop returns true, otherwise returns false.
Defaults: false


More examples

Examples

Check whether the audio player to play again after:

var x = document.getElementById("myAudio").loop;
x The output is:
true

try it"


Related Pages

HTML Reference Manual: HTML <Audio> Loop Properties


Audio Object Reference Audio Object