Commit graph

235 commits

Author SHA1 Message Date
Pavle Goloskokovic
11923621ad Finding available audio tag when calling play method and resetting and returning false if it was not successful 2018-01-11 18:17:50 +01:00
Pavle Goloskokovic
af8666f611 Added reset method that calls super stop method in order to reset sounds state
Calling reset method and setting audio to null after hijacking audio tag from another sound
2018-01-11 18:15:42 +01:00
Pavle Goloskokovic
106e32499f Sorting sounds to hijack audio from by loop and seek properties values 2018-01-11 18:12:52 +01:00
Pavle Goloskokovic
f377b4fa85 Finding another sound to hijack audio tag from if there are no free audio tags and override setting is set to true 2018-01-11 18:11:10 +01:00
Pavle Goloskokovic
fc19a05f0b Returning false if override setting of sound manager is set to false 2018-01-11 18:05:12 +01:00
Pavle Goloskokovic
935ef78102 Added method for finding unused audio tag for playing sound 2018-01-11 18:04:17 +01:00
Pavle Goloskokovic
6730b3b314 Defined seek property for HTML5AudioSound class 2018-01-11 18:00:42 +01:00
Pavle Goloskokovic
d6b11e2fdb Defined seek property's setter for HTML5AudioSound class 2018-01-11 17:59:36 +01:00
Pavle Goloskokovic
afb8075379 Defined seek property's setter for HTML5AudioSound class 2018-01-11 17:58:26 +01:00
Pavle Goloskokovic
110c6891dd Defined volume property for HTML5AudioSound class 2018-01-11 17:57:04 +01:00
Pavle Goloskokovic
8f9eafd315 Defined mute property for HTML5AudioSound class 2018-01-11 17:55:05 +01:00
Pavle Goloskokovic
495a79d4bf Implemented setRate method 2018-01-11 17:51:58 +01:00
Pavle Goloskokovic
91f9629ed2 Implemented setVolume method 2018-01-11 17:50:20 +01:00
Pavle Goloskokovic
162a063f03 Implemented setMute method 2018-01-11 17:49:40 +01:00
Pavle Goloskokovic
ede81f2a03 Added destroy method 2018-01-11 17:48:23 +01:00
Pavle Goloskokovic
0223019290 Added blank update method 2018-01-11 17:47:01 +01:00
Pavle Goloskokovic
d51156fe94 Added stop method implementation that calls super method and dispatches stop event 2018-01-11 17:45:02 +01:00
Pavle Goloskokovic
196258b8ac Added resume method implementation that calls super method and dispatches resume event 2018-01-11 17:43:56 +01:00
Pavle Goloskokovic
5e8d0dcaee Added pause method implementation that calls super method and dispatches pause event 2018-01-11 17:42:18 +01:00
Pavle Goloskokovic
d3c034e5cc Added play method implementation that calls super method and dispatches play event 2018-01-11 17:40:59 +01:00
Pavle Goloskokovic
b452859b78 Assigning duration and totalDuration values to audio tag duration 2018-01-11 17:38:47 +01:00
Pavle Goloskokovic
1d925105bd Audio property docs update 2018-01-11 17:37:28 +01:00
Pavle Goloskokovic
ad858d1475 Throwing an error if no sound with given key was loaded 2018-01-11 17:36:51 +01:00
Pavle Goloskokovic
cf83880fb0 Defined tags property that holds reference to audio tags array 2018-01-11 17:35:25 +01:00
Pavle Goloskokovic
b22116e1f8 Updated override property docs 2018-01-11 17:32:49 +01:00
Pavle Goloskokovic
2372fdd812 Completed a TODO to return HTML5AudioSoundManager instance when necessary 2018-01-11 17:29:57 +01:00
Pavle Goloskokovic
7c715f1ba0 Removed detune property since it is already implemented in BaseSound class 2018-01-11 17:28:52 +01:00
Pavle Goloskokovic
be713af155 Removed rate property since it is already implemented in BaseSound class 2018-01-11 17:28:25 +01:00
Pavle Goloskokovic
98700ffff2 Updating play method to return boolean indicating if play call was done successfully 2018-01-11 17:27:19 +01:00
Pavle Goloskokovic
15562a70e3 Updated override property docs 2018-01-11 17:25:55 +01:00
Pavle Goloskokovic
2903417798 Defining detune property on a BaseSound class since it's the shared behaviour between subclasses 2018-01-11 17:24:53 +01:00
Pavle Goloskokovic
15f2717e9b Defining rate property on a BaseSound class since it's the shared behaviour between subclasses 2018-01-11 17:24:26 +01:00
Pavle Goloskokovic
c0c6e39ccd Updating play method to return boolean indicating if play call was done successfully 2018-01-11 17:22:57 +01:00
Pavle Goloskokovic
e75871adec Added override property to HTML5AudioSoundManager 2018-01-11 16:50:50 +01:00
Pavle Goloskokovic
9fc3aaa0da Moved HTML5AudioSoundManager.js 2018-01-10 16:50:21 +01:00
Pavle Goloskokovic
081908fd7b Moved HTML5AudioSound.js 2018-01-10 16:50:11 +01:00
Pavle Goloskokovic
d0d3a6473d Merge remote-tracking branch 'origin/master' 2018-01-10 16:20:13 +01:00
Richard Davey
d8f1ba03e9 Moved repository location 2018-01-09 21:43:56 +00:00
Richard Davey
0d90f75b5f Splitting the dev branch up into versions. 2016-11-22 01:36:56 +00:00
photonstorm
7b9c4114b2 Preparing for 2.6.2 release. 2016-08-22 12:31:02 +01:00
Richard Davey
33748ece87 Merge pull request #2697 from hilts-vaughan/fix-sound-loop
Sound: Fixes an issue where loopFull would not return the soundinstan…
2016-08-18 15:29:18 +01:00
Vaughan Hilts
067f3cca83 Sound: Fixes an issue where loopFull would not return the soundinstance that it looped from 2016-08-17 22:15:45 -04:00
Richard Davey
e955cf4222 Sound.play would throw the error "Uncaught DOMException: Failed to execute 'disconnect' on 'AudioNode': the given destination is not connected." in Chrome, if you tried to play an audio marker that didn't exist, while a valid marker was already playing. 2016-08-03 04:04:22 +01:00
Richard Davey
6f9bcae23e Docs fixes #2629 2016-07-17 11:23:41 +01:00
photonstorm
521a6c9dbb Sound.stop will check to see if gainNode exists before trying to disconnect from it. 2016-07-08 12:27:12 +01:00
photonstorm
2310e5dc6f Sound.volume was accidentally repeated twice in the source (thanks @LoneStranger #2569) 2016-06-20 12:18:39 +01:00
Richard Davey
1b67850c82 Merge pull request #2529 from TheJasonReynolds/local_dev
Set isPlaying to true if no marker (.play is not called again)
2016-06-05 15:51:43 +01:00
John Rees
e75827d6ab Signal description typo fix 2016-06-04 19:41:54 +01:00
Jason Reynolds
db0a41bedf Set isPlaying to true if no marker (.play is not called again) 2016-06-03 17:08:07 -05:00
photonstorm
63a1336bd5 Sound.addMarker now has a default value for the duration argument (1 second) to avoid the DOM Exception 11 error if you accidentally miss it out (thanks @mari8i #2508) 2016-06-02 15:29:51 +01:00
photonstorm
d161a7f6bc Sounds played using the Audio tag, set to loop, would get caught in an endless pause-play loop cycle (thanks @rroylance #2473) 2016-05-17 16:43:11 +01:00
photonstorm
54683b7fb2 Sounds played using the Audio tag, that were paused and then resumed again (either directly in code, or via a game pause event) would not resume from the point at which they paused (thanks @rroylance #2473) 2016-05-16 15:16:19 +01:00
photonstorm
58af40ca92 Added a bit more info to the SoundManager docs re: #2373 2016-04-07 01:07:19 +01:00
photonstorm
896b32a28c SoundManager.muteOnPause is a new boolean that allows you to control if the Sound system gets muted automatically when a Phaser game pauses, such as when it loses focus. You may need to set this to false if you wish to control the audio system from outside of your Phaser game, i.e. from DOM buttons or similar (#2382) 2016-04-06 02:09:22 +01:00
photonstorm
61bc4a8dca Sound.play when using an AudioTag would ignore the muted state of the SoundManager and play regardless. It now checks the SoundManager.mute state on play, and sets the volume accorindingly (thanks @brianbunch #2139) 2016-04-06 01:41:54 +01:00
photonstorm
988290631f When setting a global volume for the SoundManager it would previously incorrectly calculate the volumes of AudioTag based Sound objects that were not played at volume 1. The new approach uses Sound.updateGlobalVolume which adjusts the Sound volume to be a percentage of the global volume. So if the global volume is 0.5 and the Sound volume is 0.5, the Sound will play with an actual volume of 0.25 (thanks @VitaZheltyakov #2325) 2016-04-06 01:19:32 +01:00
Richard Davey
71056ccb69 Merge pull request #2371 from stoneman1/dev
Fixed video for future
2016-04-06 01:08:22 +01:00
photonstorm
f40cfbe2ae 2015 - 2016. 2016-04-04 22:16:16 +01:00
Stoneman1
4a29d5102d Fixes issue #2325 2016-03-02 11:57:41 +02:00
Silvan Strübi
1b1c4ef0f5 AudioBufferSourceNode - same issue as on play:
I was able to reproduce this rare occurrence. It gets triggered by me in some cases when leaving focus and then resuming the sound. Same as we have had it only play, see => https://github.com/photonstorm/phaser/issues/2351

Cheers
2016-03-02 10:06:01 +09:00
photonstorm
08ce659447 Sound.position can no longer become negative, meaning calls to AudioContextNode.start with negative position offsets will no longer throw errors (thanks @Weedshaker #2351) 2016-02-26 13:36:19 +00:00
photonstorm
15d952171c SoundManager.destroy doesn't close the context if it's being stored in PhaserGlobal (thanks @brianbunch #2356) 2016-02-26 13:31:45 +00:00
photonstorm
cc3a07bada SoundManager.close now validates that context.close is a valid function before calling it (thanks @brianbunch #2355) 2016-02-26 13:29:35 +00:00
Stoneman1
62f0a52544 Fixed issue with IE crashing on this.context.close() in SoundManager.js (There was no check if context exists) 2016-02-24 13:08:37 +02:00
Richard Davey
332fb6fe68 Fixed window global check. 2016-02-09 11:41:24 +00:00
Richard Davey
0610ddd15f SoundManager.setTouchLock is no longer set if SoundManager.noAudio is true, or if the PhaserGlobal setting disableAudio is true (thanks @bcjordan #2206) 2016-02-03 23:23:36 +00:00
Richard Davey
3b686f906f Moved the Sound.disconnect after the Sound.stop call in Web Audio (#2280) 2016-02-03 22:22:22 +00:00
Richard Davey
425ee09047 Sound.onEndedHandler now sets Sound.currentTime to be Sound.durationMS (thanks @stoneman1 #2237) 2016-02-02 01:08:45 +00:00
Richard Davey
e7820dbe85 SoundManager.destroy now calls AudioContext.close (thanks @stoneman1 #2237) 2016-02-02 01:08:35 +00:00
photonstorm
172f972d8c Pausing a Sound that used a Marker for playback would fire the onMarkerComplete signal by mistake as well as stop the fadeTween. This Signal is now only dispatched if Sound.stop is called and the Sound isn't paused (thanks Corin) 2015-12-02 12:41:20 +00:00
photonstorm
f64fc42f3e The SoundManager now detects if the browser is running under iOS9 and uses a touchend callback to unlock the audio subsystem. Previous versions of iOS (and Android) still use touchstart. This fixes Apple's screw-up with regard to changing the way Web Audio should be triggered in Mobile Safari. Thanks Apple (thanks @MyCatCarlos for the heads-up #2095) 2015-09-22 11:46:58 +01:00
Pappa
12d24d3677 Fix for AudioBufferSourceNode listener memory leak.
In Chrome, the AudioBufferSourceNode onended listeners were never being garbage collected. This frees up the listener for collection.
2015-09-08 17:56:17 +01:00
photonstorm
a8934c392d Phaser.Sound will now automatically check the Cache to see if the audio file it is using is still there or not. If not then it will automatically called Sound.destroy on itself. If you do not desire this result then you should ensure that you undertake all house-keeping yourself, and properly destroy Sound objects _before_ calling Cache.removeSound (#1946) 2015-07-27 14:02:04 +01:00
photonstorm
f15fe6706c All undefined argument checks were changed from if (typeof x === 'undefined') to if (x === undefined) removing the typeof check and saving some bytes across the codebase in the process. 2015-07-22 10:37:15 +01:00
photonstorm
8356aacaa8 Trying out new Text pivot and mute handling. 2015-06-24 19:57:40 +01:00
photonstorm
1ed33cb06c Setting mute to false on Sound that was never muted caused its volume to be set to zero (thanks @brianbunch #1870) 2015-06-24 15:54:25 +01:00
photonstorm
1990bce48b Sound.restart and Sound.stop now properly disconnect the sound from the gainNode (or external node) before stopping it, allowing restart to work correctly (thanks @eofs #1796) 2015-06-16 16:24:47 +01:00
photonstorm
ab8c98676e Sound.resume wouldn't properly restart looped sounds in Chrome after being paused. Phaser now specifically handles the Chrome 42 bug and later fix (thanks @nkovacs #1820) 2015-06-16 14:28:46 +01:00
photonstorm
1c1a2ac195 Volume should default to 1 if undefined OR null (as from an Audio Sprite) 2015-06-09 20:55:20 +01:00
photonstorm
621e51d949 Docs update about the lovely 48000 Hz music bug. 2015-05-23 03:37:04 +01:00
photonstorm
4cd374691a Wrapped the decodeAudio in a try/catch. 2015-05-14 23:21:19 +01:00
photonstorm
766b110f99 SoundManager now uses the new Touch.addTouchLockCallback methods to handle mobile device audio unlocking. 2015-05-05 16:25:16 +01:00
photonstorm
7178ff61c7 jsdoc fixes. 2015-05-05 14:00:29 +01:00
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