Open In App
Related Articles

How to play audio repeatedly using HTML5 ?

Improve Article
Improve
Save Article
Save
Like Article
Like

This article will show you how an audio file can be played repeatedly on a web page. This is done by using the loop attribute of the <audio> tag. It is used to restart the audio again and again after loading the web page. This can be used in situations where the audio has to be looped until it is specifically stopped, like in the case of background music on a web page.

Syntax:

<audio loop>

Example:

html




<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to play an audio repeatedly
        using HTML5?
    </title>
</head>
  
<body>
    <h1 style="color: green;">
        GeeksForGeeks
    </h1>
    <b>
        How to play an audio repeatedly
        using HTML5?
    </b>
  
    <p><b>Non Looping Audio</b></p>
  
    <audio controls>
        <source src=
        type="audio/mp3">
    </audio>
  
  
    <p><b>Looping Audio</b></p>
  
  
    <!-- Using the loop attribute -->
    <audio controls loop>
        <source src=
        type="audio/mp3">
    </audio>
</body>
  
</html>

Output:
 

Supported Browsers:

  • Google Chrome 4.0
  • Internet Explorer 9.0
  • Firefox 3.5
  • Opera 10.5
  • Safari 4.0
     

Last Updated : 14 Jul, 2020
Like Article
Save Article
Similar Reads
Related Tutorials