HTML5 audio element

      No Comments on HTML5 audio element

Before HTML5 audio files could only be played in a browser with a plug-in (like flash).
The HTML5 <audio> element specifies a standard way to embed audio in a web page

 

Syntax to embed audio in HTML page:

<audio src="scanfcode.mp3" controls="controls">

Lest us understand the statement:
The audio element uses src attribute to determine the source name of the audio file.
controls is used to incorporate basic audio control buttons like pause, play, stop etc.

HTML5 audio attributes

  • preload:This attribute tells how to download a file.It supports two values:
    1. none: Browser holds off completely
    2. metadata:browser grabs small chunk of data from file which is used to determine basic details.
  • auto:This is the default value to start download of a file.
  • autoplay:This value tells the browser to start playing the file automatically as it downloads.
  • loop:Tells browser to start over when audio ends.

Syntax to apply attributes:

<audio src="scanfcode.mp3" controls="controls" preload="metadata"></audio>

<audio src="scanfcode.mp3" controls="controls" autoplay="autoplay"></audio>

<audio src="scanfcode.mp3" controls="controls" loop="loop"></audio>

Leave a Reply

Your email address will not be published. Required fields are marked *