Library
Here you will find a very complete 2D and 3D audio system that you can integrate into any script.
Functions
Playing Sound
--2D Sound
PlayMusicUrl(musicIdentifier, URL, volume, loop, options)
-- loop and options parameters are optional, so they aren't needed to execute the function
--3D Sound
PlayMusicUrlPos(musicIdentifier, URL, volume, loop, options)
-- loop and options parameters are optional, so they aren't needed to execute the function
- onPlayStart
- onPlayEnd
- onLoading
- onPlayPause
- onPlayResume
Manipulation with sound
Position(musicIdentifier, Vector3 vec)
-- Will update location of sound
Distance(musicIdentifier, newDistance)
-- Will set new playing distance from location
Destroy(musicIdentifier)
-- Will destroy sound
Pause(musicIdentifier)
-- Will pause sound
Resume(musicIdentifier)
-- Will resume sound
setVolume(musicIdentifier, volume)
-- volume is from 0.0 to 1.0
-- Will set a new value to volume. Should be used for non 3D sound
setVolumeMax(musicIdentifier, volume)
-- volume is from 0.0 to 1.0
-- will set new value to max volume. Should be used only for 3D sound
setTimeStamp(musicIdentifier, time)
-- will set a new timestamp.
setSoundURL(musicIdentifier, url)
-- will set new URL to sound (will play whenever changed)
repeatSound(musicIdentifier)
-- will play again the saved sound
destroyOnFinish(musicIdentifier, bool)
-- true = destroy on end / false = do not destroy on end
setSoundLoop(musicIdentifier, bool)
-- will set a new value to loop
setSoundDynamic(musicIdentifier, bool)
-- will set if the sound is 3D / 3D = true
Effects on sound
fadeOut(musicIdentifier, time)
fadeIn(musicIdentifier, time, volume)
Events (client side only)
onPlayStart(name, function)
--This event will trigger after the sound
--is loaded and start playing in game.
onPlayEnd(name, function)
--This event will be triggered after sound end.
onLoading(name, function)
--This event will be triggered when the sound start loading.
onPlayPause(name, function)
--This event will be triggered whenever you pause sound.
onPlayResume(name, function)
--This event will be triggered whenever you resume sound.
Getting info about sound
soundExists(name)
--Will return true/false if sound exists
isPaused(name)
--Will return true/false if song is paused
isPlaying(name)
--Will return true/false if song is playing
isLooped(name)
--Will return true/false if sound is looped
getDistance(name)
--Will return distance in Integer
getVolume(name)
--Will return current volume of music.
getPosition(name)
--Will return vector3
isDynamic(name)
--Will return if sound is 3D or 2D (3D = true, 2D = false)
getTimeStamp(name)
--returns current timestamp
getMaxDuration(name)
--returns max duration of sound
getLink(name)
--Will return url link
isPlayerInStreamerMode()
--will return if player got streamer mode enabled.
getAllAudioInfo()
--Will return array of all sound
isPlayerCloseToAnySound()
--will return true if player is close to any sound.
getInfo(name)
--Will return an array with info of the sound...
-- return:
{
volume, -- value from 0.0 to 1.0
url , -- sound url
id, -- id
position, -- will be nil if position isnt set.
distance, -- distance in integer
playing, -- true/false
paused, -- true/false
loop, -- true/false
isDynamic, -- true/false
timeStamp, -- returns current timestamp
maxDuration, -- returns max duration of sound
destroyOnFinish, -- default value is true means after its finish it will destroy it self
}