@@ -58,11 +58,19 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
5858 var extName = this . _getExtFromFullPath ( path ) ;
5959 var keyname = this . _getPathWithoutExt ( path ) ;
6060 if ( this . _checkAudioFormatSupported ( extName ) && ! this . _soundList . hasOwnProperty ( keyname ) ) {
61+ /*var sfxCache = new cc.SFX();
62+ sfxCache.ext = extName;
63+ sfxCache.audio = new Howl({
64+ urls: [path]
65+ });
66+
67+ this._soundList[keyname] = sfxCache;*/
68+
6169 var soundCache = new Howl ( {
6270 urls : [ path ]
6371 } ) ;
6472
65- this . _soundList [ keyname ] = true ;
73+ // this._soundList[keyname] = true;
6674 }
6775 }
6876 cc . Loader . getInstance ( ) . onResLoaded ( ) ;
@@ -78,21 +86,23 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
7886 */
7987 playMusic :function ( path , loop ) {
8088 var keyname = this . _getPathWithoutExt ( path ) ;
81- var actExt = this . _supportedFormat [ 0 ] ;
82-
89+ var extName = this . _getExtFromFullPath ( path ) ;
8390 var au ;
84- if ( this . _muiscList . hasOwnProperty ( this . _playingMusic ) ) {
85- this . _muiscList [ this . _playingMusic ] . pause ( ) ;
91+
92+ if ( this . _soundList . hasOwnProperty ( this . _playingMusic ) ) {
93+ this . _soundList [ this . _playingMusic ] . audio . pause ( ) ;
8694 }
8795 this . _playingMusic = keyname ;
8896
89- if ( this . _muiscList . hasOwnProperty ( keyname ) ) {
90- au = this . _muiscList [ keyname ] ;
97+ if ( this . _soundList . hasOwnProperty ( this . _playingMusic ) ) {
98+ au = this . _soundList [ keyname ] . audio ;
9199 } else {
92- au = new Howl ( {
93- urls : [ keyname + "." + actExt ]
100+ var sfxCache = new cc . SFX ( ) ;
101+ sfxCache . ext = extName ;
102+ au = sfxCache . audio = new Howl ( {
103+ urls : [ keyname + "." + extName ]
94104 } ) ;
95- this . _muiscList [ keyname ] = au ;
105+ this . _soundList [ keyname ] = sfxCache ;
96106 }
97107
98108 if ( loop ) {
@@ -110,11 +120,11 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
110120 * cc.AudioEngine.getInstance().stopMusic();
111121 */
112122 stopMusic :function ( releaseData ) {
113- if ( this . _muiscList . hasOwnProperty ( this . _playingMusic ) ) {
114- this . _muiscList [ this . _playingMusic ] . loop ( false ) . stop ( ) ;
123+ if ( this . _soundList . hasOwnProperty ( this . _playingMusic ) ) {
124+ this . _soundList [ this . _playingMusic ] . audio . loop ( false ) . stop ( ) ;
115125 this . _isMusicPlaying = false ;
116126 if ( releaseData ) {
117- delete this . _muiscList [ this . _playingMusic ] ;
127+ delete this . _soundList [ this . _playingMusic ] ;
118128 }
119129 }
120130 } ,
@@ -126,8 +136,8 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
126136 * cc.AudioEngine.getInstance().pauseMusic();
127137 */
128138 pauseMusic :function ( ) {
129- if ( this . _muiscList . hasOwnProperty ( this . _playingMusic ) ) {
130- this . _muiscList [ this . _playingMusic ] . pause ( ) ;
139+ if ( this . _soundList . hasOwnProperty ( this . _playingMusic ) ) {
140+ this . _soundList [ this . _playingMusic ] . audio . pause ( ) ;
131141 this . _isMusicPlaying = false ;
132142 }
133143 } ,
@@ -139,8 +149,8 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
139149 * cc.AudioEngine.getInstance().resumeMusic();
140150 */
141151 resumeMusic :function ( ) {
142- if ( this . _muiscList . hasOwnProperty ( this . _playingMusic ) ) {
143- this . _muiscList [ this . _playingMusic ] . play ( ) ;
152+ if ( this . _soundList . hasOwnProperty ( this . _playingMusic ) ) {
153+ this . _soundList [ this . _playingMusic ] . audio . play ( ) ;
144154 this . _isMusicPlaying = true ;
145155 }
146156 } ,
@@ -152,8 +162,8 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
152162 * cc.AudioEngine.getInstance().rewindMusic();
153163 */
154164 rewindMusic :function ( ) {
155- if ( this . _muiscList . hasOwnProperty ( this . _playingMusic ) ) {
156- this . _muiscList [ this . _playingMusic ] . stop ( ) . play ( ) ;
165+ if ( this . _soundList . hasOwnProperty ( this . _playingMusic ) ) {
166+ this . _soundList [ this . _playingMusic ] . audio . stop ( ) . play ( ) ;
157167 this . _isMusicPlaying = true ;
158168 }
159169 } ,
@@ -166,8 +176,8 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
166176 * var volume = cc.AudioEngine.getInstance().getMusicVolume();
167177 */
168178 getMusicVolume :function ( ) {
169- if ( this . _muiscList . hasOwnProperty ( this . _playingMusic ) ) {
170- return this . _muiscList [ this . _playingMusic ] . volume ( ) ;
179+ if ( this . _soundList . hasOwnProperty ( this . _playingMusic ) ) {
180+ return this . _soundList [ this . _playingMusic ] . audio . volume ( ) ;
171181 }
172182 return 0 ;
173183 } ,
@@ -180,8 +190,8 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
180190 * cc.AudioEngine.getInstance().setMusicVolume(0.5);
181191 */
182192 setMusicVolume :function ( volume ) {
183- if ( this . _muiscList . hasOwnProperty ( this . _playingMusic ) ) {
184- var music = this . _muiscList [ this . _playingMusic ] ;
193+ if ( this . _soundList . hasOwnProperty ( this . _playingMusic ) ) {
194+ var music = this . _soundList [ this . _playingMusic ] . audio ;
185195 if ( volume > 1 ) {
186196 music . volume ( 1 ) ;
187197 } else if ( volume < 0 ) {
@@ -201,8 +211,13 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
201211 * var soundId = cc.AudioEngine.getInstance().playEffect(path);
202212 */
203213 playEffect :function ( path , loop ) {
204- var keyname = this . _getPathWithoutExt ( path ) ;
205- var actExt = this . _supportedFormat [ 0 ] ;
214+ var keyname = this . _getPathWithoutExt ( path ) , actExt ;
215+ if ( this . _soundList . hasOwnProperty ( keyname ) ) {
216+ actExt = this . _soundList [ keyname ] . ext ;
217+ }
218+ else {
219+ actExt = this . _getExtFromFullPath ( path ) ;
220+ }
206221
207222 var au ;
208223 if ( this . _effectList . hasOwnProperty ( keyname ) ) {
@@ -217,14 +232,14 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
217232 //to prevent a bug. when one effect plays in a loop,
218233 //no effect of the same type can play at the same time
219234 if ( au . loop ( ) ) {
220- return keyname ;
235+ return path ;
221236 }
222237
223238 if ( loop ) {
224239 au . loop ( loop ) ;
225240 }
226241 au . play ( ) ;
227- return keyname ;
242+ return path ;
228243 } ,
229244
230245 /**
@@ -260,6 +275,7 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
260275 * cc.AudioEngine.getInstance().pauseEffect(path);
261276 */
262277 pauseEffect :function ( path ) {
278+ if ( ! path ) return ;
263279 var keyname = this . _getPathWithoutExt ( path ) ;
264280 if ( this . _effectList . hasOwnProperty ( keyname ) ) {
265281 this . _effectList [ keyname ] . loop ( false ) . pause ( ) ;
@@ -288,6 +304,7 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
288304 * cc.AudioEngine.getInstance().resumeEffect(path);
289305 */
290306 resumeEffect :function ( path ) {
307+ if ( ! path ) return ;
291308 var keyname = this . _getPathWithoutExt ( path ) ;
292309 if ( this . _effectList . hasOwnProperty ( keyname ) ) {
293310 this . _effectList [ keyname ] . play ( ) ;
@@ -316,6 +333,7 @@ cc.HowlerAudioEngine = cc.AudioEngine.extend(/** @lends cc.AudioEngine# */{
316333 * cc.AudioEngine.getInstance().stopEffect(path);
317334 */
318335 stopEffect :function ( path ) {
336+ if ( ! path ) return ;
319337 var keyname = this . _getPathWithoutExt ( path ) ;
320338 if ( this . _effectList . hasOwnProperty ( keyname ) ) {
321339 this . _effectList [ keyname ] . loop ( false ) . stop ( ) ;
0 commit comments