|
1 | 1 | /*! |
2 | | - * howler.js v2.0.0 |
| 2 | + * howler.js v2.0.1 |
3 | 3 | * howlerjs.com |
4 | 4 | * |
5 | 5 | * (c) 2013-2016, James Simpson of GoldFire Studios |
|
170 | 170 | * @return {Boolean} |
171 | 171 | */ |
172 | 172 | codecs: function(ext) { |
173 | | - return (this || Howler)._codecs[ext]; |
| 173 | + return (this || Howler)._codecs[ext.replace(/^x-/, '')]; |
174 | 174 | }, |
175 | 175 |
|
176 | 176 | /** |
|
225 | 225 | mp4: !!(audioTest.canPlayType('audio/x-mp4;') || audioTest.canPlayType('audio/mp4;') || audioTest.canPlayType('audio/aac;')).replace(/^no$/, ''), |
226 | 226 | weba: !!audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, ''), |
227 | 227 | webm: !!audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, ''), |
228 | | - dolby: !!audioTest.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/, '') |
| 228 | + dolby: !!audioTest.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/, ''), |
| 229 | + flac: !!(audioTest.canPlayType('audio/x-flac;') || audioTest.canPlayType('audio/flac;')).replace(/^no$/, '') |
229 | 230 | }; |
230 | 231 |
|
231 | 232 | return self; |
|
820 | 821 | // Get the sound. |
821 | 822 | var sound = self._soundById(ids[i]); |
822 | 823 |
|
823 | | - if (sound && !sound._paused) { |
| 824 | + if (sound) { |
824 | 825 | // Reset the seek position. |
825 | 826 | sound._seek = sound._start || 0; |
826 | 827 | sound._rateSeek = 0; |
|
834 | 835 | if (self._webAudio) { |
835 | 836 | // make sure the sound has been created |
836 | 837 | if (!sound._node.bufferSource) { |
| 838 | + if (!internal) { |
| 839 | + self._emit('stop', sound._id); |
| 840 | + } |
| 841 | + |
837 | 842 | return self; |
838 | 843 | } |
839 | 844 |
|
|
930 | 935 | if (args.length === 0) { |
931 | 936 | // Return the value of the groups' volume. |
932 | 937 | return self._volume; |
933 | | - } else if (args.length === 1) { |
| 938 | + } else if (args.length === 1 || args.length === 2 && typeof args[1] === 'undefined') { |
934 | 939 | // First check if this is an ID, and if not, assume it is a new volume. |
935 | 940 | var ids = self._getSoundIds(); |
936 | 941 | var index = ids.indexOf(args[0]); |
|
1008 | 1013 | var diff = Math.abs(from - to); |
1009 | 1014 | var dir = from > to ? 'out' : 'in'; |
1010 | 1015 | var steps = diff / 0.01; |
1011 | | - var stepLen = len / steps; |
| 1016 | + var stepLen = (steps > 0) ? len / steps : len; |
| 1017 | + |
| 1018 | + // Since browsers clamp timeouts to 4ms, we need to clamp our steps to that too. |
| 1019 | + if (stepLen < 4) { |
| 1020 | + steps = Math.ceil(steps / (4 / stepLen)); |
| 1021 | + stepLen = 4; |
| 1022 | + } |
1012 | 1023 |
|
1013 | 1024 | // If the sound hasn't loaded, add it to the load queue to fade when capable. |
1014 | 1025 | if (self._state !== 'loaded') { |
|
1049 | 1060 |
|
1050 | 1061 | var vol = from; |
1051 | 1062 | sound._interval = setInterval(function(soundId, sound) { |
1052 | | - // Update the volume amount. |
1053 | | - vol += (dir === 'in' ? 0.01 : -0.01); |
| 1063 | + // Update the volume amount, but only if the volume should change. |
| 1064 | + if (steps > 0) { |
| 1065 | + vol += (dir === 'in' ? 0.01 : -0.01); |
| 1066 | + } |
1054 | 1067 |
|
1055 | 1068 | // Make sure the volume is in the right bounds. |
1056 | 1069 | vol = Math.max(0, vol); |
|
1147 | 1160 | sound._loop = loop; |
1148 | 1161 | if (self._webAudio && sound._node && sound._node.bufferSource) { |
1149 | 1162 | sound._node.bufferSource.loop = loop; |
| 1163 | + if (loop) { |
| 1164 | + sound._node.bufferSource.loopStart = sound._start || 0; |
| 1165 | + sound._node.bufferSource.loopEnd = sound._stop; |
| 1166 | + } |
1150 | 1167 | } |
1151 | 1168 | } |
1152 | 1169 | } |
|
1439 | 1456 | delete cache[self._src]; |
1440 | 1457 | } |
1441 | 1458 |
|
| 1459 | + // Clear global errors. |
| 1460 | + Howler.noAudio = false; |
| 1461 | + |
1442 | 1462 | // Clear out `self`. |
1443 | 1463 | self._state = 'unloaded'; |
1444 | 1464 | self._sounds = []; |
|
1900 | 1920 | _errorListener: function() { |
1901 | 1921 | var self = this; |
1902 | 1922 |
|
1903 | | - if (self._node.error && self._node.error.code === 4) { |
1904 | | - Howler.noAudio = true; |
1905 | | - } |
1906 | | - |
1907 | 1923 | // Fire an error event and pass back the code. |
1908 | 1924 | self._parent._emit('loaderror', self._id, self._node.error ? self._node.error.code : 0); |
1909 | 1925 |
|
|
2162 | 2178 | /*! |
2163 | 2179 | * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported. |
2164 | 2180 | * |
2165 | | - * howler.js v2.0.0 |
| 2181 | + * howler.js v2.0.1 |
2166 | 2182 | * howlerjs.com |
2167 | 2183 | * |
2168 | 2184 | * (c) 2013-2016, James Simpson of GoldFire Studios |
|
0 commit comments