audio.getDuration()

Description:

Returns the total time in milliseconds of the audio resource. If the total length cannot be determined, -1 will be returned.

Syntax:

audio.getDuration( audioHandle )

Example:

backgroundMusic = audio.loadStream( "backgroundMusic.m4a" )
totalTime = audio.getDuration( backgroundMusic )

Parameters:

audioHandle
object: The audio object returned by audio.loadStream() or audio.loadSound().

Returns:

Returns the total time in milliseconds of the audio resource.

Remarks:

Assuming a duration can actually be determined, the number returned may not be completely accurate. Particularly for sounds loaded with 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.

Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    Build 2011.222
  • Windows:
    Build 2011.222
  • iOS:
    Build 2011.222
  • Android:
    Build 2011.222

Replies

Pasz72
User offline. Last seen 2 years 15 weeks ago. Offline
Joined: 13 Jul 2011

This works perfectly with iOS, but when encoded as ogg, I cannot get this to work on Android.