Type Function Library audio.* Return value Number Revision Current Public Release (2017.3068) Keywords audio, duration See also audio.loadSound() audio.loadStream()
This function returns the total time in milliseconds of the audio resource. If the total length cannot be determined,
-1 will be returned.
Assuming a duration can actually be determined, the number returned may not be completely accurate. Particularly for sounds loaded with audio.loadStream(), the information may be a estimate or may just be slightly off due to inaccurate metadata. The type of file and encoding you use may have an impact on the accuracy of this value.
audio.getDuration( audioHandle )
local backgroundMusic = audio.loadStream( "backgroundMusic.m4a" ) local totalTime = audio.getDuration( backgroundMusic ) print( totalTime )