WebSound


Module hilo/media/WebSound Requires hilo/media/HTMLAudio, hilo/media/WebAudio, hilo/util/util Source WebSound.js
Audio playing manager.


demo:

var audio = WebSound.getAudio({
    src: 'test.mp3',
    loop: false,
    volume: 1
}).on('load', function(e){
    console.log('load');
}).on('end', function(e){
    console.log('end');
}).play();

Methods

Method Defined
static Activate audio function.
WebSound
getAudio(source:String|Object, preferWebAudio:Boolean):WebAudio|HTMLAudio
static Get audio element.
WebSound
removeAudio(source:String|Object)
static Remove audio element.
WebSound

Method Detail

[Static] enableAudio()
Activate audio function. Note: Require user action events to activate. Currently support WebAudio.
[Static] getAudio(source:String|Object, preferWebAudio:Boolean):WebAudio|HTMLAudio
Get audio element. Default use WebAudio if supported.
parameters
source:String|Object — If String, it's the source of the audio; If Object, it should contains a src property.
preferWebAudio:Boolean Optional, Default: true — Whether or not to use WebAudio first, default is true.
return
WebAudio|HTMLAudio — Audio playing instance.
[Static] removeAudio(source:String|Object)
Remove audio element.
parameters
source:String|Object — If String, it's the source of the audio; If Object, it should contains a src property.