Commit graph

102 commits

Author SHA1 Message Date
photonstorm
d98b984ad2 SoundManager.volume now has its input value clamped to ensure it's between 0 and 1 (inclusive) 2015-05-05 11:04:14 +01:00
photonstorm
36c7084e01 Adjusting property order. 2015-05-05 10:59:54 +01:00
photonstorm
adad60f8f4 SoundManager.onVolumeChange is a new signal that is dispatched whenever the global volume changes. The new volume is passed as the only parameter to your callback.
SoundManager.onMute is a new signal that is dispatched when the SoundManager is globally muted, either directly via game code or as a result of the game pausing.

SoundManager.onUnMute is a new signal that is dispatched when the SoundManager is globally un-muted, either directly via game code or as a result of the game resuming from a pause.
2015-05-05 10:58:43 +01:00
photonstorm
e6ab4884a6 Set usingWebAudio if using it :) 2015-04-21 02:07:47 +01:00
photonstorm
8476a0b87f One ! too many #1746 2015-04-17 14:26:01 +01:00
photonstorm
59beae762d The SoundManager didn't accurately detect devices or browser environments with no sound card present and would try to carry on using a null Web Audio context (thanks @englercj #1746)
SoundManager.pauseAll, resumeAll and stopAll now checks if the SoundManager.noAudio is set and ignores the calls.

SoundManager.usingWebAudio is set to `false` by default (used to be `true`) and is only explicitly set if Web Audio is available and hasn't been disabled in the PhaserGlobal object.

SoundManager.touchLocked is now set to `false` should the device be using legacy Audio, avoiding the unlock call running without need.
2015-04-17 03:49:20 +01:00
photonstorm
96e313e768 If you paused a Sound object that is using audio markers and then resumed it, it wouldn't correctly calculate the resume duration - causing the sound to sometimes play into the marker that followed it (thanks @AnderbergE #1669) 2015-03-24 14:43:35 +00:00
photonstorm
0a45223cd4 Resuming a sound needs the onended handler adding back in again. 2015-03-04 00:32:33 +00:00
photonstorm
a69e53f901 Copyright date change. 2015-02-25 03:36:23 +00:00
photonstorm
e93ded324f Added missing class var. 2015-02-22 19:30:34 +00:00
photonstorm
ba08498e73 Fixed bug with the watch list not checking decode status by key properly. 2015-02-20 00:58:05 +00:00
photonstorm
72d1c13b6b Fixed jshint error. 2015-02-18 14:54:19 +00:00
photonstorm
ef3cb1f31d Sound in Web Audio now uses AudioContext.onended to trigger when it will stop playing instead of using a time based value. This is only used if the sound doesn't loop and isn't an audio sprite, but will give a much more accurate Sound.onStop event. It also prevents short audio files from being cut off during playback (#1471) and accounts for time spent decoding. 2015-02-18 11:25:17 +00:00
photonstorm
74bee324a5 Sound.fadeIn now supports fading from a marker, as well as the entire audio clip, so now works with audio sprites (thanks @vorrin #1413) 2015-02-11 13:52:16 +00:00
photonstorm
dfee82834d Sound.loop even when set for WebAudio wouldn't use the AudioContext loop property because Sound.start was being invoked with an offset and duration. Now if loop is true and no marker is being used it will use the native Web Audio loop support (#1431)
SoundManager.setDecodedCallback lets you specify a list of Sound files, or keys, and a callback. Once all of the Sound files have finished decoding the callback will be invoked. The amount of time spent decoding depends on the codec used and file size. If all of the files given have already decoded the callback is triggered immediately.

Sound.loopFull is a new method that will start playback of the Sound and set it to loop in its entirety.
2015-02-11 05:17:53 +00:00
photonstorm
ac14edae94 Sound.stop and Sound.destroy now halt a fade tween if in effect. 2015-02-03 16:17:03 +00:00
photonstorm
d37ffe6a8f Sound.fadeTween is now used for Sound.fadeIn and Sound.fadeOut audio tweens.
Sound.stop and Sound.destroy now halt a fade tween if in effect.
2015-01-28 17:18:32 +00:00
photonstorm
65f8820514 SoundManager.unlock checks for audio start support and falls back to noteOn if not found. 2015-01-06 13:50:15 +00:00
photonstorm
b22233a0bc docs update and sound marker check. 2015-01-02 04:14:44 +00:00
photonstorm
fa40b3a7a9 Removed readyState check as it breaks overlapping sounds. 2014-12-18 11:14:45 +00:00
photonstorm
269af69da5 Added extra checks to Sound.play to stop it throwing DOM Exception Error 11 if the sound.readyState wasn't set or the sound was invalid. Also wrapped stop() call in a try catch`. 2014-12-17 13:07:19 +00:00
photonstorm
d8fee414b8 Merge remote-tracking branch 'origin/dev' 2014-12-03 10:40:35 +00:00
photonstorm
40c490ce23 Phaser 2.2 Release Candidate 8 (newsletter build) 2014-11-17 14:14:50 +00:00
photonstorm
ff8a138081 jshint fix 2014-11-16 21:18:29 +00:00
photonstorm
5cd4225412 If you are reloading a Phaser Game on a page that never properly refreshes (such as in an AngularJS project) then you will quickly run out of AudioContext nodes. If this is the case create a global var called PhaserGlobal on the window object before creating the game. The active AudioContext will then be saved to window.PhaserGlobal.audioContext when the Phaser game is destroyed, and re-used when it starts again (#1233) 2014-11-16 21:05:31 +00:00
Sheepolution
266adf06d8 Removed an unnecessary if-statement.
Not sure if it had any purpose. Maybe to make it more clear?

Just a suggestion of something I noticed.
2014-11-10 23:28:20 +01:00
photonstorm
0a86a7ef51 Time.now can no longer be relied upon to contain a timestamp value. If the browser supports requestAnimationFrame then Time.now will contain the high resolution timer value that rAf generates. Otherwise it will contain the value of Date.now. If you require the actual time value (in milliseconds) then please use Time.time instead. Note that all Phaser sub-systems that used to rely on Time.now have been updated, so if you have any code that extends these please be sure to check it. 2014-11-08 20:01:10 +00:00
photonstorm
96fd0ade74 JSDoc fixes. 2014-10-21 22:43:42 +01:00
photonstorm
2657de0daa Sound.fadeTo allows you to fade the Sound to the given volume over the duration specified (thanks @nickryall #1225) 2014-10-15 21:48:00 +01:00
Richard Davey
33ebc10570 Merge pull request #1225 from nickryall/dev
Phaser.Sound.fadeTo Method
2014-10-15 21:44:42 +01:00
Bobby Wilson
0482684dc8 changed all typeof comparisons from == to === 2014-10-10 21:52:06 -06:00
nickryall
f5db1b070e Phaser.Sound.fadeTo Method 2014-10-10 11:03:13 +13:00
photonstorm
506a091257 Sound.allowMultiple allows you to have multiple instances of a single Sound playing at once. This is only useful when running under Web Audio, and we recommend you implement a local pooling system to not flood the sound channels. But it allows for one Sound object to play overlapping times, useful for gun effects and similar (#1220) 2014-10-09 14:44:25 +01:00
photonstorm
9e29a58d89 Sound.fadeOut(duration) will fade the Sound to a volume of zero over the duration given. At the end of the fade the Sound will be stopped and Sound.onFadeComplete dispatched.
Sound.fadeIn(duration, loop) will start the Sound playing, or restart it if already playing, set its volume to zero and then increase the volume over the duration given until it reaches 1. At the end of the fade the Sound.onFadeComplete event is dispatched.
2014-09-24 06:51:39 +01:00
Richard Davey
473e9a1d88 jshint fix 2014-09-23 22:28:15 +01:00
Richard Davey
01fd3df434 AudioSprite support is now built into the Loader and SoundManager. AudioSprites are like sprite sheets, only they consist of a selection of audio files and markers in a json configuration. You can find more details at https://github.com/tonistiigi/audiosprite (thanks @codevinsky #1205)
Fixed AudioSprite jsdoc, casing and formatting issues.
2014-09-23 22:15:09 +01:00
Jeremy Dowell
7cce1366f2 jshint cleanup 2014-09-23 10:25:49 -05:00
Jeremy Dowell
dd0d1729ad Phaser.AudioSprite
AudioSprite implementation for phaser.

Loads audio sprites based on the file format created with: https://github.com/tonistiigi/audiosprite
2014-09-23 10:21:29 -05:00
photonstorm
20551f9129 Lots of jsdocs fixes ready for the new doc generator. 2014-09-16 17:35:08 +01:00
photonstorm
8fec5169f0 Added Sound._muteVolume which stops Firefox and IE9 crashing if you try to unmute a sound that hasn't yet been muted, which can also happen as a result of a game visibility change (thanks @osmanzeki #1108 #1123) 2014-09-01 03:13:05 +01:00
photonstorm
26a55bd202 SoundManager.destroy is a new method that will destroy all current sounds and reset any callbacks.
StateManager.clearCurrentState now handles the process of clearing down the current state and is now called if the Game is destroyed.
Game.destroy now clears the current state, activating its shutdown callback if it had one. It also now destroys the SoundManager, stopping any currently running sounds (#1092)
2014-08-29 11:37:47 +01:00
photonstorm
52ea95d9ce Sound.restart used to cause the Sound to double-up if it was already playing when called. Now correctly stops the sound before restarting it (thanks @wombatbuddy #1136) 2014-08-29 01:06:29 +01:00
photonstorm
2293b64c94 Removing debug / console.log output. 2014-07-09 05:49:13 +01:00
Richard Davey
dd11e2a5a9 Merge pull request #840 from villetou/WebAudioExternalNodeFix
Web audio external node fix
2014-07-01 16:06:08 +01:00
j0hnskot
5ef8143322 Fixes bug #906 2014-06-24 01:59:44 +03:00
j0hnskot
cb0d9c5a69 Fixes bug #906 by adding a check for isDecoded in the update loop. 2014-06-15 21:27:32 +03:00
j0hnskot
5aec4cff8f Fixes bug #906 by adding a check for isDecoded in the update loop. 2014-06-15 21:23:13 +03:00
photonstorm
7d436a7dc3 Update to #868 2014-06-05 13:17:32 +01:00
photonstorm
9aa10f7521 Sound.pause will no longer fire a Sound.onStop signal, and the pause values are set before the onPause signal is dispatched (thanks @AnderbergE, fix #868) 2014-06-05 02:55:20 +01:00
photonstorm
369e2cc2d0 Sound.destroy(true) would call remove on the SoundManager, which in turn would throw a TypeError as it tried to remove the sound events twice (thanks @AnderbergE, fix #874) 2014-06-05 02:50:53 +01:00