HTML5 的音樂工具庫:Sound.js
Audio & WebAudio的一個封裝用于播放一個正常音頻文件。
</div>
Use HTML5 Audio: var sound = new Sound({ id: "bgm-1", src: "res/bgm-1.mp3", loop: false, volume: 1, tag: "bg", channel: 4, useWebAudio: false, }); sound.load(); sound.onLoad = function(){ this.play(); }
Use WebAudio :
var sound = new Sound({ id: "sfx-1", src: "res/sfx-1.mp3", loop: false, volume: 1, tag: "sfx", channel: 2, useWebAudio: true, }); sound.load(); sound.onLoad = function(){ this.play(); }
useWebAudio: default is true. It will try to use WebAudio first.
channel: for Multi Channel .
sound.play(); setTimeout(function(){ // if channel <=1 , // the prev playing will be stopped. // else , another there will be a new playing sound.play(); },1000);
tag: you can do something to many sounds by tag. example:
Sound.setMuteByTag("bg", true)
all sounds that tag=="bg" will be muted.
=====================
Sound.loadSounds : load sounds in batch
... ...
More features in Source Code :P
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!