The HTML5 audio element is a standard way to embed audio content in Web applications. You can use the audio element to stream audio files on a Samsung Smart TV. The audio element inherits all the properties and methods of the HTMLMediaElement interface.

Samsung TVs support a variety of standard audio formats. For more information on the supported formats, see the Media Specifications.

Implementing an Audio Player

To create an audio player using HTML5:

Create an audio element, and add attributes and properties.
You can create the element in HTML or in JavaScript:

The following are some basic properties for the JavaScript audio element. You can also use the HTML attributes as properties. For more information, see the HTMLMediaElement Properties.

audioTracks: Lists the audio tracks contained in the element.

buffered: Returns the time ranges that the audio player has buffered.

currentTime: Indicates the current playback position, in seconds.

duration: Indicates the length of the media, in seconds.

ended: Indicates whether the media has finished playing.

paused: Indicates whether the media playback is paused.

volume: Indicates the audio volume, where 0.0 is silent and 1.0 is loudest.

Note

The audio element only differs from the video element by having no visual component to the player. Attributes related to the visual component, such as height, width, and poster image, are not supported by the audio element.

Define event listeners.
For more information on the available events, see Media events.

canPlayType(): Determine whether the specified media type can be played.

load(): Reset the audio player and restart media playback. This method can be useful for releasing resources after any src attribute and source element descendants have been removed.

pause(): Pause media playback. If playback is already paused, this method has no effect.

play(): Begin media playback.

To move to a specific time in the media, set the currentTime property. The currentTime property sets or returns the current playback position, in seconds. When you set this property, the playback jumps to the specified position in the audio.

If the meta data of the media file is loaded, you can move to the specified time position even when the media file is not playing. For more information, see Retrieving Media Information.

To control the playback rate (trick play) of the media, set the playbackRate property as a multiplier for the playback rate.
Positive values for the playbackRate property play the media forwards, while negative values cause the media to play in reverse.

To improve application performance, you can optionally add the type attribute to each source element. By indicating the MIME types of the media files using the type attribute, you can immediately skip media in formats that are not supported by the TV.

When the first audio file has finished playing, start playback for the next file: