Control audio with this slick api for controlling one or many audio tracks at simultaneously.
This method plays the audio track from the current position (default position if not set is 0, the beginning)
This method pauses the audio track.
This method toggles between the play and pause methods. It will pause if it is playing and play if it is paused.
This method stops the audio track and sets the position back to the beginning.
This method sets the volume of the audio track. The volume parameter is a percentage of complete volume: a value from 0 to 100.
This method sets the position of the audio track. The position parameter is a 'double' representing seconds in the track.
This method sets the rate at which the audio track is played. The default rate value is 1. Anything lower than one makes it slower, likewise anything higher than 1 makes it faster.
This method loads a different audio track from the file in the path specified. The filePath parameter must be a path to an audio file that exists or none of these audio methods will work.
This method reloads the already loaded audio file. This can be used as a kind of refresh. It will in fact completely reload the original audio file, making a network call.
This method sets the boolean value of whether or not the audio track should loop back to the beginning when it reaches the end.
This method starts a seamless loop. The fadeLength parameter is a number representing the number of seconds it should use to fade back into itself and fade into at the beginning.
A seamless loop fades into the audio track and then proceeds to play seamlessly. The track will only be seamless if the audio file doesn't contain any silence at the beginning or end of the file. The track MUST be more than two times longer than the fadeLength used. NOTE: this is meant to be used for ambient sound files not music or short clips of sound effects.
This method is the proper way to stop a seamless loop. If you use the stop method it will most likely not completely stop and odd behaviour may occur. If you want to stop the seamless loop less abruptly you can use the fadeOutSeamlessLoop method.
This method is for fading out the seamless loop. This method is a good alternative for stopSeamlessLoop seeing as it stops it after fading it out, giving a more seamless feel.
This function will fade a seamless loop in or out depending on its previous state.
This method fades in the audio track. The fadeLength parameter is a number representing the duration of the effect in seconds. NOTE: the track must being longer than the number of seconds given for the fadeIn effect. The optional parameter 'finished' is a callback function for when the audio track is finished fading in.
This method fades out the audio track. The fadeLength parameter is a number representing the duration of the effect in seconds. NOTE: the track must being longer than the number of seconds given for the fadeOut effect. The optional parameter 'finished' is a callback function for when the audio track is finished fading out.
This method will wait to fade out until it reaches the end of the audio track. Specifically, it will start fading the audio track out when the track is as many seconds away from the end as the fadeLength that is specified. In this way, you can think of the fadeLength acting as a "startFade" parameter, being both the duration of the effect and the specified beginning of the effect itself. In other words: when the track's current position is equal to the end of the track minus the fadeLength, the fade effect will begin.
The optional parameter 'started' is a callback function for when the audio track has started fading out. The optional parameter 'finished' is a callback function for when the audio track is finished fading out.
The audio gallery object gives you the ability to manage a group of audio tracks.
Syntax: AudioGallery(audioTracks, rootPath)
The audio gallery constructor has two parameters: audioTracks and rootPath
audioTracks: is an object containing audio track names and file paths. rootPath: is an optional parameter that allows you to set a root path that will be appended to all file paths in the audio gallery. So if you have all of your audio files in a directory called "audio", you would want to set the rootPath to "audio/".
Example:
var ag = new AudioGallery({
birdSounds: "animals/birdSounds.wav",
rainSounds: "lightRain.mp3",
thunderSound: "thunder.mp3"
}, "audio/");
This method plays the given audio track. The name parameter is the name of the audio track to play. The vol parameter is the number value of the volume, going from 0 (off) to 100 (as loud as possible). The default volume value is 100. If the optional 'only' parameter is set to true then only this track will play and all other tracks will be stopped.
This method pauses the given audio track.
This method toggles the given track between playing is pausing.
This method stops the given track. (See Audio.stop() )
This method stops all audio tracks in this gallery.
This method toggles a seamless loop for the given audio track, using the provided fadeLength.
This method will randomly play an audio track in the gallery from the beginning. If the audio track it selects to play is already playing it will stop it first.