G.SoundDuration
From GMod Wiki
| Function | |
| Syntax |
SoundDuration( String sound_path ) Where is this used? |
| Description: | |
| Returns the length of a sound in seconds. | |
| Returns: | Float |
| Part of Library: | Global Functions |
| Realm: |
|
| BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=G.SoundDuration]G.SoundDuration [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Example
| Description | Print the length (in seconds) of the sound. |
|---|---|
| Used on | |
| Code | print( SoundDuration( "npc/metropolice/pain1.wav" ) ) |
| Output | 0.55986392498016 |
Notes
This seems to fail on some dedicated servers for some reason. This can be remedied by appending "../../hl2/sound/" to your soundpath if you have issues.
For example:
| Description | Print the length (in seconds) of the sound. |
|---|---|
| Used on | |
| Code | MySound = Sound( "npc/metropolice/pain1.wav" ) print( SoundDuration( "../../hl2/sound/" .. MySound ) ) |
| Output | 0.55986392498016 |
Additional Notes
- Only works with .wav files.