• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

Audio

The HTML Audio element is used to play an audio file on a web page. There are three supported audio formats: MP3, WAV, and OGG. All of the attributes and events for HTML5 Audio are available to use.

Audio Tag Documentation

Audio is a media component that embeds an audio player.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
autoplay boolean false false Specifies that the media will start playing as soon as it is ready.
cache boolean false true Whether to cache the media content
controls boolean false false Specifies that media controls should be displayed (such as a play/pause button etc).
controlslist String false When specified, helps the browser select what controls to show. Values are nodownload, nofullscreen and noremoteplayback.
crossorigin String false Indicates whether to use CORS to fetch the related media file. Values are anonymous and user-credentials.
currentTime String false Sets or returns the current playback position in seconds.
defaultMuted boolean false false Specifies that the audio output should be muted by default.
defaultPlaybackRate String false Sets or returns the default speed of the media playback.
disablepictureinpicture boolean false false Prevents the browser from suggesting a Picture-in-Picture context menu or to request Picture-in-Picture automatically.
disableremoteplayback boolean false false Used to disable the capability of remote playback in devices that are attached using wired and wireless technologies.
height String false Height of the media component.
loop boolean false false Specifies that the media will start over again, every time it is finished.
muted boolean false false Specifies that the audio output of the media should be muted.
onabort String false Client-side callback to execute when the media loading is aborted.
oncanplay String false Client-side callback to execute when the browser can start playing the media.
oncanplaythrough String false Client-side callback to execute when the browser can play through the media without stopping for buffering.
ondurationchange String false Client-side callback to execute when the duration of the media is changed.
onemptied String false Client-side callback to execute when the media resource element suddenly becomes empty.
onended String false Client-side callback to execute when the media has reached the end.
onerror String false Client-side callback to execute when an error occurs while loading the media.
onloadeddata String false Client-side callback to execute when media data is loaded.
onloadedmetadata String false Client-side callback to execute when meta data (like dimensions and duration) are loaded.
onloadstart String false Client-side callback to execute when the browser starts looking for the media.
onpause String false Client-side callback to execute when the media is paused.
onplay String false Client-side callback to execute when the media is started or is no longer paused.
onplaying String false Client-side callback to execute when the media is playing after having been paused or stopped for buffering.
onprogress String false Client-side callback to execute when the browser is downloading the media.
onratechange String false Client-side callback to execute when the playing speed of the media is changed.
onseeked String false Client-side callback to execute when the user is finished moving/skipping to a new position in the media.
onseeking String false Client-side callback to execute when the user starts moving/skipping to a new position in the media.
onstalled String false Client-side callback to execute when the browser is trying to get media data, but data is not available.
onsuspend String false Client-side callback to execute when the browser is intentionally not getting media data.
ontimeupdate String false Client-side callback to execute when the playing position has changed.
onvolumechange String false Client-side callback to execute when the volume has been changed.
onwaiting String false Client-side callback to execute when the media has paused but is expected to resume.
playbackRate String false Sets or returns the speed of the media playback.
player String false Media player type.
playsinline boolean false false A Boolean attribute indicating that the video is to be played 'inline', that is within the element's playback area.
poster String false Specifies an image to be shown while the video is downloading, or until the user hits the play button.
preload String false Specifies if and how the author thinks the media should be loaded when the page loads. Values are auto, metadata, and none.
style String false Inline style of the component.
styleClass String false Style class of the component.
value Object false Media source value.
volume String false Sets or returns the audio volume of the media. Must be a number between 0.0 and 1.0.
width String false Width of the media component.
Loading...
Tag DocumentationNew DocumentationNew Documentation
MP3
OGG

Usage


<div class="card">
    <h5>MP3</h5>
    <p:audio value="http://download.lisztonian.com/music/download/Larghetto+in+F-62.mp3"
             player="mp3"
             controls="true"
             onplay="console.log('MP3 Started Playing')"
             onpause="console.log('MP3 Stopped Playing')">
        Your browser does not support the audio element.
        See: <h:outputLink value="https://www.w3schools.com/html/html5_audio.asp">HTML5 Audio</h:outputLink>
    </p:audio>
</div>
<div class="card">
    <h5>OGG</h5>
    <p:audio value="/resources/demo/media/sample-ogg.ogg"
             controls="true"
             onplay="console.log('OGG Started Playing')"
             onpause="console.log('OGG Stopped Playing')">
        Your browser does not support the audio element.
        See: <h:outputLink value="https://www.w3schools.com/html/html5_audio.asp">HTML5 Audio</h:outputLink>
    </p:audio>
</div>