WebAudio


Module hilo/media/WebAudio Requires hilo/core/Class, hilo/util/util, hilo/event/EventMixin Source WebAudio.js
WebAudio audio playing module. It provides a better way to play and control audio, use on iOS6+ platform. Compatibility:iOS6+、Chrome33+、Firefox28+ supported,but all Android browsers do not support.

Properties

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

Methods

Method Defined
WebAudio(properties:Object)
Constructor
WebAudio
load()
Load audio file.
WebAudio
Pause (halt) playing the audio.
WebAudio
play()
Play the audio.
WebAudio
Continue to play the audio.
WebAudio
setMute(muted)
Set mute mode.
WebAudio
setVolume(volume)
Set the volume.
WebAudio
stop()
Stop playing the audio.
WebAudio
static Activate WebAudio.
WebAudio
clearBufferCache(url:String)
static Clear the audio buffer cache.
WebAudio

Property Detail

autoPlay:Boolean
Is the audio autoplay, default value is false.
duration:Number
The duration of the audio, readonly!
[Static] enabled
Does browser activate WebAudio already.
[Static] isSupported
Does the browser support WebAudio.
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

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

Method Detail

[Static] clearBufferCache(url:String)
Clear the audio buffer cache.
parameters
url:String — audio's url. if url is none, it will clear all buffer.
[Static] enable()
Activate WebAudio. Note: Require user action events to activate. Once activated, can play audio without user action events.
load()
Load audio file. Note: use XMLHttpRequest to load the audio, should pay attention to cross-origin problem.
pause()
Pause (halt) playing the audio.
play()
Play the audio. Restart playing the audio from the beginning if already playing.
resume()
Continue to play the audio.
setMute(muted)
Set mute mode.
parameters
muted
setVolume(volume)
Set the volume.
parameters
volume
stop()
Stop playing the audio.