HTMLAudio


Module hilo/media/HTMLAudio Requires hilo/core/Class, hilo/util/util, hilo/event/EventMixin Source HTMLAudio.js
HTMLAudio is an audio playing module, which uses HTMLAudioElement to play audio. Limits: iOS platform requires user action events to start playing, and many Android browser can only play one audio at a time.

Properties

Property Defined
autoPlay:Boolean
Is the audio autoplay, default value is false.
HTMLAudio
duration:Number
The duration of the audio, readonly!
HTMLAudio
loaded:Boolean
Is the audio resource loaded, readonly!
HTMLAudio
loop:Boolean
Is loop playback, default value is false.
HTMLAudio
muted:Boolean
Is the audio muted, default value is false.
HTMLAudio
playing:Boolean
Is the audio playing, readonly!
HTMLAudio
src:String
The source of the playing audio.
HTMLAudio
volume:Number
The volume of the audio, value between 0 to 1.
HTMLAudio
static Does the browser supports HTMLAudio.
HTMLAudio

Methods

Method Defined
HTMLAudio(properties:Object)
Constructor
HTMLAudio
load()
Load audio file.
HTMLAudio
Pause (halt) the currently playing audio.
HTMLAudio
play()
Start playing the audio.
HTMLAudio
Continue to play the audio.
HTMLAudio
setMute(muted)
Set mute mode.
HTMLAudio
setVolume(volume)
Set the volume.
HTMLAudio
stop()
Stop playing the audio.
HTMLAudio

Property Detail

autoPlay:Boolean
Is the audio autoplay, default value is false.
duration:Number
The duration of the audio, readonly!
[Static] isSupported
Does the browser supports HTMLAudio.
loaded:Boolean
Is the audio resource loaded, readonly!
loop:Boolean
Is loop playback, default value is false.
muted:Boolean
Is the audio muted, default value is false.
playing:Boolean
Is the audio playing, readonly!
src:String
The source of the playing audio.
volume:Number
The volume of the audio, value between 0 to 1.

Constructor

HTMLAudio(properties:Object)
parameters
properties:Object — create object properties, include all writable properties of this class.

Method Detail

load()
Load audio file.
pause()
Pause (halt) the currently playing audio.
play()
Start playing the audio. And play the audio from the beginning if the audio is already playing. Note: To prevent failing to play at the first time, play when the audio is loaded.
resume()
Continue to play the audio.
setMute(muted)
Set mute mode. Note: iOS devices cannot set mute mode.
parameters
muted
setVolume(volume)
Set the volume. Note: iOS devices cannot set volume.
parameters
volume
stop()
Stop playing the audio.