
The load() method re-loads the audio/video element. The pause() method halts (pauses) the currently playing audio or video. The play() method starts playing the current audio or video.Įxample: var music = document.getElementById("myAudio") src - Specifies the URL of the audio file.It's value can be auto, metadata or none. preload - Specifies if and how the author thinks the audio should be loaded when the page loads.muted - Specifies that the audio output should be muted.

loop - Specifies that the audio will start over again, every time it is finished.controls - Specifies that audio controls should be displayed (such as a play/pause button etc).autoplay - Specifies that the audio will start playing as soon as it is ready.We can also use the Web Audio API to directly generate and manipulate audio streams from JavaScript code.tag can't have subtitles/captions associated with it.We can get precise control over our audio using HTMLMediaElement methods.We can create our own custom controls using JavaScript and the HTMLMediaElement API. If we don't specify the controls attribute, the audio player won't include the browser's default controls.Your browser doesn't support HTML5 audio. This can be explained from the example listed below: Wou can provide multiple sources inside nested tags, and the browser will then use the first one it understands. ⭐ Important: Browsers don't all support the same audio formats.

The content inside the opening and closing tags is shown as a fallback in browsers that don't support the element. We can include other attributes to specify information such as, whether we want it to autoplay and loop, whether we want to show the browser's default audio controls, etc. Similar to or tags, we include a path to the media we want to embed inside the src attribute. The above example shows simple usage of the tag. Your browser does not support the audio element. It can also be the destination for streamed media, using a MediaStream. We will discuss about in in later part of the article. It may contain one or more audio sources, represented using the src attribute or the element: the browser will choose the most suitable one. The HTML element is used to embed sound or music element in our HTML page.
